Stochastic Oscillator value - page 2

 
blogzr3 wrote >>

The standard built-in Stochastic Oscillator is iStochastic().

Thanks.

But it's different! once you put built-in Stochastic Oscillator and another Stochastic made by iStochastic() in a chart.

 
rbt:

Thanks.

But it's different! once you put built-in Stochastic Oscillator and another Stochastic made by iStochastic() in a chart.


No, its not. I tried before I posted.

I compared the "built-in" from the Navigator Window, Indicators/Stochastic Oscillator versus a "made by iStochastic()" with the following code, and they look exactly the same:


buffer1[i]=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,i);
buffer2[i]=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,i);


Do you have an example where they are different?

 

Thank you.

You're right. I had a wrong parameter.

 
rbt:

Thank you.

You're right. I had a wrong parameter.

What's the difference between using price_field = 0 (low/high) vs price_field = 1 (close/close). The stochastic formula calculates how far from the lowest low the last close is, relative to the recent range (high - low). what does close/close use instead? sorry the mql4 documentation doesn't seem to address this

 
blogzr3:

No, its not. I tried before I posted.

I compared the "built-in" from the Navigator Window, Indicators/Stochastic Oscillator versus a "made by iStochastic()" with the following code, and they look exactly the same:

buffer1[i]=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,i);
buffer2[i]=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,i);


Do you have an example where they are different?


I appreciate this thread is a couple of years old, but I've been slowly going crazy with the same problem.

If I place the standard Stochatic Oscillator indicator directly onto a chart with a 17,5,3 using LWMA mode with CLOSE price I get the base and signal plot just fine.

If I use an in-code call to iStochastic using EXACTLY the same parameters - I get slightly different data.

I've double-checked all my parameters a few hundred times...

edit: attached the screenshot showing the standard Stochastic Oscillator indicator in window 1 and the iStochastic in-code call plots in window 2. The settings are 17,5,3 using MODE_LWMA and PRICE_CLOSE. Even a cursory glance at the two plots show differences, but the most obvious is the the current values for each as shown in the upper left hand corner of each of the windows.

I have also attached the code used to plot the iStochastic as I'm hopeful, even at this late stage, to have someone, anyone, point out how stupid I've been and where my error lies. Or not.

//+------------------------------------------------------------------+
//| //| iStochastic Plot
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DarkTurquoise
#property indicator_color2 MediumSpringGreen

extern int k_param = 17;
extern int d_param = 5;
extern int slowing_param = 3;
//---- input parameters

//---- buffers
double val1[];
double val2[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator line
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_LINE,0,0);
   SetIndexStyle(1,DRAW_LINE,STYLE_DOT,0);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
    

//----
   return(0);
  }
  
int deinit()
  { 

//----
   return(0);
  }
  
//+------------------------------------------------------------------+
//| ASCTrend1sig                                                     |
//+------------------------------------------------------------------+
int start()
  {
    
   SetIndexDrawBegin(0,1);
   SetIndexDrawBegin(1,1);
   

    if(Bars<=10) return(0);
   int ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars;
               
  while(pos>=0)
     {
     
     val1[pos] = iStochastic(NULL,0,k_param,d_param,slowing_param,MODE_LWMA,PRICE_CLOSE,0,pos);
     val2[pos] = iStochastic(NULL,0,k_param,d_param,slowing_param,MODE_LWMA,PRICE_CLOSE,1,pos);
                            
            
    pos--;
     
     }
         
      
   return(0);
  }
//+------------------------------------------------------------------+

 

I too can't find any way to get the same values out of iStochastic or iCustom( ... "Stochastic" ...) as I do when I display a "Stochastic Oscillator" standard indicator.

Bizarre.