I have a strategy with two orders with 2 stops and 2 profit target,
I want to enter the first order if the conditions are met, and a second order once the close price is less than something; then move the stoploss1 to breakeven and enter a second order with stoploss at breakeven. Only once in a day for both orders. This is my code, but the second order enters more than once in a day.
Could you please me tell me what's wrong in my code?
if (ToTime(Time[0]) == ToTime(8, 0, 0))
{
Variable0 = 2021.75;
SetStopLoss("PT1", CalculationMode.Ticks, StopLoss1, false);
SetStopLoss("PT2", CalculationMode.Ticks, StopLoss2, false);
Entrada1 = false;
Entrada2 = false;
}
// Condition set 2
if ( ToTime(Time[0]) > ToTime(9, 30, 0)
&& ToTime(Time[0]) < ToTime(10, 30, 0)
&& Close[0] < Variable0
&& Open[0] > Close[0]
&& Entrada1 == false
&& Entrada2 == false)
{
EnterShort(DefaultQuantity, "PT1");
SetProfitTarget("PT1", CalculationMode.Ticks, ProfitTarget1);
SetStopLoss("PT1", CalculationMode.Ticks, StopLoss1, false);
Entrada1 = true;
}
if (Close[1] < (Position.AvgPrice - MovBE * TickSize))
{
SetStopLoss ("PT1", CalculationMode.Price, Position.AvgPrice - 1 * TickSize, false);
EnterShort(DefaultQuantity, "PT2");
SetStopLoss ("PT2", CalculationMode.Price, Position.AvgPrice - 1 * TickSize, false);
SetProfitTarget("PT2", CalculationMode.Ticks, ProfitTarget2);
Entrada2 = true;
}
}
Comment