i have a problem with my stop and limit order in term of "timing"
i script is running on 5 minutes, when my script buy, normally it send a stop order and a limit order... but it send the order on the next 5 minutes after the buy order.
for example, at 10h05 my script buy but it send the stop and limit order at 10h10... so i have 5 minutes without stop on the market
Please, help me to fix this problem, i would like than my stop and limit order is send when the buying order is filled.
here my script of the order
if (Positions[0].MarketPosition==MarketPosition.Flat)
{
Stop = Low[0] - 3*TickSize;
Stop1 = Low[0]- 3*TickSize;
TP = Close[0]+(Close[0]-Stop);
tp1hit=false;
tp2hit=false;
}
}
}
}
if (Positions[0].MarketPosition!=MarketPosition.Flat)
{
if (Positions[0].MarketPosition==MarketPosition.Long)
{
if (High[0]>=TP)
{
if (!tp1hit)
{
TP=Positions[0].AvgPrice+(Positions[0].AvgPrice-Stop1)*1.50;
tp1hit=true;
Stop=Low[CurrentBar-barNumberOfOrder];
}
elseif (!tp2hit)
{
TP=Positions[0].AvgPrice+(Positions[0].AvgPrice-Stop1)*2;
tp2hit=true;
Stop=Positions[0].AvgPrice+2*TickSize;
}
}
ExitLongLimit(Positions[0].AvgPrice+(Positions[0].AvgPrice-Stop1)*2,"Long Profit", "Entry Long");
}
ExitLongStop(Stop,"Long Stop", "Entry Long");
}

Comment