Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Also noticed these odd little, tiny dots on the O and C lines. Kinda funky.
# Multi-Time-Frame Candle Overlay version 2.3
# 2020 Paul Townsend
# with code from UseThinkScript.com
input agg = AggregationPeriod.fifteen_min;
input OpenCloseLines = yes;
input HighLowLines = yes;
input HighLowGray = no;
input LineWeight =2;
addlabel(yes,"[" + agg/60000 + "]",color.white);
plot o = open(period = agg);
plot c = close(period = agg);
plot h = high(period = agg);
plot l = low(period = agg);
o.sethiding(!OpenCloseLines);
c.sethiding(!OpenCloseLines);
h.sethiding(!HighLowLines);
l.sethiding(!HighLowLines);
o.setLineWeight(lineweight);
c.setLineWeight(lineweight);
h.setLineWeight(lineweight);
l.setLineWeight(lineweight);
o.AssignValueColor(if o==c then color.white else if o > c then Color.red else Color.green);
c.AssignValueColor(if o==c then color.white else if o > c then Color.red else Color.green);
AddCloud(c, o, Color.Green, Color.Red);
h.AssignValueColor(if highlowgray then color.gray else if o==c then color.white else if o > c then Color.red else Color.green);
l.AssignValueColor(if highlowgray then color.gray else if o==c then color.white else if o > c then Color.red else Color.green);
o.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
c.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
So, the question is, how do you get the paint to stay within the boxes?
Hint: you will need to use more than one AddCloud() statement.
Hint: You need to use two AddCloud() functions--one for even MTF periods and one for odd.
I've spent an hour or so on this. Still can't get it to work. How do these two AddCloud() statements differ? I've discovered def variables are not accepted in the color definitions. Though if then else statements are. I'm kind stuck on this one. Maybe... another hint... or some code?
# Bollinger Band Color SD Clouds Squeeze
# Mobius
# 12.15.2015
input length = 20;
input Dev = 2.0;
input Dev2 = 3.0;
def h = high;
def l = low;
def c = close;
def sDev = StDev(close, length);
def ATR = Average(TrueRange(h, c, l), length);
plot MidL = Average(close, length);
plot LowerB = MidL + (-Dev * sDev);
plot UpperB = MidL + (Dev * sDev);
plot LowerB2 = MidL + (-Dev2 * sDev);
plot UpperB2 = MidL + (Dev2 * sDev);
def Squeeze = UpperB < MidL + (1.5 * ATR);
LowerB.SetDefaultColor(Color.Gray);
LowerB.HideBubble();
UpperB.SetDefaultColor(Color.Gray);
UpperB.HideBubble();
LowerB2.SetDefaultColor(Color.Gray);
LowerB2.HideBubble();
UpperB2.SetDefaultColor(Color.Gray);
UpperB2.HideBubble();
MidL.SetDefaultColor(Color.WHITE);
MidL.HideBubble();
addCloud(if squeeze then UpperB else double.nan, UpperB2, color.white, color.white);
addCloud(UpperB, UpperB2, color.gray, color.gray);
addCloud(if squeeze then LowerB else double.nan, LowerB2, color.white, color.white);
addCloud(LowerB, LowerB2, color.gray, color.gray);
# End Study
# Multi-Time-Frame Candle Overlay version 2.4
# 2020 Paul Townsend
# with code from UseThinkScript.com
input agg = AggregationPeriod.fifteen_min;
input OpenCloseLines = yes;
input HighLowLines = yes;
input HighLowGray = no;
input LineWeight =2;
addlabel(yes,"[" + agg/60000 + "]",color.white);
plot o = open(period = agg);
plot c = close(period = agg);
plot h = high(period = agg);
plot l = low(period = agg);
o.sethiding(!OpenCloseLines);
c.sethiding(!OpenCloseLines);
h.sethiding(!HighLowLines);
l.sethiding(!HighLowLines);
o.setLineWeight(lineweight);
c.setLineWeight(lineweight);
h.setLineWeight(lineweight);
l.setLineWeight(lineweight);
o.AssignValueColor(if o==c then color.white else if o > c then Color.red else Color.green);
c.AssignValueColor(if o==c then color.white else if o > c then Color.red else Color.green);
h.AssignValueColor(if highlowgray then color.gray else if o==c then color.white else if o > c then Color.red else Color.green);
l.AssignValueColor(if highlowgray then color.gray else if o==c then color.white else if o > c then Color.red else Color.green);
def side = if side[1] == 1 then 2 else 1; plot sider = side; sider.hide();
AddCloud( if sider==2 then c else double.nan, o, Color.green, Color.red);
AddCloud( if sider==1 then c else double.nan, o, Color.green, Color.red);
o.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
c.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
# end
# Multi-Time-Frame Candle Overlay version 2.4
# 2020 Paul Townsend
# with code from UseThinkScript.com
# 01.25.2020 - BLT - Modified Addcloud to match horizontal lines
input agg = AggregationPeriod.fifteen_min;
input OpenCloseLines = yes;
input HighLowLines = yes;
input HighLowGray = no;
input LineWeight =2;
addlabel(yes,"[" + agg/60000 + "]",color.white);
plot o = open(period = agg);
plot c = close(period = agg);
plot h = high(period = agg);
plot l = low(period = agg);
o.sethiding(!OpenCloseLines);
c.sethiding(!OpenCloseLines);
h.sethiding(!HighLowLines);
l.sethiding(!HighLowLines);
o.setLineWeight(lineweight);
c.setLineWeight(lineweight);
h.setLineWeight(lineweight);
l.setLineWeight(lineweight);
o.AssignValueColor(if o==c then color.white else if o > c then Color.red else Color.green);
c.AssignValueColor(if o==c then color.white else if o > c then Color.red else Color.green);
h.AssignValueColor(if highlowgray then color.gray else if o==c then color.white else if o > c then Color.red else Color.green);
l.AssignValueColor(if highlowgray then color.gray else if o==c then color.white else if o > c then Color.red else Color.green);
input addcloud =yes;
def side = if side[1] == 1 then 2 else 1; plot sider = side; sider.hide();
AddCloud( if sider==2 then c else double.nan, o, Color.green, Color.red);
AddCloud( if sider==1 then c else double.nan, o, color.green, Color.red);
o.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
c.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
# end
#[email protected]
def NA = Double.NaN;
input Aggregation1 = AggregationPeriod.HOUR;
input Aggregation2 = AggregationPeriod.DAY;
plot HighBand1 = high("Period" = Aggregation1);
plot LowBand1 = low("Period" = Aggregation1);
plot OpenBand1 = open("Period" = Aggregation1);
plot CloseBand1 = close("Period" = Aggregation1);
HighBand1.Hide();
LowBand1.Hide();
OpenBand1.Hide();
CloseBand1.Hide();
plot HighBand2 = high("Period" = Aggregation2);
plot LowBand2 = low("Period" = Aggregation2);
plot OpenBand2 = open("Period" = Aggregation2);
plot CloseBand2 = close("Period" = Aggregation2);
#Aggregation2
AddCloud(if OpenBand2 > CloseBand2 then OpenBand2 else NA, if OpenBand2 > CloseBand2 then CloseBand2 else NA, Color.DARK_RED, Color.DARK_RED);
AddCloud(if OpenBand2 > CloseBand2 then NA else CloseBand2, if OpenBand2 > CloseBand2 then NA else OpenBand2, Color.DARK_GREEN, Color.DARK_GREEN);
AddCloud(if OpenBand2 > CloseBand2 then OpenBand2 else NA, if OpenBand2 > CloseBand2 then HighBand2 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(if OpenBand2 > CloseBand2 then CloseBand2 else NA, if OpenBand2 > CloseBand2 then LowBand2 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(if CloseBand2 > OpenBand2 then CloseBand2 else NA, if CloseBand2 > OpenBand2 then HighBand2 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(if CloseBand2 > OpenBand2 then OpenBand2 else NA, if CloseBand2 > OpenBand2 then LowBand2 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
#Aggregation1
AddCloud(if OpenBand1 > CloseBand1 then OpenBand1 else NA, if OpenBand1 > CloseBand1 then CloseBand1 else NA, Color.RED, Color.RED);
AddCloud(if OpenBand1 > CloseBand1 then NA else CloseBand1, if OpenBand1 > CloseBand1 then NA else OpenBand1, Color.GREEN, Color.GREEN);
AddCloud(if OpenBand1 > CloseBand1 then OpenBand1 else NA, if OpenBand1 > CloseBand1 then HighBand1 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(if OpenBand1 > CloseBand1 then CloseBand1 else NA, if OpenBand1 > CloseBand1 then LowBand1 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(if CloseBand1 > OpenBand1 then CloseBand1 else NA, if CloseBand1 > OpenBand1 then HighBand1 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(if CloseBand1 > OpenBand1 then OpenBand1 else NA, if CloseBand1 > OpenBand1 then LowBand1 else NA, Color.DARK_GRAY, Color.DARK_GRAY);
#Hour
HighBand1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
HighBand1.SetDefaultColor(Color.DARK_GRAY);
LowBand1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowBand1.SetDefaultColor(Color.DARK_GRAY);
OpenBand1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
OpenBand1.SetDefaultColor(Color.GREEN);
CloseBand1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
CloseBand1.SetDefaultColor(Color.RED);
#Day
HighBand2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
HighBand2.SetDefaultColor(Color.DARK_GRAY);
LowBand2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowBand2.SetDefaultColor(Color.DARK_GRAY);
OpenBand2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
OpenBand2.SetDefaultColor(Color.GREEN);
CloseBand2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
CloseBand2.SetDefaultColor(Color.RED);
input aggPeriod = AggregationPeriod.FIFTEEN_MIN;
def o = open(period =aggPeriod);
def h = high(period =aggPeriod);
def l = low(period =aggPeriod);
def c = close(period =aggPeriod);
# Number of bars within the lower timeframe
def lowerTimeFrameBarCount = aggPeriod / GetAggregationPeriod();
def bn = BarNumber();
# Determine the position of each bar using the remainder with value of 0 = lowerTimeFrameBarCount
def remainder = bn % lowerTimeFrameBarCount;
def bar = if remainder == 0 then lowerTimeFrameBarCount else remainder;
#Find the middle bar in the lower timeframe - odd numbers add 0.5 to plot the wicks on the higher time frame
def midBar = if lowerTimeFrameBarCount % 2 == 0 then lowerTimeFrameBarCount/2 else lowerTimeFrameBarCount/2 + 0.5;
### making stuff up here drawing the wick through the middle candle.
def nan = double.nan;
def hb = if bar == midBar then h else nan;
def lb = if bar == midBar then l else nan;
AddChart(growcolor = color.white, high = hb, low = lb, open = nan, close = nan, type = ChartType.bar);
hey Townsend... could you make it highlight a number of candles to show a 6,9,12 etc... like a moving avg and it would be red or green or white...
Yeah... I've got another indicator very similar to what you're asking about. I'll post it in a new thread this weekend.
Start a new thread and receive assistance from our community.
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.
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.