I'd like to create a strategy where a stop limit order is placed after a condition is met, then cancel this order X bars later if not filled. If it is filled, I'd like to trail the stop based upon the previous bar's close.
For example, on a long trade, after the condition is met, I'd like an order placed below the market. After X bars and not filled, cancel the order. If the order is filled, I'd like the stop to be set on the low of the previous bar, then trail up on the close with each bar.
Is there a code example for this?
Thanks.

Comment