ChocolateVol
New member
I'm tracking the classic MACD using a 20min time frame but displayed in the 5min chart.
Can you help me fix the below code so that the bars are colored green if up/sideways and red once they turn lower/sideways? The idea is that they should be all green or all red until the line flips direction and or remain of the same "trending" color otherwise.
Can you help me fix the below code so that the bars are colored green if up/sideways and red once they turn lower/sideways? The idea is that they should be all green or all red until the line flips direction and or remain of the same "trending" color otherwise.
Code:
declare lower;
input time1 = AggregationPeriod.TWENTY_MIN;
input fastLength = 3;
input slowLength = 10;
input averageType = AverageType.EXPONENTIAL;
plot Value1 = MovingAverage(averageType, close(period = time1), fastLength) - MovingAverage(averageType, close(period = time1), slowLength);
plot ZeroLine = 0;
Value1.SetPaintingStrategy(PaintingStrategy.LINE);
Value1.SetLineWeight(1);
Value1.DefineColor("Positive and Up", Color.GREEN);
Value1.DefineColor("Positive and Down", Color.RED);
Value1.DefineColor("Negative and Down", Color.RED);
Value1.DefineColor("Negative and Up", Color.GREEN);
Value1.AssignValueColor(if Value1 >= 0 then if Value1 >= Value1[1] then Value1.color("Positive and Up") else Value1.color("Positive and Down") else if Value1 < Value1[1] then Value1.color("Negative and Down") else Value1.color("Negative and Up"));
Last edited by a moderator: