Mastering The Trade

AstroBoy

New member
@halcyonguy Hey I was wondering if you can help me with this Watchlist Column indicator I am working on?
Taking a page from John Carter's book Mastering the Trade, this indicator seeks to look back at the previous 21 candles on any time frame to see what is the "Highest of the Low Period (HOLP)" and what is the "Lowest of the High Period (LOHP)"...... If the price closed below HOLP, it signals a sell, and vice-versa if price closes above LOHP it signals a buy...
This indicator works perfectly fine on a chart, however on a watchlist column, it isn't displaying correctly - - I am interested in whether the most recent signal during the trading day was a buy or a sell... But this is only telling me if the current candle is a buy or sell which is not what I want... I hope this makes sense.


Code:
input lookback = 21;

def lowBar = low == Lowest(low, lookback);
def HOLP = if lowBar then high else HOLP[1];
def closedAboveHOLP = if lowBar then 0 else if close > HOLP then closedAboveHOLP[1]+1 else closedAboveHOLP[1];
def buy = closedAboveHOLP == 1 and closedAboveHOLP[1] == 0;

def highBar = high == Highest(high, lookback);
def LOHP = if highBar then low else LOHP[1];
def closedBelowLOHP = if highBar then 0 else if close < LOHP then closedBelowLOHP[1]+1 else closedBelowLOHP[1];
def sell = closedBelowLOHP == 1 and closedBelowLOHP[1] == 0;

plot output = if buy then 1 else if sell then -1 else 0;
output.assignvaluecolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);
assignbackgroundcolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);
 
Last edited by a moderator:
Solution
@halcyonguy Hey I was wondering if you can help me with this Watchlist Column indicator I am working on?
Taking a page from John Carter's book Mastering the Trade, this indicator seeks to look back at the previous 21 candles on any time frame to see what is the "Highest of the Low Period (HOLP)" and what is the "Lowest of the High Period (LOHP)"...... If the price closed below HOLP, it signals a sell, and vice-versa if price closes above LOHP it signals a buy...
This indicator works perfectly fine on a chart, however on a watchlist column, it isn't displaying correctly - - I am interested in whether the most recent signal during the trading day was a buy or a sell... But this is only telling me if the...
@halcyonguy Hey I was wondering if you can help me with this Watchlist Column indicator I am working on?
Taking a page from John Carter's book Mastering the Trade, this indicator seeks to look back at the previous 21 candles on any time frame to see what is the "Highest of the Low Period (HOLP)" and what is the "Lowest of the High Period (LOHP)"...... If the price closed below HOLP, it signals a sell, and vice-versa if price closes above LOHP it signals a buy...
This indicator works perfectly fine on a chart, however on a watchlist column, it isn't displaying correctly - - I am interested in whether the most recent signal during the trading day was a buy or a sell... But this is only telling me if the current candle is a buy or sell which is not what I want... I hope this makes sense.


Code:
input lookback = 21;

def lowBar = low == Lowest(low, lookback);
def HOLP = if lowBar then high else HOLP[1];
def closedAboveHOLP = if lowBar then 0 else if close > HOLP then closedAboveHOLP[1]+1 else closedAboveHOLP[1];
def buy = closedAboveHOLP == 1 and closedAboveHOLP[1] == 0;

def highBar = high == Highest(high, lookback);
def LOHP = if highBar then low else LOHP[1];
def closedBelowLOHP = if highBar then 0 else if close < LOHP then closedBelowLOHP[1]+1 else closedBelowLOHP[1];
def sell = closedBelowLOHP == 1 and closedBelowLOHP[1] == 0;

plot output = if buy then 1 else if sell then -1 else 0;
output.assignvaluecolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);
assignbackgroundcolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);


this is a column study
it shows the number of bars since a signal.
positive numbers for buy , negative numbers for sell.
the cell is colored green or red.

column

link
zholcarter_0a
15min
http://tos.mx/jNrIBiQ

Code:
# zholcarter_0a

# hol_loh_carter_col_0a
# hol_loh_carter_lower_0b

# test, lower
# col from upper

#https://usethinkscript.com/threads/mastering-the-trade.12180/
# I am interested in whether the most recent signal during the trading day was a buy or a sell

#declare lower;

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

input lookback = 21;

def lowBar = low == Lowest(low, lookback);
def HOLP = if lowBar then high else HOLP[1];
def closedAboveHOLP = if lowBar then 0 else if close > HOLP then closedAboveHOLP[1]+1 else closedAboveHOLP[1];
def buy = closedAboveHOLP == 1 and closedAboveHOLP[1] == 0;

def highBar = high == Highest(high, lookback);
def LOHP = if highBar then low else LOHP[1];
def closedBelowLOHP = if highBar then 0 else if close < LOHP then closedBelowLOHP[1]+1 else closedBelowLOHP[1];
def sell = closedBelowLOHP == 1 and closedBelowLOHP[1] == 0;

def output = if buy then 1 else if sell then -1 else 0;
#output.assignvaluecolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);

#assignbackgroundcolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);


def out2 =
     if bn == 1 then 0
else if buy then 1
else if sell then -1
else if out2[1] > 0 then out2[1] + 1
else if out2[1] < 0 then out2[1] - 1
else 0;

#addlabel(1, out2, (if out2 < 0 then color.red else if out2 > 0 then color.green else color.gray));
plot z = out2;
z.setdefaultcolor(color.black);

assignbackgroundcolor((if out2 < 0 then color.red else if out2 > 0 then color.green else color.gray));
#

column, showing how many bars back to a buy or sell
0UTZCd4.jpg



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

test studies

if a column study is desired, i usually make a lower, to verify the signals match those in the upper study.
then i modify a copy of the lower, and make a column.

upper
Code:
# hol_loh_carter_upper

# col from upper

#https://usethinkscript.com/threads/mastering-the-trade.12180/
#Mastering The Trade
# AstroBoy  Start dateToday at 6:08 PM

#@halcyonguy Hey I was wondering if you can help me with this Watchlist Column indicator I am working on?
#Taking a page from John Carter's book Mastering the Trade, this indicator seeks to look back at the previous 21 candles on any time frame to see what is the "Highest of the Low Period (HOLP)" and what is the "Lowest of the High Period (LOHP)"...... If the price closed below HOLP, it signals a sell, and vice-versa if price closes above LOHP it signals a buy...
#This indicator works perfectly fine on a chart, however on a watchlist column, it isn't displaying correctly - - I am interested in whether the most recent signal during the trading day was a buy or a sell... But this is only telling me if the current candle is a buy or sell which is not what I want... I hope this makes sense.

def na = double.nan;
input lookback = 21;

def lowBar = low == Lowest(low, lookback);
def HOLP = if lowBar then high else HOLP[1];
def closedAboveHOLP = if lowBar then 0 else if close > HOLP then closedAboveHOLP[1]+1 else closedAboveHOLP[1];
def buy = closedAboveHOLP == 1 and closedAboveHOLP[1] == 0;

def highBar = high == Highest(high, lookback);
def LOHP = if highBar then low else LOHP[1];
def closedBelowLOHP = if highBar then 0 else if close < LOHP then closedBelowLOHP[1]+1 else closedBelowLOHP[1];
def sell = closedBelowLOHP == 1 and closedBelowLOHP[1] == 0;

#plot output = if buy then 1 else if sell then -1 else 0;
#plot output = if buy then high else if sell then low else MidBodyVal()[6];
#plot output = if buy then high else if sell then low else na;

def fac1 = 0.003;
plot output =
       if buy[-1] then low*(1-fac1)
  else if buy then low[1]*(1-fac1)
  else if sell[-1] then high*(1+fac1)
  else if sell then high[1]*(1+fac1)
  else na;

output.assignvaluecolor(if buy then color.cyan else if sell then color.yellow else color.gray);
#output.assignvaluecolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);
output.setlineweight(3);

#assignbackgroundcolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);
#



lower
Code:
# hol_loh_carter_lower_0b

# test, lower
# col from upper

#https://usethinkscript.com/threads/mastering-the-trade.12180/
#Mastering The Trade
# AstroBoy  Start dateToday at 6:08 PM

#@halcyonguy Hey I was wondering if you can help me with this Watchlist Column indicator I am working on?
#Taking a page from John Carter's book Mastering the Trade, this indicator seeks to look back at the previous 21 candles on any time frame to see what is the "Highest of the Low Period (HOLP)" and what is the "Lowest of the High Period (LOHP)"...... If the price closed below HOLP, it signals a sell, and vice-versa if price closes above LOHP it signals a buy...
#This indicator works perfectly fine on a chart, however on a watchlist column, it isn't displaying correctly - - I am interested in whether the most recent signal during the trading day was a buy or a sell... But this is only telling me if the current candle is a buy or sell which is not what I want... I hope this makes sense.

declare lower;

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

input lookback = 21;

def lowBar = low == Lowest(low, lookback);
def HOLP = if lowBar then high else HOLP[1];
def closedAboveHOLP = if lowBar then 0 else if close > HOLP then closedAboveHOLP[1]+1 else closedAboveHOLP[1];
def buy = closedAboveHOLP == 1 and closedAboveHOLP[1] == 0;

def highBar = high == Highest(high, lookback);
def LOHP = if highBar then low else LOHP[1];
def closedBelowLOHP = if highBar then 0 else if close < LOHP then closedBelowLOHP[1]+1 else closedBelowLOHP[1];
def sell = closedBelowLOHP == 1 and closedBelowLOHP[1] == 0;

plot output = if buy then 1 else if sell then -1 else 0;
output.assignvaluecolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);

#assignbackgroundcolor(if buy then color.dark_green else if sell then color.dark_red else color.yellow);


def out2 =
     if bn == 1 then 0
else if buy then 1
else if sell then -1
else if out2[1] > 0 then out2[1] + 1
else if out2[1] < 0 then out2[1] - 1
else 0;

addlabel(1, out2, (if out2 < 0 then color.red else if out2 > 0 then color.green else color.gray));
#
 
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
420 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