|
Jackson, MS
Posts: 34 since Dec 2015
Thanks Given: 1
Thanks Received: 5
|
Hello, enjoy the scripts. I have created an upper and lower study for you to use. Your criteria is listed by default and must use a defined average length and percent, but has inputs for you to modify them. There is a way to make them plot using all the bars on the chart but that requires more time than I have.
This study will mark the candles whose range expands > 30% of the N value average range. This examines average range (high - low), not ATR, and excludes the current candle to ensure the average range is anchored. The current bar is not included with the average range so that the average range does not change while the current bar is forming its range.
By default the upper study shows the labels with expansion %, average range, and current bar range, and the dots above the bars that are outside the range %. Both can be turned off to avoid hiding candles. I created a lower study to keep your price chart clean and help you visualize the range compared to the average range. Certain elements can be turned off on it as well. Copy and paste the following scripts into your platform. I have attached an image to show how these look as of the time I post them.
UPPER STUDY
# Begin script
#VanDriver @ Futures.io on Sept 22, 2020.
# Request: mark candle range whose range expands > 30% of the N value average range. This examines average range, not ATR, and excludes the current candle to ensure the average range is anchored. This is the upper study that goes with the lower.
input Bubbles = yes;
input dots = yes;
input length = 60;
input percent = 30;
def ph = high[1];
def pl = low[1];
def range = high - low;
def avgrange = Sum(ph - pl, length) / length ;
def rangeX = range >= avgrange * (1 + percent /100);
def avgrp = (avgrange - range) / avgrange * -1;
def na = double.nan;
Plot Dot = if dots and rangeX then high else na;
dot.setdefaultColor(color.yellow);
dot.setpaintingStrategy(PaintingStrategy.TRIANGLES);
dot.HideBubble();
dot.hideTitle();
dot.setLineWeight(3);
AddChartBubble(bubbles and rangeX, high, text = "Stretch " + AsPercent(avgrp) + "\n AvgRange " + Round((avgrange), 2) + "\n Range Size " + Round((range), 2), Color.light_gray);
# end script
---
LOWER STUDY
# Begin script
#VanDriver @ Futures.io on Sept 22, 2020.
# Request: mark candle range whose range expands > 30% of the N value average range. This examines average range, not ATR, and excludes the current candle to ensure the average range is anchored. This is the lower study and requires the upper to see plots on the candles.
declare lower;
input Bubbles = yes;
input length = 60;
input percent = 30;
def ph = high[1];
def pl = low[1];
plot range = high - low;
def avgrange = Sum(ph - pl, length) / length ;
def rangeX = range >= avgrange * (1 + percent /100);
def avgrp = (avgrange - range) / avgrange * -1;
plot UpperBand = avgrange * (1 + percent / 100);
UpperBand.SetDefaultColor(color.magenta);
range.setdefaultColor(color.dark_green);
range.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);
AddChartBubble(bubbles and rangeX, range, text = "Stretch " + AsPercent(avgrp) + "\n AvgRange " + Round((avgrange), 2) + "\n Range Size " + Round((range), 2), Color.light_gray);
# end script
|