Quote from ytr30:
I'm trying to code simple scan in Tradestation but can't figure out how to use 2 different timeframes. Hope somebody can help.
This is what I'm trying to code:
on 5 min chart looking for highest(high, 60)
and on daily chart needs to be above bolligerband upperband
I'm scanning in radarscreen, all symbols 5 min interval
Thank you in advance!
the functions HighD, LowD, and CloseD are helpful for what you are trying to do. They reference daily HLC values from within an intraday chart (bartype < 2).
For the simple case of price being the close of the daily bar, you can simply use CloseD to reference the past N daily closes, including the current unfinished close if the session is active.
For bollinger bands, you first need to calculate the average:
avg = 0;
for index = 0 to N - 1 begin
avg = avg + (1 / N) + CloseD(index);
end;
next is the standard deviation:
var = 0;
for index = 0 to N - 1 begin
var = var + (1 / (N - 1)) * square(CloseD(index) - avg);
end;
std = squareroot(var);
last thing is to calculate the band values:
upperband = avg + numStd * std;
lowerband = avg - numStd * std;
your filtering criteria is then
closeD(0) > upperband;
hope this helps,
rt