Scan First Candle Crossing Above Previous Week High


Category:
0
0

Hey, you helped out on this study a while ago for ToS.  I’ve tried to convert this to a scan where today’s candle crosses the previous week but I get the error cannot use secondary time frame.

 

Plot first candle crosses prev week high.

 

If you could help again that would be great.

Thanks!

Marked as spam
Posted by (Questions: 10, Answers: 15)
Asked on November 3, 2022 5:58 pm
95 views
0
Private answer

There are limitations on the amount of historical data available to custom scans. For time frames less than 1 hour the scan engine only has 11-13 trading sessions to use. This scan will require at least 10 trading sessions to compute the key metrics. So this is right on the borderline of what is feasible for lower time frames. If you find it does not work on time frame below 1 hour, you will need to increase the time frame to 1 hour or higher.

This solution replaces the secondary aggregation with two recursive variables to track the weekly high and the previously weekly high:

def newWeek = GetWeek() <> GetWeek()[1];
rec weeklyHigh = if newWeek then high else if high > weeklyHigh[1] then high else weeklyHigh[1];
rec previousWeekHigh = if newWeek then weeklyHigh[1] else previousWeekHigh[1];
rec firstCrossAbove = if newWeek[-1] then 0 else if high > previousWeekHigh then 1 else firstCrossAbove[1];
plot crossingWeeklyHigh = firstCrossAbove and !firstCrossAbove[1];

Marked as spam
Posted by (Questions: 37, Answers: 4079)
Answered on November 3, 2022 8:40 pm