I'm trying to do a simple calculation on OnBarUpdate() but I keep getting errors. I have researched but I can't make it work.
I have three different indicator lengths and I want to calculate the average. Something like this:
This is declared in the class above the OnStateChange()
private SMA SMA1;
private SMA SMA2;
private SMA SMA3;
Then OnBarUpdate()
SMA1 = SMA(5);
SMA2 = SMA(20);
SMA3 = SMA(50);
AvgSMA=(SMA1+SMA2+SMA3)/3;
double highsignal = 90;
if (CrossAbove(AvgSMA, highsignal, 1))
EnterLong("AALong");
But I keep getting errors about converting double to a series and vice versa. I have tried to declare all doubles but the CrossAbove doesn't like it neither...
What's the best way to accomplish this?
Thanks for the help.
Comment