Multi-TimeFrame Candles Overlay for ThinkOrSwim

Can I have this same setup but painting Heikin Ashi Candles Colors, The other Heikin Ashi Scripts I found have wicks and I only want the box of high and bottom like this one but showing the color of the heikin ashi candle on that time frame.

Added Cloud Coloring Choice at the Input Screen with this snippet basis:
Code:
#### Cloud Coloring
def cloud_o;
def cloud_c;
def Heiken_close = (o + h + l + c) / 4;
def Heiken_open  = CompoundValue(1, (Heiken_open[1] + Heiken_close[1]) / 2, (o[1] + c[1]) / 2);

input cloud_color = {default candle, heiken_ashi};
switch (cloud_color) {
case candle:
    cloud_o = o;
    cloud_c = c;
case heiken_ashi:
    cloud_o = Heiken_open;
    cloud_c = Heiken_close;
}

Here is the full revised code with the snippet and other necessary changes referencing the choice made.
The image shows a 1d1m chart with a 15m chart overlay with Heiken Ashi coloring.
Screenshot 2024-01-23 055542.png
Code:
#CandleOverlay_MTF_Using_VolumeProfile
#Added Cloud Coloring Choice between Candle/Heiken_Ashi

input ShowTodayOnly = { default "No", "Yes"};
input showbubbles   = yes;
input aggperiod     = {"1 MIN", "2 MIN", "3 MIN", "5 MIN", "10 MIN", "15 MIN", "30 MIN", "1 HOUR", default "DAY", "WEEK", "MONTH", "QUARTER", "YEAR"};
input displace      = 0;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def qtr = (GetMonth() - 1 ) % 3;
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);

switch (aggperiod) {
case "1 MIN":
    period = Floor(seconds / 60 + day_number * 24 * 60);
case "2 MIN":
    period = Floor(seconds / 120 + day_number * 24);
case "3 MIN":
    period = Floor(seconds / 180 + day_number * 24);
case "5 MIN":
    period = Floor(seconds / 300 + day_number * 24);
case "10 MIN":
    period = Floor(seconds / 600 + day_number * 24);
case "15 MIN":
    period = Floor(seconds / 900 + day_number * 24);
case "30 MIN":
    period = Floor(seconds / 1800 + day_number * 24);
case "1 HOUR":
    period = Floor(seconds / 3600 + day_number * 24);
case "DAY":
    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case "WEEK":
    period = Floor(day_number / 7);
case "MONTH":
    period = Floor(month - First(month));
case QUARTER:
    period = qtr == 0 and qtr[1] != 0;
case "YEAR":
    period = GetYear();
}
def bn = BarNumber();
def na = Double.NaN;
def o  = open(period = aggperiod)[displace];
def c  = close(period = aggperiod)[displace];
def h  = high(period = aggperiod)[displace];
def l  = low(period = aggperiod)[displace];
def r  = if period != period[1] then 0 else 1;
def b  = if period != period[1] then bn else b[1];
def xb = b;

#### Cloud Coloring
def cloud_o;
def cloud_c;
def Heiken_close = (o + h + l + c) / 4;
def Heiken_open  = CompoundValue(1, (Heiken_open[1] + Heiken_close[1]) / 2, (o[1] + c[1]) / 2);

input cloud_color = {default candle, heiken_ashi};
switch (cloud_color) {
case candle:
    cloud_o = o;
    cloud_c = c;
case heiken_ashi:
    cloud_o = Heiken_open;
    cloud_c = Heiken_close;
}

plot ORH = if ShowTodayOnly and !IsNaN(close(period = aggperiod)[-1]) then Double.NaN else high(period = aggperiod)[displace];
plot ORL = if ShowTodayOnly and !IsNaN(close(period = aggperiod)[-1]) then Double.NaN else  low(period = aggperiod)[displace];

ORH.AssignValueColor(if cloud_c > cloud_o then Color.GREEN else if cloud_c < cloud_o then Color.RED else Color.WHITE);
ORH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ORH.SetLineWeight(2);

ORL.AssignValueColor(if cloud_c > cloud_o then Color.GREEN else if cloud_c < cloud_o then Color.RED else Color.WHITE);
ORL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ORL.SetLineWeight(2);


input showcloud = yes;
AddCloud( if showcloud and r and cloud_c > cloud_o then ORH else Double.NaN, if r then ORL else Double.NaN,  Color.GREEN, Color.GREEN);
AddCloud( if showcloud and r and cloud_c < cloud_o then ORH else Double.NaN, if r then ORL else Double.NaN,  Color.RED, Color.RED);
AddCloud( if showcloud and r and cloud_c == cloud_o then ORH else Double.NaN, if r then ORL else Double.NaN,  Color.WHITE, Color.WHITE);

AddCloud( if showcloud and Between(bn, xb - 1, xb + 1) and cloud_c > cloud_o then ORH else Double.NaN, if Between(bn, xb - 1, xb + 1) then ORL else Double.NaN,  Color.GREEN, Color.GREEN);
AddCloud( if showcloud and Between(bn, xb - 1, xb + 1) and cloud_c < cloud_o then ORH else Double.NaN, if Between(bn, xb - 1, xb + 1) then ORL else Double.NaN,  Color.RED, Color.RED);
AddCloud( if showcloud and Between(bn, xb - 1, xb + 1) and cloud_c == cloud_o then ORH else Double.NaN, if Between(bn, xb - 1, xb + 1) then ORL else Double.NaN,  Color.WHITE, Color.WHITE);

#
 

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

How can we make it so we can change the opacity on this script?

Use Defineglobalcolor to change opacity of clouds.

defineglobalColor ("Up", color.lime);
defineglobalColor ("Dn", color.red);
defineglobalColor ("Flat", color.white);

input showcloud = yes;

AddCloud( if showcloud and r and c > o then ORH else Double.NaN, if r then ORL else Double.NaN, globalColor ("Up"), globalColor ("Up"));
AddCloud( if showcloud and r and c < o then ORH else Double.NaN, if r then ORL else Double.NaN, globalColor ("Dn"), globalColor ("Dn"));
AddCloud( if showcloud and r and c == o then ORH else Double.NaN, if r then ORL else Double.NaN, globalColor ("Flat"), globalColor ("Flat"));
 

Attachments

  • Candles Overlay4.jpg
    Candles Overlay4.jpg
    95.7 KB · Views: 55
  • Candles Overlay3.jpg
    Candles Overlay3.jpg
    240.5 KB · Views: 54
  • Candles Overlay2.jpg
    Candles Overlay2.jpg
    278.5 KB · Views: 54
This colors the MTF Candle Overlay from High to Low
I couldn’t get this to work. Could you help me in identifying what I am doing wrong as this is the 4-5th created study I’ve had something like this show up .
 

Attachments

  • IMG_2731.jpeg
    IMG_2731.jpeg
    357.1 KB · Views: 33
I couldn’t get this to work. Could you help me in identifying what I am doing wrong as this is the 4-5th created study I’ve had something like this show up .

No, there is nothing wrong with the script.
Perhaps you are having cutting and pasting difficulties?
Be sure to copy ONLY the code and ALL the code.

Here is a chart with the indicator already plotted on it.
By loading this shared chart link, the script will show up at the bottom of your study tab with a 'shared' prefix.
shared chart link: http://tos.mx/rVP3Tgw Click here for --> Easiest way to load shared links
FYI: Schwab will not make shared links fully-functional for everyone until after May 13
F12eslF.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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