I have a strategy with profit taking limit order (based on 1min bars) and want to keep this order alive in the case the position was exited on chart but still open at broker (IB). If I want to do so only for the bar, the "chart order" was exited, would the following framework (short position with profit taking based on EntryPrice) be a solution? The order should be active asap (exit + 1 tick) and is part of an OCO order.
Code: Select all
[IntraBarOrderGeneration=true];
Vars: IntraBarPersist EP(0),IntraBarPersist MP(0), IntraBarPersist BSE(0);
EP=EntryPrice(1);
MP=MarketPosition;
BSE=BarsSinceExit(1);
if MP = 0 and MarketPosition_at_Broker_for_The_Strategy = -1 and BSE<1 then begin
BuyToCover next bar at EntryPrice(1)-XX points limit;
end;