Previous Day High and Low Breakout Indicator for ThinkorSwim

justatrader2021

New member
Can somebody help me setup the following thinkscrips code/scan, TOS lacks additional conditions

I just want to scan for:
Candle that make high over previous day high of day, yet closes under it.
or
Make low below previous day low of day, and closes over it.

Thats it! TOS custom candle pattern builder is missing the integration with the previous high of day study or any studies for that matter.
If I want to scan for 3 ascending candles, yet over vwap, its impossible to incorporate any indicators into the candle scanner.
 

MerryDay

Administrative
Staff member
Staff
VIP
Daily Higher Highs or Lower Lows That Are Reversing
Scan Rules:
  1. Run with a daily aggregation
  2. Scan = highcandle is true OR lowcandle is true

Ruby:
plot highcandle = high > high[1] and close <  high;
plot lowcandle =  low  < low[1]   and close  > low ;
 

SleepyZ

Well-known member
Can somebody help me setup the following thinkscrips code/scan, TOS lacks additional conditions

I just want to scan for:
Candle that make high over previous day high of day, yet closes under it.
or
Make low below previous day low of day, and closes over it.

Thats it! TOS custom candle pattern builder is missing the integration with the previous high of day study or any studies for that matter.
If I want to scan for 3 ascending candles, yet over vwap, its impossible to incorporate any indicators into the candle scanner.

See if this helps

Ruby:
def ymd        = GetYYYYMMDD();
def candles    = !isnan(close);
def capture    = candles and ymd != ymd[1];
def dayCount   = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
def thisDay    = (HighestAll(dayCount) - dayCount) ;
def phd        = if thisday==0 then double.nan else if thisday== 1 and secondsfromTime(0930)== 0
                 then high else if thisday==1 then Max(high, phd[1]) else phd[1];
def phdext     = if IsNaN(phd) then phdext[1] else phd;
def  ph        = phdext;
def  cond1     = if thisday==0 and
                 open > phdext
                 then 1 else 0;
def cond2      = if thisday==0
                 then if cond1 == 1 and close < phdext
                      then 1
                      else 0
                else 0;


def pld        = if thisday==0 then double.nan
                 else if thisday == 1 and secondsFromTime(0930) == 0
                 then low
                 else Min(low, pld[1]);
def pldext     = if IsNaN(pld) then pldext[1] else pld;
def pl         =  pldext;
def  cond1a    = if thisday == 0 and
                 open < pldext
                 then 1 else 0;
def cond2a     = if thisday == 0
                 then if cond1a == 1 and close > pldext
                     then 1
                     else 0
                else 0;
plot scan     = (cond1a == 1 and cond2a == 1) or (cond1 == 1 and cond2 == 1);
 

sanjeev_mail

New member
How to add this indicator to my watchlist . If there is a breakout or breakdown i need to get an alert.

Previous Day High and Low Breakout Indicator​

 

MerryDay

Administrative
Staff member
Staff
VIP
plot scan = close crosses above previousHigh;
The scan needs to be run in the first 5min of the open bell as it states: the current price crosses above the previous High, right at this moment.


You could try replacing the last statement in Post#7 with:
plot scan = open is greater than previousHigh;
This returns all stocks that OPENED above the previous day high.
It will not display PLTR in the results because PLTR open was not above. It crossed above in the first 5min.
Screenshot (85).png

@kevinasore
 
Last edited:

Similar threads

Top