painting candlesticks on gap candles

Mr. Puts and Calls

New member
Plus
I use red and green candlesticks and would like a script that would allow me to take a candlestick that gaps up on the open but closes lower for the timeframe that you are using (and show the body hollow but the candlestick outlined in green. I would like the reverse situation, where the candle gapped down but closed higher than the open to have a hollow body but a red outline. I am mimicking Jack Steiman's charts (Jack was an old timer from the trading floor that I respect a great deal)! Thanks for any help that you might provide.
 
I use red and green candlesticks and would like a script that would allow me to take a candlestick that gaps up on the open but closes lower for the timeframe that you are using (and show the body hollow but the candlestick outlined in green. I would like the reverse situation, where the candle gapped down but closed higher than the open to have a hollow body but a red outline. I am mimicking Jack Steiman's charts (Jack was an old timer from the trading floor that I respect a great deal)! Thanks for any help that you might provide.

This will base gapup or gapdn candles at 0930 that meet the input gappct and body painting conditions.
Make sure that the you choose the background color of your chart to hollow out the gapup/gapdn candles.

Screenshot 2023-07-31 084939.jpg
Code:
#Painting_candlesticks_on_gap_candles
input gappct = .01;

def o  = open;
def h  = high;
def l  = low;
def c  = close;
def op = open(period = AggregationPeriod.DAY);
def cl = close(period = AggregationPeriod.DAY);

#GapUp and GapDn defined
def gapup = if SecondsFromTime(0930) == 0 and (op - cl[1]) > cl[1] * gappct and close < open then 1 else 0;
def gapdn = if SecondsFromTime(0930) == 0 and AbsValue((op - cl[1])) > cl[1] * gappct
#(cl[1] - op) > op * gappct
and close > open then 1 else 0;

#Color Gapup or GapDn Candle the color of the chart background to hide it
DefineGlobalColor("Chart Background", Color.BLACK);
AssignPriceColor(if gapup or gapdn then GlobalColor("Chart Background") else Color.CURRENT);

#Highlight the border of the GapUp or GapDn candle Green/Red and hollow then body of these candles

input borderhighlight = yes;
input charttype = ChartType.CANDLE;

def cond = if borderhighlight and gapup then 1 else 0;

def o1 = if cond
         then if o < c then c else o
         else Double.NaN;
def c1 = if cond
         then if o < c then o else c
         else Double.NaN;
def h1 = if cond
         then h
         else Double.NaN;
def l1 = if cond
         then l
         else Double.NaN;

AddChart(growColor = Color.GREEN, fallColor = Color.BLUE, neutralColor = Color.BLUE, high = h1, low = l1, open = c1, close = o1, type = charttype);

def cond1 = if borderhighlight and gapdn then 1 else 0;

def o2 = if cond1
         then if o < c then c else o
         else Double.NaN;
def c2 = if cond1
         then if o < c then o else c
         else Double.NaN;
def h2 = if cond1
         then h
         else Double.NaN;
def l2 = if cond1
         then l
         else Double.NaN;

AddChart(growColor = Color.RED, fallColor = Color.RED, neutralColor = Color.RED, high = h2, low = l2, open = c2, close = o2, type = charttype);

#Test
input test = yes;

AddChartBubble(
test and SecondsFromTime(0930) == 0 and AbsValue(cl[1] - op) > 0,
high,
(if gapup then "GapUp: " else if gapdn then "GapDn: " else "Gap: ") +  AbsValue(cl[1] - op) +
"\nPct " +
(AbsValue(cl[1] - op) / cl[1]) +
"\nBar:" +
(if c > o then "Grn" else "Red"),
if gapup then Color.GREEN else if gapdn then Color.RED else Color.GRAY);
 

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

This will base gapup or gapdn candles at 0930 that meet the input gappct and body painting conditions.
Make sure that the you choose the background color of your chart to hollow out the gapup/gapdn candles.
How would I put this code to print the gap candle according to the chart aggregation period I'm using and not just the open?
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
428 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