I want to lock the profit once it achieve a certain price level. But before this I do not want to trail in any way. I have tried many different ways but I can code it properly. Any ideas?
I think there may be a logic flaw in if(TradePriceClose). TradePriceClose is literally the price in which the trade itself closed, so why would the closing of the trade generate a new stop for a trade that has already closed?