Cribbage
Member
I'm trying to modify the TOS DailyHighLow Study to only show up if the candle is an engulfing candle. In other words, the indicator range doesn't display unless the aggregated period moves past the high and the low of the previously aggregated range. Also would be nice if the halfway point between the high and the low could be added as I can't figure out where that code would go.
Code:
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
def Engulfing = high > high[1] and low < low[1];
plot DailyHigh;
plot DailyLow;
if Engulfing and showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
DailyHigh = Double.NaN;
DailyLow = Double.NaN;
} else {
DailyHigh = Highest(high(period = aggregationPeriod)[-displace], length);
DailyLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}
DailyHigh.SetDefaultColor(GetColor(4));
DailyHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailyLow.SetDefaultColor(GetColor(4));
DailyLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);