I wish to turn on the trailling stop once the order PnL is more than trailingStop,
my code is as follow
(within the OnOrderUpdate)
if((GetCurrentBid()-OrderOne.AvgFillPrice)>trailingStop &&
(GetCurrentBid()-OrderOne.AvgFillPrice)>LockedUpProfit)
{
LockedUpProfit=GetCurrentBid()-OrderOne.AvgFillPrice;
}
else
{
if(GetCurrentBid()-LongOrder.AvgFillPrice<LockedUpProfit)
{
LockedUpProfit=0;
ExitLong("###Trailing###","LongOrderOne");
}
}
it turns out that the trailing stop is not working as expected
what will be the right place for me to define the LockedUpProfit variable??
(etc. in OnBarUpdate, Initialize)
and what's wrong with the coding??
I would be really appreciate for your reply and thank you very much for reading.

Comment