I have a strategy that enters a trade and manages the take profits and stop loss using the ExitLongStop and ExitLong orders
When my first take profit hits, I update the stop loss quantity and then take the profit.
For example: Once entering a trade with 600 stocks. When the first take profit hits, I decrease the quantity of the stop loss to 400 stocks and exit 200 stocks as follows
// Update stop loss quantity
stopOrder = ExitLongStop(0, true, 400 , stopOrder.StopPrice , "STOP_LOSSS" , "ENTRY");
// Take profit
ExitLong(200 , "FIRST_TAKE_PROFIT" , "ENTRY");
In some cases, I've noticed that the stop loss order doesn't get updated and my trade is left without any stop loss.
(The order of the stop loss is canceled instead of being updated with the right quantity).
It is important to mention that this is not consistent. Sometimes the stoploss order igets updated properly.
Can someone help me understand what I'm doing wrong?
Is there a race condition between the ExitLongStop and ExitLong orders (I know that the stop order should be updated prior to taking the profit).
Regards,
Ron

Comment