I have been using TradeStation for several years, but have only just started testing on 5 minute data. Previously all my coding was for daily data.
Iâm having a problem writing code to exit a trade at tomorrowâs open. For example the following code buys at todayâs open plus 0.5 x yesterdayâs true range. I then wish to exit MOO tomorrow; however this code always exits at the open of tomorrowâs âsecondâ five minute bar rather than the first, i.e. If market opens at 9.00am the code exits at 9.05am.
Any thoughts on where Iâm going astray would be much appreciated.
{Data1 is 5 minute data, Data2 is daily data.}
Vars: dATR(0), ent(0);
{Start calculations on first 5 minute bar of the day}
If Date <> Date[1] then begin
dATR = AvgTrueRange(1) of data2; {Yesterdayâs TR}
ent = Open + 0.5*dATR;
end;
Buy at ent stop;
If Date <> Date[1] then ExitLong at Open;
Iâm having a problem writing code to exit a trade at tomorrowâs open. For example the following code buys at todayâs open plus 0.5 x yesterdayâs true range. I then wish to exit MOO tomorrow; however this code always exits at the open of tomorrowâs âsecondâ five minute bar rather than the first, i.e. If market opens at 9.00am the code exits at 9.05am.
Any thoughts on where Iâm going astray would be much appreciated.
{Data1 is 5 minute data, Data2 is daily data.}
Vars: dATR(0), ent(0);
{Start calculations on first 5 minute bar of the day}
If Date <> Date[1] then begin
dATR = AvgTrueRange(1) of data2; {Yesterdayâs TR}
ent = Open + 0.5*dATR;
end;
Buy at ent stop;
If Date <> Date[1] then ExitLong at Open;