How to use iMAOnArray() with Stochastic? - page 2

 

so whats the big deal

   for(i=0; i<Bars; i++)
   Signal_Sto[i] = iStochastic(NULL,0,70,5,5,MODE_EMA,0,MODE_SIGNAL,i);
   ArraySetAsSeries(Signal_Sto, true);
   double MA_Sto = iMAOnArray( Signal_Sto, 0,14,0,MODE_SMA,0);
 
qjol:

so whats the big deal


Thanks a lot!

Suddenly I got another question in mind. That is, how the MA which I'm using in the Stochastic indicator window, calculating it's value because there are two period:

%K Period [Main Value]

%D Period [Signal Value]

   for(i=0; i<Bars; i++)
   Main_Sto[i] = iStochastic(NULL,0,70,5,5,MODE_EMA,0,MODE_MAIN,i);
   for(i=0; i<Bars; i++)
   Signal_Sto[i] = iStochastic(NULL,0,70,5,5,MODE_EMA,0,MODE_SIGNAL,i);
   ArraySetAsSeries(Signal_Sto, true);
   double MA_Sto = iMAOnArray( Signal_Sto, 0,14,0,MODE_SMA,0);

Here according to this line:

double MA_Sto = iMAOnArray( Signal_Sto, 0,14,0,MODE_SMA,0);

MA is getting value ONLY from %D period?

Or it is getting value from both periods?

And would please explain a bit why the line is used?

ArraySetAsSeries(Signal_Sto, true);

Thanks

 
Arav007:


Thanks a lot!

Suddenly I got another question in mind. That is, how the MA which I'm using in the Stochastic indicator window, calculating it's value because there are two period:

%K Period [Main Value]

%D Period [Signal Value]

i think u r mistaken & u mean main line & signal line

Here according to this line:

double MA_Sto = iMAOnArray( Signal_Sto, 0,14,0,MODE_SMA,0);

MA is getting value ONLY from %D period?

again not %D Period but signal line

Or it is getting value from both periods?

no only the signal line

And would please explain a bit why the line is used?

ArraySetAsSeries(Signal_Sto, true);

ArraySetAsSeries()

 
qjol:



Thanks once again!

Now I got it. But I was thinking if it was possible to get the value for MA from both the Lines?

And in general when I put that MA into the Stochastic indicator window, how it is getting it's value?

Here the Thick Red line is MA and other two lines are two period of Stochastic.

Thanks

MA

 
Arav007:


Now I got it.

i dont think so

   for(i=0; i<Bars; i++)
   Main_Sto[i] = iStochastic(NULL,0,70,5,5,MODE_EMA,0,MODE_MAIN,i);
   for(i=0; i<Bars; i++)
   Signal_Sto[i] = iStochastic(NULL,0,70,5,5,MODE_EMA,0,MODE_SIGNAL,i);
   ArraySetAsSeries(Main_Sto, true);
   ArraySetAsSeries(Signal_Sto, true);
   double MA_Main_Sto = iMAOnArray(Main_Sto, 0,14,0,MODE_SMA,0);
   double MA_Signal_Sto = iMAOnArray(Signal_Sto, 0,14,0,MODE_SMA,0);
 
qjol:

i dont think so



opps... I missed the ArraySetAsSeries(Main_Sto, true);

Thank you once again. :)

 
qjol:i dont think so
   for(i=0; i<Bars; i++)
   Signal_Sto[i] = iStochastic(NULL,0,70,5,5,MODE_EMA,0,MODE_SIGNAL,i);
   ArraySetAsSeries(Main_Sto, true);
I think you need the AsSeries for the OnArray, but you've put the data in backwards. Put the AsSeries before you fill the array.
 
WHRoeder:
I think you need the AsSeries for the OnArray, but you've put the data in backwards. Put the AsSeries before you fill the array.


I am not sure what's wrong with it but it's not returning any value!

    ArraySetAsSeries(Signal_Stochastic, true);
   for( i=0; i<Bars; i++)
Signal_Stochastic[i] = iStochastic(NULL,0,75,5,5,MODE_SMA,0,MODE_SIGNAL,i);


sLog_Start = sLog_Start + sNL + "    Signal Sto's Value=" +  Signal_Stochastic[0];

I tired to get the value of Signal_Stochastic at 'current' bar, hence I put '0' in the Array but nothing is showing up!

Probably I have done it wrong. If I want to get the value of current bar then what can I do?

Thanks


 
  1. You didn't "put '0' in the Array" you pust the stochastic signal in the array and selected the zero'th element.
  2. "nothing is showing up" means nothing."Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  3. Post ALL the code, like your array definitions, resizing, etc.
 
WHRoeder:
  1. You didn't "put '0' in the Array" you pust the stochastic signal in the array and selected the zero'th element.
  2. "nothing is showing up" means nothing."Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  3. Post ALL the code, like your array definitions, resizing, etc.


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,75,5,5,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);
}

Here I am really confused with the Array things. So pardon my ignorance.

My sole aim is comparing the Two [Signal_Stochastic & MA_Signal_Sto]. The sequence of functions will be exactly the same as showed above. [I just avoided the Buying/Selling functions to avoid lengthy code]

Thanks