I am wondering the most efficient way to code a take profit and stop loss order at the same time as an EnterLong() order.
For example I'd like the take profit and stop loss to be based on the average true range at the specific time of order entry so I would like to simultaneously enter the stops with the EnterLong(). However the conditions are within an OnBarUpdate() function so each time the script runs those stops are removed unless the conditions for meeting the EnterLong() are fulfilled again, correct?
I have tried using the SetProfitTarget and StopLoss functions but I find the particularly buggy and would like to do this with direct order management. I remember with NT7 there was a LiveUntilCancelled field or something but I never fleshed out this same issue in that version of the script.
Summary: How do you enter a market order and its take profit and stop loss at the same time while preventing canceling these orders after the next bar?
Thanks

Comment