Minimum percent range from low to high for consecutive bars


Category:
0
0

Hey Pete, I’m looking for a scan that can search the minimum percentage of 5% from low to high of each daily candle in the past 5 candles.

Note that I’m not looking for accumulative of the last 5 candles but instead each candle has to have a 5% range.

Marked as spam
Posted by (Questions: 12, Answers: 20)
Asked on July 26, 2020 12:07 pm
76 views
0
Private answer

I have updated the title of your question. The original title you entered did not include the very important detail about consecutive bars. The title I have selected will make it much easier for the rest of our audience to understand the context immediately and will assist those searching for these specific terms.

So the code needs to compute the percent difference from the low to the high. But we can also measure this value by computing the percent difference from high to low. I have included both in the solution.

The code includes user inputs to adjust the percent threshold and number of consecutive bars without modifying the code.

input percentThreshold = 5.0;
input consectutiveBars = 5;
# two ways to compute percent diff
# from low to high
def percentFromLow = 100 * (high / low - 1);
# from high to low
def percentFromHigh = AbsValue(100 * (low / high - 1));
# scan using computation from low to high
plot scan = Sum(percentFromLow >= percentThreshold, consectutiveBars) >= consectutiveBars;
# scan using the computation from high to low
#plot scan =Sum(percentFromHigh >= percentThreshold, consectutiveBars) >= consectutiveBars;

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on July 26, 2020 1:13 pm