This is their indicator. It works really well. Is there any way to turn it into a scan in order to see stocks that are making new highs over and over?
I've tried before but it is too intensive for TD's servers.
This is my scan:
I've tried before but it is too intensive for TD's servers.
Code:
input marketOpen = 830;
input marketClose = 1500;
input intraDaySpan = {Default "SameDay" , "OverNight"};
input numberOfDays = 1;
input numberOfYears = 0;
plot newhigh; #I'm adding this for scans. See the end
def okToPlot = GetLastDay() - numberOfDays <= GetDay() and GetLastYear() - numberOfYears <= GetYear() ;
def OpenCounter = SecondsFromTime(marketOpen);
def CloseCounter = SecondsTillTime(marketClose);
def MarketHours = if OpenCounter >= 0 and CloseCounter >= 0 then 1 else 0;
def beforeMidnight = OpenCounter >= 0 and CloseCounter <= 0;
def afterMidnight = OpenCounter <= 0 and CloseCounter >= 0 ;
def Today ;
def hideChartBubbles ;
rec DailyHigh ;
rec DailyLow ;
switch (intraDaySpan) {
case "SameDay":
Today = if GetDay() != GetDay()[1] then 1 else 0;
DailyHigh = if MarketHours then if high > DailyHigh[1] then high else DailyHigh[1] else high;
DailyLow = if Today then low else if MarketHours then if low < DailyLow[1] then low else DailyLow[1] else low;
hideChartBubbles = MarketHours;
case "OverNight":
Today = 0;
DailyHigh = if beforeMidnight or afterMidnight then if high > DailyHigh[1] then high else DailyHigh[1] else high;
DailyLow = if beforeMidnight or afterMidnight then if low < DailyLow[1] then low else DailyLow[1] else low;
hideChartBubbles = beforeMidnight or afterMidnight;
};
AddLabel(close > 0, Concat( "Dly High: " , DailyHigh), Color.GRAY);
AddLabel(close > 0, Concat( "Dly Low: " , DailyLow), Color.GRAY);
AddLabel(close > 0, Concat("Range: " , (DailyHigh - DailyLow) / TickSize()), Color.GRAY);
plot TodaysHigh = if okToPlot and MarketHours then DailyHigh else Double.NaN;
plot TodaysLow = if okToPlot and MarketHours then DailyLow else Double.NaN;
TodaysHigh.SetDefaultColor(Color.GREEN);
TodaysLow.SetDefaultColor(Color.RED);
AddChartBubble(DailyHigh > DailyHigh[1] and hideChartBubbles and okToPlot, DailyHigh, "Hi", color.GREEN, yes);
AddChartBubble(DailyLow < DailyLow[1] and hideChartBubbles and okToPlot, DailyLow, "Lo", color.RED, no);
Alert(DailyHigh > DailyHigh[1] and MarketHours, "New Hi", Alert.ONCE);
Alert(DailyLow < DailyLow[1] and MarketHours, "New Low", Alert.ONCE);
This is my scan:
Code:
if DailyHigh > DailyHigh[1] and MarketHours {
newhigh = 1;
} else {
newhigh = 0;
}
Last edited by a moderator: