Low High from United Traders scan?

ezrollin

Member
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.

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:
Solution
@ezrollin Per your request, I have converted the study you posted above into a scan. This is based on the underlying logic as contained in your study. I have configured this as a bullish scan. If you'd like to set this up as a bearish scan, just change the plot statement on the last line to

Code:
plot scan = bear;

I have tested both bullish as well as bearish scans against the S&P 500 (daily chart) For bullish I get 83 results and for bearish scan I get 273 results

Here is the scan code

Code:
input marketOpen = 830;
input marketClose = 1500;
input intraDaySpan = {Default "SameDay" , "OverNight"};
input numberOfDays = 1;
input numberOfYears = 0;

def okToPlot = GetLastDay() - numberOfDays <= GetDay() and GetLastYear() -...
@ezrollin Per your request, I have converted the study you posted above into a scan. This is based on the underlying logic as contained in your study. I have configured this as a bullish scan. If you'd like to set this up as a bearish scan, just change the plot statement on the last line to

Code:
plot scan = bear;

I have tested both bullish as well as bearish scans against the S&P 500 (daily chart) For bullish I get 83 results and for bearish scan I get 273 results

Here is the scan code

Code:
input marketOpen = 830;
input marketClose = 1500;
input intraDaySpan = {Default "SameDay" , "OverNight"};
input numberOfDays = 1;
input numberOfYears = 0;

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;
};

def TodaysHigh = if okToPlot and MarketHours then DailyHigh else Double.NaN;
def TodaysLow = if okToPlot and MarketHours then DailyLow else Double.NaN;

def bull = DailyHigh > DailyHigh[1] and MarketHours;
def bear = DailyLow < DailyLow[1] and MarketHours;

plot scan = bull;
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
353 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top