Here is my code, in real trade, it looks the market order doesn’t work even target price meet after 5 seconds, any idea?
Code: Select all
[IntrabarOrderGeneration = true]
Var: settle_s(-1), target_price(xxx);
if close >= target_price and marketposition > 0 then
begin
if settle_s = -1 then
settle_s = time_s;
sell("limit") next bar at target_price limit;
end;
If eltimetodatetime_s(time_s) - eltimetodatetime_s(settle_s) > eltimetodatetime_s(5) and marketposition > 0 then
sell("(Market Close)") next bar at market;