Hope you are doing fine.
I am having problem with defining 'iMAOnArray()' function.
I am planning a strategy with 'Stochastic Crossover' with Moving Average in the 'Precious Indicator's Data'. [See the attached Image, Yellow one is the MA]
The idea is when the MA will cross the 'Signal Line' of Stochastic, it'll produce Buy/Sell accordingly.
I have tried to get idea about 'iMAOnArray' and arranged things like this:
Code: Select all
int start()
{
sLog_Start = "START - start() function----------------------------------";
double Signal_Stochastic[];
sLog_Start = sLog_Start + sNL + " Start - Set and Get MA values";
ArraySetAsSeries(Signal_Stochastic, true);
for( i=0; i<Bars; i++)
Signal_Stochastic[i] = iStochastic(NULL,0,20,10,20,MODE_SMA,0,MODE_SIGNAL,i);
double MA_Signal_Sto = iMAOnArray(Signal_Stochastic, 0,20,0,MODE_SMA,0);
sLog_Start = sLog_Start + sNL + " Signal Sto's Value=" + Signal_Stochastic[0];
sLog_Start = sLog_Start + sNL + " MA_Signal_Sto's Value=" + MA_Signal_Sto;
if (Signal_Stochastic>MA_Signal_Sto)
{
Buy;
}
if (Signal_Stochastic<MA_Signal_Sto)
{
Sell;
}
return (0);
}But matter of great regret is that I am not getting any value other than '0' for Signal Line and MA.
Signal Sto's Value=0.000000000
MA_Signal_Sto's Value=0.00000
So I am doing it wrong. So please correct me or refer me to the example where such MA crossover with Stochastic is discussed elaborately.
Thanks