You are on page 1of 1

#Range expansion bars

input Period = aggregationPeriod.DAY;

input AvgType = averageType.SIMPLE;

input Length = 5;

input priceclose = close;

input percentage = 0.80;

def range = high(period = Period) - low(period = Period);

#def UpBar = MovingAverage(AvgType, close(period = Period), Length) < priceclose and priceclose >
(close(period = Period) + (range * percentage));

def UpBar = MovingAverage(AvgType, close(period = Period), Length) < priceclose and priceclose >
(close(period = Period)[1] + (range[1] * percentage)) and open(period = Period) <
MovingAverage(AvgType, close(period = Period), Length);

def DownBar = MovingAverage(AvgType, close(period = Period), Length) > priceclose and priceclose <
(close(period = Period)[1] - (range[1] * percentage)) and open(period = Period) >
MovingAverage(AvgType, close(period = Period), Length);

input PaintBars = Yes;

AssignPriceColor (if !PaintBars then Color.CURRENT else if UpBar >= 0 and UpBar > DownBar[0] then
Color.GREEN else if UpBar <= 1 and UpBar < DownBar[1] then Color.RED else Color.WHITE);

#UpBar > DownBar[0]

You might also like