Why won't this label work on my chart?

earlyinout

New member
just trying to create a simple label that is green if mov. avg fast is above mov.avg slow?

Code:
def ma8 = movAvgWeighted(8);
def ma34 = movAvgWeighted(34);


addLabel(1, "MAW 8 VS 34" + IF ma8 > ma34 then color.GREEN else color.RED);

As always your help is appreciated!
 

MerryDay

Well-known member
VIP
@earlyinout
I tried @mashume's fix and while no syntax errors highlighted. The 'ok' button was grayed out and won't save. So I made some more changes and corrected 3 syntax errors:
QcMR0zi.png

Ruby:
def ma8  = MovAvgWeighted("length" = 8) ;
def ma34 = MovAvgWeighted("length" = 34);

addLabel(1, "MAW 8 VS 34", if ma8 > ma34 then color.GREEN else color.RED);
Here is a quickie way to find the correct syntax in the future.
HTH
 

earlyinout

New member

Similar threads

Top