0

I have the code plotting McGinley Dynamic. My goal is to diffrentiate the colors of the line depending on rising or falling line (green/red).

Code for plotting McGinley works. The problem is that it plots only in one color. After adding last two commented lines (and removing "plot(mg, color=orange, linewidth=4)") which are supposed to change colors the whole code breaks. What is wrong here?

study(title="McGinley Dynamic Average", shorttitle="McGinley", overlay=true, precision=6) len = input(14, minval=1) src = input(close, title="Source") mg = na(mg[1]) ? src : mg[1] + (src - mg[1]) / (0.6 * len * pow(src/mg[1], 4)) plot(mg, color=orange, linewidth=4) //mgc=(mg>mg[1]) ? green:(mg<mg[1]) ? red:(mg==mg[1]):blue:black //plot(mg, color=std?mgc:black, linewidth=3, title="mg") 

Expecting McGinley plotted in diffrent colors.

1 Answer 1

1

There is a mismatch in your conditions at this line (You placed : instead of ? after (mg == mg[1])):

mgc=(mg>mg[1]) ? green:(mg<mg[1]) ? red:(mg==mg[1]):blue:black 

Simply change it to:

mgc = (mg > mg[1]) ? green : (mg < mg[1]) ? red : (mg == mg[1]) ? blue : black 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.