Hello everyone. I'm new here, and I hope I'm posting this request in the appropriate forum/thread.
I'm not a coder but trying to learn some of the basics, and I'm hoping someone can help me with what I thought was going to be a relatively easy add-on to an existing code. What I'm trying to accomplish is to add color plots to the existing MACD in TOS, based on whether the fast line, slow line, and MACD lines are rising or falling.
I copied the existing code from the default MACD, created a new indicator and pasted that code into it, then added the following;
Thought it would be fairly straight-forward, but since I know next to nothing about coding, it has turned out to be a challenge and I'm getting multiple errors. I'm hoping one of you experts on here would be able to look at this and tell me what I'm doing wrong?
Thank you so much!
If you would like to see the entire code, here it is;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
fastLength.AssignValueColor(if fastLength > fastLength  then fastLength.color("Up") else fastLength.color("Down"));
slowLength.AssignValueColor(if slowLength > slowLength  then slowLength.color("Up") else slowLength.color("Down"));
MACDLength.AssignValueColor(if MACDLength > MACDLength  then MACDLength.color("Up") else MACDLength.color("Down"));
FYI, I didn't change any of the code from the existing MACD, but only added the color plots at the end.