Stop order within specified time period

Questions about MultiCharts and user contributed studies.
dingmanhoe123
Posts: 61
Joined: 25 Jul 2013
Has thanked: 18 times

Stop order within specified time period

Postby dingmanhoe123 » 12 Feb 2014

I used the following to generate a stop order within time>=0916 and time<=1615,I tried the following programme in backtesting and found that stop order will not be generated outside the time period. however I still see stop order generated in IB screen after 1615 in real trade, is there any problem with the following programme?

if date=trade_date then begin

if time>=0916 and time<=1615 then begin

if ((mp_s[1]=0 and mp_s>0) or
(mp_s[1]=0 and mp_s<0) or
(mp_s[1]>0 and mp_s=0) or
(mp_s[1]<0 and mp_s=0) or
(mp_s[1]>0 and mp_s<0) or
(mp_s[1]<0 and mp_s>0)) then traded=traded+1;

If traded=0 and action = 1 then
buy 2 contract next bar at Tri stop;

If traded=0 and action = 2 then
sellshort 2 contract next bar at Tri stop;

end;
end;

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Stop order within specified time period

Postby Henry MultiСharts » 13 Feb 2014

Hello dingmanhoe123,

Even in backtesting the following code can generate the order after 1615 as "next bar" order command is used and the condition is "if time>=0916 and time<=1615".


Return to “MultiCharts”