Topics
Replies
ubiratamoreira.trader
06 Jun 2023, 17:35
modificado e continua nao abrindo ardens deve haver outro erro nas modificaçoes que fiz
using System;
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class PipsDeVelas : Robot
{
[Parameter("Pips de Compra", DefaultValue = 40)]
public int CompraPips { get; set; }
[Parameter("Pips de Venda", DefaultValue = 40)]
public int VendaPips { get; set; }
[Parameter("Trailing Stop (Pips)", DefaultValue = 30)]
public int TrailingStopPips { get; set; }
[Parameter("Tamanho do Lote", DefaultValue = 0.01)]
public double LotSize { get; set; }
protected override void OnStart()
{
Positions.Closed += OnPositionClosed;
}
protected override void OnBar()
{
double currentCandleRange = Symbol.Bid - Symbol.Ask;
double compraPipsValue = CompraPips * Symbol.PipSize;
double vendaPipsValue = VendaPips * Symbol.PipSize;
if (currentCandleRange > compraPipsValue)
{
double volume = Symbol.QuantityToVolumeInUnits(LotSize);
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, volume, "Compra", null, null, null, GetTrailingStop());
}
if (currentCandleRange > vendaPipsValue)
{
double volume = Symbol.QuantityToVolumeInUnits(LotSize);
ExecuteMarketOrder(TradeType.Sell, Symbol.Name, volume, "Venda", null, null, null, GetTrailingStop());
}
}
private void OnPositionClosed(PositionClosedEventArgs args)
{
Print("Position closed: " + args.Position.Label);
}
private bool GetTrailingStop()
{
return true;
}
}
}
@ubiratamoreira.trader
ubiratamoreira.trader
07 Jun 2023, 18:32
07/06/2023 11:50:22.737 | CBot instance [pips de velas, XAUUSD, m1] started.
07/06/2023 11:51:00.458 | Failed to place Market Order Sell XAUUSD 1 with error code InvalidRequest
using System;
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class PipsDeVelas : Robot
{
[Parameter("Pips de Compra", DefaultValue = 40)]
public int CompraPips { get; set; }
[Parameter("Pips de Venda", DefaultValue = 40)]
public int VendaPips { get; set; }
[Parameter("Trailing Stop (Pips)", DefaultValue = 30)]
public int TrailingStopPips { get; set; }
[Parameter("Tamanho do Lote", DefaultValue = 0.01)]
public double LotSize { get; set; }
protected override void OnStart()
{
Positions.Closed += OnPositionClosed;
}
protected override void OnBar()
{
double compraPipsRange = CompraPips * Symbol.PipSize;
double vendaPipsRange = VendaPips * Symbol.PipSize;
if (Symbol.Bid - Symbol.Ask > compraPipsRange)
{
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, Symbol.QuantityToVolumeInUnits(LotSize), "Compra", null, null, null, GetTrailingStop());
}
if (Symbol.Ask - Symbol.Bid > vendaPipsRange)
{
ExecuteMarketOrder(TradeType.Sell, Symbol.Name, Symbol.QuantityToVolumeInUnits(LotSize), "Venda", null, null, null, GetTrailingStop());
}
}
private void OnPositionClosed(PositionClosedEventArgs args)
{
Print("Position closed: " + args.Position.Label);
}
private bool GetTrailingStop()
{
return true;
}
}
}
@ubiratamoreira.trader