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.