Welkin
Active member
The author of the study isn't available on the forum to provide answers to questions. So this thread has been locked.
Think I might've posted a older version of something similar I'd made in the past, but couldn't find it... figured I'd post this one because it's far less intrusive on a chart, especially when you have other indicators on top of it.
Plots ATR Levels above and below the day's open to a max of 2x ATR in quarter segments.
Code:
#[email protected]
#Plots Upper and Lower ATR ranges onto the current day's open
def NA = Double.NaN;
input atrLength = 14;
input averageType = AverageType.WILDERS;
input showClouds = yes;
input showAtrLabel = yes;
input showAtrStatsLabel = yes;
#ATR
def TR1 = high("period"= AggregationPeriod.DAY) - low("period"= AggregationPeriod.DAY);
def TR2 = AbsValue(high("period"= AggregationPeriod.DAY) - close("period"= AggregationPeriod.DAY)[1]);
def TR3 = AbsValue(low("period"= AggregationPeriod.DAY) - close("period"= AggregationPeriod.DAY)[1]);
def TrueRange = if TR1 > TR2 and TR1 > TR3 then TR1 else if TR2 > TR1 and TR2 > TR3 then TR2 else TR3;
def ATR = MovingAverage(averageType, TrueRange, atrLength);
def DayHigh = high("period"= AggregationPeriod.DAY);
def DayLow = low("period"= AggregationPeriod.DAY);
def Range = DayHigh - DayLow;
#PLOTS
plot DayOpen = open("period"= AggregationPeriod.DAY);
plot ATRQuarterH = DayOpen + (ATR[1]/4);
plot ATRQuarterL = DayOpen - (ATR[1]/4);
plot ATRHalfH = DayOpen + (ATR[1]/2);
plot ATRHalfL = DayOpen - (ATR[1]/2);
plot ATR3QuarterH = DayOpen + (ATR[1]*.75);
plot ATR3QuarterL = DayOpen - (ATR[1]*.75);
plot ATRFullH = DayOpen + (ATR[1]);
plot ATRFullL = DayOpen - (ATR[1]);
plot ATRFullQuarterH = DayOpen + (ATR[1]*1.25);
plot ATRFullQuarterL = DayOpen - (ATR[1]*1.25);
plot ATRFullHalfH = DayOpen + (ATR[1]*1.5);
plot ATRFullHalfL = DayOpen - (ATR[1]*1.5);
plot ATRFull3QuarterH = DayOpen + (ATR[1]*1.75);
plot ATRFull3QuarterL = DayOpen - (ATR[1]*1.75);
plot ATRFull2xH = DayOpen + (ATR[1]*2);
plot ATRFull2xL = DayOpen - (ATR[1]*2);
#LABEL
AddLabel(if showAtrLabel then 1 else 0, "ATR: " + Round(ATR,2) + " / Range: " + Round(Range,2) + " / " + Round(Range/ATR,2) +"xATR", Color.GRAY);
#CLOUDS
AddCloud(if !showClouds then NA else ATRFull2xH, ATRFull3QuarterH, CreateColor(160,160,160),CreateColor(160,160,160), no);
AddCloud(if !showClouds then NA else ATRFull3QuarterH, ATRFullHalfH, CreateColor(140,140,140),CreateColor(140,140,140), no);
AddCloud(if !showClouds then NA else ATRFullHalfH, ATRFullQuarterH, CreateColor(120,120,120),CreateColor(120,120,120), no);
AddCloud(if !showClouds then NA else ATRFullQuarterH, ATRFullH, CreateColor(100,100,100),CreateColor(100,100,100), no);
AddCloud(if !showClouds then NA else ATRFullH, ATR3QuarterH, CreateColor(80,80,80),CreateColor(80,80,80), no);
AddCloud(if !showClouds then NA else ATR3QuarterH, ATRHalfH, CreateColor(60,60,60),CreateColor(60,60,60), no);
AddCloud(if !showClouds then NA else ATRHalfH, ATRQuarterH, CreateColor(40,40,40),CreateColor(40,40,40), no);
AddCloud(if !showClouds then NA else ATRFull3QuarterL, ATRFull2xL, CreateColor(160,160,160),CreateColor(160,160,160), no);
AddCloud(if !showClouds then NA else ATRFullHalfL, ATRFull3QuarterL, CreateColor(140,140,140),CreateColor(140,140,140), no);
AddCloud(if !showClouds then NA else ATRFullQuarterL, ATRFullHalfL, CreateColor(120,120,120),CreateColor(120,120,120), no);
AddCloud(if !showClouds then NA else ATRFullL, ATRFullQuarterL, CreateColor(100,100,100),CreateColor(100,100,100), no);
AddCloud(if !showClouds then NA else ATR3QuarterL, ATRFullL, CreateColor(80,80,80),CreateColor(80,80,80), no);
AddCloud(if !showClouds then NA else ATRHalfL, ATR3QuarterL, CreateColor(60,60,60),CreateColor(60,60,60), no);
AddCloud(if !showClouds then NA else ATRQuarterL, ATRHalfL, CreateColor(40,40,40),CreateColor(40,40,40), no);
#FORMATTING
#ATRQuarterH.Hide();
#ATRQuarterL.Hide();
#ATRHalfH.Hide();
#ATRHalfL.Hide();
#ATR3QuarterH.Hide();
#ATR3QuarterL.Hide();
#ATRFullH.Hide();
#ATRFullL.Hide();
#ATRFullQuarterH.Hide();
#ATRFullQuarterL.Hide();
#ATRFullHalfH.Hide();
#ATRFullHalfL.Hide();
#ATRFullHalfH.Hide();
#ATRFullHalfL.Hide();
#ATRFullHalfH.Hide();
#ATRFullHalfL.Hide();
#ATRFull3QuarterH.Hide();
#ATRFull3QuarterL.Hide();
#ATRFull2xH.Hide();
#ATRFull2xL.Hide();
DayOpen.SetDefaultColor(Color.WHITE);
DayOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRQuarterH.SetDefaultColor(Color.DARK_GRAY);
ATRQuarterL.SetDefaultColor(Color.DARK_GRAY);
ATRQuarterH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRQuarterL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRHalfH.SetDefaultColor(Color.DARK_GRAY);
ATRHalfL.SetDefaultColor(Color.DARK_GRAY);
ATRHalfH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRHalfL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATR3QuarterH.SetDefaultColor(Color.DARK_GRAY);
ATR3QuarterL.SetDefaultColor(Color.DARK_GRAY);
ATR3QuarterH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATR3QuarterL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFullH.SetDefaultColor(Color.DARK_GRAY);
ATRFullL.SetDefaultColor(Color.DARK_GRAY);
ATRFullH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFullL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFullQuarterH.SetDefaultColor(Color.DARK_GRAY);
ATRFullQuarterL.SetDefaultColor(Color.DARK_GRAY);
ATRFullQuarterH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFullQuarterL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFullHalfH.SetDefaultColor(Color.DARK_GRAY);
ATRFullHalfL.SetDefaultColor(Color.DARK_GRAY);
ATRFullHalfH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFullHalfL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFull3QuarterH.SetDefaultColor(Color.DARK_GRAY);
ATRFull3QuarterL.SetDefaultColor(Color.DARK_GRAY);
ATRFull3QuarterH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFull3QuarterL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFull2xH.SetDefaultColor(Color.DARK_GRAY);
ATRFull2xL.SetDefaultColor(Color.DARK_GRAY);
ATRFull2xH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRFull2xL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Last edited by a moderator: