the last few posts were just patches, so i wasn't sure what the final study was, so i made one.

i started by looking at the chart, and determined there are 3 zones to have different colors.

there are 2 average lines, so,

above top line, in between the lines, below bottom line.

i decided i would want 2 different colors for the in between, 1 for upwards, 1 for down. so i added cyan.

i simplified this,

def histogramValue = if isUptrend or isDowntrend then close - ema1 else Double.NaN;

to this,

def histogramValue = close - ema1;

i never use a specific average function (like ExpAverage() ).

i always use MovingAverage( ), so i can change the type of average.

because the averages could be different numbers, i renamed them to avg1 and avg2.

Code:

```
#histo_colors_with_emas
#https://usethinkscript.com/threads/simple-pullback-trend-indicator-help.17371/#post-135114
#simple pullback trend indicator help
declare lower;
def na = double.nan;
def bn = barnumber();
def c = close;
input avg1_type = AverageType.exponential;
input avg1_length = 5;
def avg1 = MovingAverage( avg1_type , c , avg1_length );
input avg2_type = AverageType.exponential;
input avg2_length = 20;
def avg2 = MovingAverage( avg2_type , c, avg2_length );
def trendup = avg1 > avg2;
def trenddwn = avg1 < avg2;
def above = c > max(avg1, avg2);
def bet_dwn = trendup and between(c, min(avg1, avg2), max(avg1, avg2));
def bet_up = trenddwn and between(c, min(avg1, avg2), max(avg1, avg2));
def below = c < min(avg1, avg2);
def histogramValue = close - avg1;
plot histogram = histogramValue;
histogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
histogram.SetLineWeight(3);
histogram.AssignValueColor(
if above then color.green
else if bet_up then color.cyan
else if bet_dwn then color.yellow
else if below then color.red
else color.gray);
#
```

COST hour