breakout Pre_Market high low

shih90

Member
VIP
Is anyone know the LABEL showing that when bell open morning stock runs up down and break either side premarket high/low ?
Thank you for your research and help!!!
 
Solution
Hi. Is it possible to do for premarket? and is it possible to place this script in the watchlist after the selection of stocks in the premarket, so that the stock that has broken through the premarket price would be highlighted? I ask for help!

will look into watch list...


i'm sorry for responding so late, i'm sometimes terrible at replying.
i see you 2 probably aren't around, but will still reply.

@shih90
here is an updated version

@DMacTrades
there is nothing to fix. i took the original request to be any time that isn't normal trading hours, hours before normal trading hours AND hours after them.
after hours, pre market,... these terms could be interpretted differently or as the same period, unless specific...
your words are too vague.

what do these this mean?
1. bell open morning stock ? all stocks open in the morning
2. runs up down ? how far up? how far down? based on what ? is this even important ?

--------------------------

here is a study that,
. finds the highest and lowest levels during pre market,
. draws lines at those levels during normal hours
. draws an arrow if price crosses above the high line or below the low line


Code:
#pre_hilow_breakout_00

#https://usethinkscript.com/threads/question-about-breakout-pre_market-high-low.14488/
#UnAnswered Question about breakout Pre_Market high low
#shih90   Feb 14, 2023

#Is anyone know the LABEL showing that when bell open morning stock runs up down and break either side premarket high/low ?


def na = double.nan;
def bn = barnumber();

# true during normal hours
def rth = (GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() < RegularTradingEnd(GetYYYYMMDD()) );

#def isup = close > open;
#def isdwn = close < open;

def prehi;
def prelo;
if bn == 1 then {
 prehi = 0;
 prelo = 0;
} else if !rth and rth[1] then {
# first bar of ah
 prehi = high;
 prelo = low;
} else if !rth then {
 prehi = if high > prehi[1] then high else prehi[1];
 prelo = if low < prelo[1] then low else prelo[1];
} else {
 prehi = prehi[1];
 prelo = prelo[1];
}


input show_lines_on_AH = no;
def ahlines = if (show_lines_on_AH and !rth) then 1 else 0;

plot zhi = if prehi < 1 then na
 else if rth then prehi
 else if ahlines then prehi
 else na;
zhi.SetDefaultColor(Color.light_gray);
zhi.hidebubble();

plot zlo = if prelo < 1 then na
 else if rth then prelo
 else if ahlines then prelo
 else na;
zlo.SetDefaultColor(Color.light_gray);
zlo.hidebubble();


plot zup = if rth and close crosses above prehi then low*0.998 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if rth and close crosses below prelo then high*1.002 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.cyan);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-------------------------
# test stuff

addchartbubble(0, low,
rth + "\n" +
!rth + "\n" +
prehi + "\n" +
prelo
, color.yellow, no);

#

o7JlG9a.jpg

This indicator is showing premarket high/low only for spy. Its not showing for any other stocks. Can you please check it?
 
Is anyone know the LABEL showing that when bell open morning stock runs up down and break either side premarket high/low ?
Thank you for your research and help!!!


your words are too vague.

what do these this mean?
1. bell open morning stock ? all stocks open in the morning
2. runs up down ? how far up? how far down? based on what ? is this even important ?

--------------------------

here is a study that,
. finds the highest and lowest levels during pre market,
. draws lines at those levels during normal hours
. draws an arrow if price crosses above the high line or below the low line


Code:
#pre_hilow_breakout_00

#https://usethinkscript.com/threads/question-about-breakout-pre_market-high-low.14488/
#UnAnswered Question about breakout Pre_Market high low
#shih90   Feb 14, 2023

#Is anyone know the LABEL showing that when bell open morning stock runs up down and break either side premarket high/low ?


def na = double.nan;
def bn = barnumber();

# true during normal hours
def rth = (GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() < RegularTradingEnd(GetYYYYMMDD()) );

#def isup = close > open;
#def isdwn = close < open;

def prehi;
def prelo;
if bn == 1 then {
 prehi = 0;
 prelo = 0;
} else if !rth and rth[1] then {
# first bar of ah
 prehi = high;
 prelo = low;
} else if !rth then {
 prehi = if high > prehi[1] then high else prehi[1];
 prelo = if low < prelo[1] then low else prelo[1];
} else {
 prehi = prehi[1];
 prelo = prelo[1];
}


input show_lines_on_AH = no;
def ahlines = if (show_lines_on_AH and !rth) then 1 else 0;

plot zhi = if prehi < 1 then na 
 else if rth then prehi
 else if ahlines then prehi
 else na;
zhi.SetDefaultColor(Color.light_gray);
zhi.hidebubble();

plot zlo = if prelo < 1 then na
 else if rth then prelo
 else if ahlines then prelo
 else na;
zlo.SetDefaultColor(Color.light_gray);
zlo.hidebubble();


plot zup = if rth and close crosses above prehi then low*0.998 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if rth and close crosses below prelo then high*1.002 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.cyan);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-------------------------
# test stuff

addchartbubble(0, low,
rth + "\n" +
!rth + "\n" +
prehi + "\n" +
prelo
, color.yellow, no);

#

o7JlG9a.jpg
 
your words are too vague.

what do these this mean?
1. bell open morning stock ? all stocks open in the morning
2. runs up down ? how far up? how far down? based on what ? is this even important ?

--------------------------

here is a study that,
. finds the highest and lowest levels during pre market,
. draws lines at those levels during normal hours
. draws an arrow if price crosses above the high line or below the low line


Code:
#pre_hilow_breakout_00

#https://usethinkscript.com/threads/question-about-breakout-pre_market-high-low.14488/
#UnAnswered Question about breakout Pre_Market high low
#shih90   Feb 14, 2023

#Is anyone know the LABEL showing that when bell open morning stock runs up down and break either side premarket high/low ?


def na = double.nan;
def bn = barnumber();

# true during normal hours
def rth = (GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() < RegularTradingEnd(GetYYYYMMDD()) );

#def isup = close > open;
#def isdwn = close < open;

def prehi;
def prelo;
if bn == 1 then {
 prehi = 0;
 prelo = 0;
} else if !rth and rth[1] then {
# first bar of ah
 prehi = high;
 prelo = low;
} else if !rth then {
 prehi = if high > prehi[1] then high else prehi[1];
 prelo = if low < prelo[1] then low else prelo[1];
} else {
 prehi = prehi[1];
 prelo = prelo[1];
}


input show_lines_on_AH = no;
def ahlines = if (show_lines_on_AH and !rth) then 1 else 0;

plot zhi = if prehi < 1 then na
 else if rth then prehi
 else if ahlines then prehi
 else na;
zhi.SetDefaultColor(Color.light_gray);
zhi.hidebubble();

plot zlo = if prelo < 1 then na
 else if rth then prelo
 else if ahlines then prelo
 else na;
zlo.SetDefaultColor(Color.light_gray);
zlo.hidebubble();


plot zup = if rth and close crosses above prehi then low*0.998 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if rth and close crosses below prelo then high*1.002 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.cyan);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-------------------------
# test stuff

addchartbubble(0, low,
rth + "\n" +
!rth + "\n" +
prehi + "\n" +
prelo
, color.yellow, no);

#

o7JlG9a.jpg
This PreMkt Hi/Low saves me about 20 minutes of charting my watchlist each morning. Thank you, Thank you, Thank you! cmf
 
your words are too vague.

what do these this mean?
1. bell open morning stock ? all stocks open in the morning
2. runs up down ? how far up? how far down? based on what ? is this even important ?

Hi @halcyonguy. In looking at charts using your script I note that the pre-market plots are pulling data from the after-hours session of the day before, rather than from the pre-market session starting at 0400 hrs of the current day.

An example would be ticker TSLA from today (April 11, 2023). The PM low being plotted ($184.06) is the low from yesterday's after-hours session rather than the low from today's PM session ($184.50).

I am not a coder so don't have a suggested fix, but thought I would share this as an FYI. Keep well.
 
Last edited by a moderator:
Hi @halcyonguy. In looking at charts using your script I note that the pre-market plots are pulling data from the after-hours session of the day before, rather than from the pre-market session starting at 0400 hrs of the current day.

An example would be ticker TSLA from today (April 11, 2023). The PM low being plotted ($184.06) is the low from yesterday's after-hours session rather than the low from today's PM session ($184.50).

I am not a coder so don't have a suggested fix, but thought I would share this as an FYI. Keep well.

This PreMkt Hi/Low saves me about 20 minutes of charting my watchlist each morning. Thank you, Thank you, Thank you! cmf
@halcyonguy
After using the Premarket High Low indicator, I realized that the indicator is pulling the data from whichever level meets the high or low criteria during either afterhours or premarket price action.
For Pre Market High example $AMZN: the premarket high of 4/14 shows a high of 107.94, which is the high of the candlewick from the 4/13 afterhours price action.
For Pre Market Low example, $NVDA: the premarket low of 4/17 shows a low of 212.29, which is the low of the candle wick from the 4/16 afterhours price action.
I hope this helps in determining how the code discriminates between afterhours and premarket, for example these two lines of code from the DailyOpen TOS script, to only show data from the opening bell candle:

input aggregationPeriod = AggregationPeriod.DAY;
input showOnlyLastPeriod = yes;

This may not help, but it's part of my researching other TOS indicator code to see if I can find code to isolate premarket from afterhours times.
Thank you, cmf
 
your words are too vague.

what do these this mean?
1. bell open morning stock ? all stocks open in the morning
2. runs up down ? how far up? how far down? based on what ? is this even important ?

--------------------------

here is a study that,
. finds the highest and lowest levels during pre market,
. draws lines at those levels during normal hours
. draws an arrow if price crosses above the high line or below the low line


Code:
#pre_hilow_breakout_00

#https://usethinkscript.com/threads/question-about-breakout-pre_market-high-low.14488/
#UnAnswered Question about breakout Pre_Market high low
#shih90   Feb 14, 2023

#Is anyone know the LABEL showing that when bell open morning stock runs up down and break either side premarket high/low ?


def na = double.nan;
def bn = barnumber();

# true during normal hours
def rth = (GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() < RegularTradingEnd(GetYYYYMMDD()) );

#def isup = close > open;
#def isdwn = close < open;

def prehi;
def prelo;
if bn == 1 then {
 prehi = 0;
 prelo = 0;
} else if !rth and rth[1] then {
# first bar of ah
 prehi = high;
 prelo = low;
} else if !rth then {
 prehi = if high > prehi[1] then high else prehi[1];
 prelo = if low < prelo[1] then low else prelo[1];
} else {
 prehi = prehi[1];
 prelo = prelo[1];
}


input show_lines_on_AH = no;
def ahlines = if (show_lines_on_AH and !rth) then 1 else 0;

plot zhi = if prehi < 1 then na
 else if rth then prehi
 else if ahlines then prehi
 else na;
zhi.SetDefaultColor(Color.light_gray);
zhi.hidebubble();

plot zlo = if prelo < 1 then na
 else if rth then prelo
 else if ahlines then prelo
 else na;
zlo.SetDefaultColor(Color.light_gray);
zlo.hidebubble();


plot zup = if rth and close crosses above prehi then low*0.998 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if rth and close crosses below prelo then high*1.002 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.cyan);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-------------------------
# test stuff

addchartbubble(0, low,
rth + "\n" +
!rth + "\n" +
prehi + "\n" +
prelo
, color.yellow, no);

#

o7JlG9a.jpg
Hi. Is it possible to do for premarket? and is it possible to place this script in the watchlist after the selection of stocks in the premarket, so that the stock that has broken through the premarket price would be highlighted? I ask for help!
 
Hi. Is it possible to do for premarket? and is it possible to place this script in the watchlist after the selection of stocks in the premarket, so that the stock that has broken through the premarket price would be highlighted? I ask for help!

will look into watch list...


i'm sorry for responding so late, i'm sometimes terrible at replying.
i see you 2 probably aren't around, but will still reply.

@shih90
here is an updated version

@DMacTrades
there is nothing to fix. i took the original request to be any time that isn't normal trading hours, hours before normal trading hours AND hours after them.
after hours, pre market,... these terms could be interpretted differently or as the same period, unless specific times are mentioned.

@LivingWithInterest
..read data from pre market and after hours,.. yes. i lumped them together in my previous version.
you wrote a lot of words, without defining WHAT time period defines what you want. although providing examples are usually good, i'm not going to type in symbols , and go look up data from some date, and try to interpret what you want.
just say , read data from 4am to 9:30. (or whatever the correct EST times are)

@EnotTrader
thanks for replying and bringing this post back to my attention.
premarket , again , be specific.


i'm not trying to sound like a dick.
i want people to think about their questions, and be as specific as they can, to provide pertinent information, in order to better communicate their request.

-----------------------------

this version allows the user to pick the 'after hours' time period to read highs and lows from.
...from normal day close to normal day open - default time
...from midnight to day open - pre
...from day close to midnight - post

the default pre and post times are from and to midnight. if 4am and 8pm are desired, then those times could be typed in the code, for these 2 variables.
def daystart = 0;
def dayend = 2359;


Code:
#pre_hilow_breakout_01

# choose pre/post/both after hours

#https://usethinkscript.com/threads/question-about-breakout-pre_market-high-low.14488/
#UnAnswered Question about breakout Pre_Market high low


def na = double.nan;
def bn = barnumber();
#def diffday = if getday() != getday()[1] then 1 else 0;
def rth = (GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() < RegularTradingEnd(GetYYYYMMDD()) );

def rthstart = 0930;
def rthend = 1600;
def daystart = 0;
def dayend = 2359;
def pre1 = if secondsfromTime(daystart) >= 0 and secondstillTime(rthstart) > 0 then 1 else 0;
def post1 = if secondsfromTime(rthend) >= 0 and secondstillTime(dayend) > 0 then 1 else 0;

input after_hours = { pre_hours , post_hours , default both };

def prehi;
def prelo;
def x;
switch (after_hours) {
case pre_hours:
 prehi = if !pre1[1] and pre1 then high
  else if pre1 and high > prehi[1] then high
  else prehi[1];
 prelo = if !pre1[1] and pre1 then low
  else if pre1 and low < prelo[1] then low
  else prelo[1];
 x = if pre1 then 1 else 0;
case post_hours:
 prehi = if !post1[1] and post1 then high
  else if post1 and high > prehi[1] then high
  else prehi[1];
 prelo = if !post1[1] and post1 then low
  else if post1 and low < prelo[1] then low
  else prelo[1];
 x = if post1 then 1 else 0;
case both:
 prehi = if !rth and rth[1] then high
  else if !rth and high > prehi[1] then high
  else prehi[1];
 prelo = if !rth and rth[1] then low
  else if !rth and low < prelo[1] then low
  else prelo[1];
 x = if !rth then 1 else 0;
}

input show_lines_on_AH = no;
def ahlines = if (show_lines_on_AH and !rth) then 1 else 0;

plot zhi = if prehi < 1 then na
 else if rth then prehi
 else if ahlines then prehi
 else na;
zhi.SetDefaultColor(Color.light_gray);
zhi.hidebubble();

plot zlo = if prelo < 1 then na
 else if rth then prelo
 else if ahlines then prelo
 else na;
zlo.SetDefaultColor(Color.light_gray);
zlo.hidebubble();


plot zup = if rth and close crosses above prehi then low*0.998 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if rth and close crosses below prelo then high*1.002 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.cyan);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-------------------------
# test stuff

input test1 = no;
addchartbubble(test1, low*0.998,
rth + "\n" +
!rth + "\n" +
prehi + "\n" +
prelo
, (if x then color.yellow else color.gray), no);
#
 
Solution
will look into watch list...


i'm sorry for responding so late, i'm sometimes terrible at replying.
i see you 2 probably aren't around, but will still reply.

@shih90
here is an updated version

@DMacTrades
there is nothing to fix. i took the original request to be any time that isn't normal trading hours, hours before normal trading hours AND hours after them.
after hours, pre market,... these terms could be interpretted differently or as the same period, unless specific times are mentioned.

@LivingWithInterest
..read data from pre market and after hours,.. yes. i lumped them together in my previous version.
you wrote a lot of words, without defining WHAT time period defines what you want. although providing examples are usually good, i'm not going to type in symbols , and go look up data from some date, and try to interpret what you want.
just say , read data from 4am to 9:30. (or whatever the correct EST times are)

@EnotTrader
thanks for replying and bringing this post back to my attention.
premarket , again , be specific.


i'm not trying to sound like a dick.
i want people to think about their questions, and be as specific as they can, to provide pertinent information, in order to better communicate their request.

-----------------------------

this version allows the user to pick the 'after hours' time period to read highs and lows from.
...from normal day close to normal day open - default time
...from midnight to day open - pre
...from day close to midnight - post

the default pre and post times are from and to midnight. if 4am and 8pm are desired, then those times could be typed in the code, for these 2 variables.
def daystart = 0;
def dayend = 2359;


Code:
#pre_hilow_breakout_01

# choose pre/post/both after hours

#https://usethinkscript.com/threads/question-about-breakout-pre_market-high-low.14488/
#UnAnswered Question about breakout Pre_Market high low


def na = double.nan;
def bn = barnumber();
#def diffday = if getday() != getday()[1] then 1 else 0;
def rth = (GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() < RegularTradingEnd(GetYYYYMMDD()) );

def rthstart = 0930;
def rthend = 1600;
def daystart = 0;
def dayend = 2359;
def pre1 = if secondsfromTime(daystart) >= 0 and secondstillTime(rthstart) > 0 then 1 else 0;
def post1 = if secondsfromTime(rthend) >= 0 and secondstillTime(dayend) > 0 then 1 else 0;

input after_hours = { pre_hours , post_hours , default both };

def prehi;
def prelo;
def x;
switch (after_hours) {
case pre_hours:
 prehi = if !pre1[1] and pre1 then high
  else if pre1 and high > prehi[1] then high
  else prehi[1];
 prelo = if !pre1[1] and pre1 then low
  else if pre1 and low < prelo[1] then low
  else prelo[1];
 x = if pre1 then 1 else 0;
case post_hours:
 prehi = if !post1[1] and post1 then high
  else if post1 and high > prehi[1] then high
  else prehi[1];
 prelo = if !post1[1] and post1 then low
  else if post1 and low < prelo[1] then low
  else prelo[1];
 x = if post1 then 1 else 0;
case both:
 prehi = if !rth and rth[1] then high
  else if !rth and high > prehi[1] then high
  else prehi[1];
 prelo = if !rth and rth[1] then low
  else if !rth and low < prelo[1] then low
  else prelo[1];
 x = if !rth then 1 else 0;
}

input show_lines_on_AH = no;
def ahlines = if (show_lines_on_AH and !rth) then 1 else 0;

plot zhi = if prehi < 1 then na
 else if rth then prehi
 else if ahlines then prehi
 else na;
zhi.SetDefaultColor(Color.light_gray);
zhi.hidebubble();

plot zlo = if prelo < 1 then na
 else if rth then prelo
 else if ahlines then prelo
 else na;
zlo.SetDefaultColor(Color.light_gray);
zlo.hidebubble();


plot zup = if rth and close crosses above prehi then low*0.998 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if rth and close crosses below prelo then high*1.002 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.cyan);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-------------------------
# test stuff

input test1 = no;
addchartbubble(test1, low*0.998,
rth + "\n" +
!rth + "\n" +
prehi + "\n" +
prelo
, (if x then color.yellow else color.gray), no);
#
Hal, Would you mind turning this into a watchlist that will change colors when Pre low/hi is broken. Also with alert. Thank You 🙏
 
will look into watch list...


i'm sorry for responding so late, i'm sometimes terrible at replying.
i see you 2 probably aren't around, but will still reply.

@shih90
here is an updated version

@DMacTrades
there is nothing to fix. i took the original request to be any time that isn't normal trading hours, hours before normal trading hours AND hours after them.
after hours, pre market,... these terms could be interpretted differently or as the same period, unless specific times are mentioned.

@LivingWithInterest
..read data from pre market and after hours,.. yes. i lumped them together in my previous version.
you wrote a lot of words, without defining WHAT time period defines what you want. although providing examples are usually good, i'm not going to type in symbols , and go look up data from some date, and try to interpret what you want.
just say , read data from 4am to 9:30. (or whatever the correct EST times are)

@EnotTrader
thanks for replying and bringing this post back to my attention.
premarket , again , be specific.


i'm not trying to sound like a dick.
i want people to think about their questions, and be as specific as they can, to provide pertinent information, in order to better communicate their request.

-----------------------------

this version allows the user to pick the 'after hours' time period to read highs and lows from.
...from normal day close to normal day open - default time
...from midnight to day open - pre
...from day close to midnight - post

the default pre and post times are from and to midnight. if 4am and 8pm are desired, then those times could be typed in the code, for these 2 variables.
def daystart = 0;
def dayend = 2359;


Code:
#pre_hilow_breakout_01

# choose pre/post/both after hours

#https://usethinkscript.com/threads/question-about-breakout-pre_market-high-low.14488/
#UnAnswered Question about breakout Pre_Market high low


def na = double.nan;
def bn = barnumber();
#def diffday = if getday() != getday()[1] then 1 else 0;
def rth = (GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() < RegularTradingEnd(GetYYYYMMDD()) );

def rthstart = 0930;
def rthend = 1600;
def daystart = 0;
def dayend = 2359;
def pre1 = if secondsfromTime(daystart) >= 0 and secondstillTime(rthstart) > 0 then 1 else 0;
def post1 = if secondsfromTime(rthend) >= 0 and secondstillTime(dayend) > 0 then 1 else 0;

input after_hours = { pre_hours , post_hours , default both };

def prehi;
def prelo;
def x;
switch (after_hours) {
case pre_hours:
 prehi = if !pre1[1] and pre1 then high
  else if pre1 and high > prehi[1] then high
  else prehi[1];
 prelo = if !pre1[1] and pre1 then low
  else if pre1 and low < prelo[1] then low
  else prelo[1];
 x = if pre1 then 1 else 0;
case post_hours:
 prehi = if !post1[1] and post1 then high
  else if post1 and high > prehi[1] then high
  else prehi[1];
 prelo = if !post1[1] and post1 then low
  else if post1 and low < prelo[1] then low
  else prelo[1];
 x = if post1 then 1 else 0;
case both:
 prehi = if !rth and rth[1] then high
  else if !rth and high > prehi[1] then high
  else prehi[1];
 prelo = if !rth and rth[1] then low
  else if !rth and low < prelo[1] then low
  else prelo[1];
 x = if !rth then 1 else 0;
}

input show_lines_on_AH = no;
def ahlines = if (show_lines_on_AH and !rth) then 1 else 0;

plot zhi = if prehi < 1 then na
 else if rth then prehi
 else if ahlines then prehi
 else na;
zhi.SetDefaultColor(Color.light_gray);
zhi.hidebubble();

plot zlo = if prelo < 1 then na
 else if rth then prelo
 else if ahlines then prelo
 else na;
zlo.SetDefaultColor(Color.light_gray);
zlo.hidebubble();


plot zup = if rth and close crosses above prehi then low*0.998 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if rth and close crosses below prelo then high*1.002 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.cyan);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-------------------------
# test stuff

input test1 = no;
addchartbubble(test1, low*0.998,
rth + "\n" +
!rth + "\n" +
prehi + "\n" +
prelo
, (if x then color.yellow else color.gray), no);
#
how can I turn this code into a scan filter?
 

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
292 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