Stochastic Oszillator - iStochastic in comparison to shown ididator in Metatrader

 

Good evening,

I am currently using the following Stochastic Oszillator:


iStochastic(NULL, PERIOD_M5, 7, 2, 2, 0, 1, 1, 0);


The issue now is that once I use a Stochastic Oszillator (7, 2, 2) in Metatrader in a M5-chart the values vary enormously in comparison to the coded results.

What I would like to achieve is getting results of the blue indicator line in the Metatrader. Until now I wasn't able to find any possible solution for this issue.


Thanks for your assistance.

 
FlashX:

iStochastic(NULL, PERIOD_M5, 7, 2, 2, 0, 1, 1, 0);


What I would like to achieve is getting results of the blue indicator line in the Metatrader. Until now I wasn't able to find any possible solution for this issue.
  1. Start with the documentation and use the predefined enumerations to make your code readable:
    iStochastic(NULL, PERIOD_M5, 7, 2, 2, MODE_SMA, 1, MODE_SIGNAL, 0); // Same as yours.
    Then you would see you want the MODE_MAIN.
  2. And next time:

    For large amounts of code, attach it.
 

Thanks for your reply,

I used the following code snippet in order to debug the issue:

double stochastic = iStochastic(NULL, PERIOD_M5, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, 0);
Print(stochastic);

22:07:39 2012.10.03 07:35  ExpertAdvisor GER30,M1: 11.7647
22:07:39 2012.10.03 07:35  ExpertAdvisor GER30,M1: 12
22:07:39 2012.10.03 07:35  ExpertAdvisor GER30,M1: 14
22:07:39 2012.10.03 07:35  ExpertAdvisor GER30,M1: 16
22:07:39 2012.10.03 07:35  ExpertAdvisor GER30,M1: 14
22:07:39 2012.10.03 07:35  ExpertAdvisor GER30,M1: 16
22:07:39 2012.10.03 07:35  ExpertAdvisor GER30,M1: 12


Indictator line in Metatrader: (PERIOD M5)

I hope the issue became more clear as I would like to get values such as 35.8209 returned instead of the results I received above.

 
If there is no possible way to receive the data I would like to have with the function iStochastic I would like to script my own indicator by using my own calculation. Does any of you know how to either get the data I would like to have or the calculation for the common Stochastic indicator?
 
FlashX:
If there is no possible way to receive the data I would like to have with the function iStochastic I would like to script my own indicator by using my own calculation. Does any of you know how to either get the data I would like to have or the calculation for the common Stochastic indicator?
Does this help ?  https://www.metatrader5.com/en/terminal/help/indicators/oscillators/so
 

Well, I am having issues with CLOSE.

%K = (CLOSE-LOW(%K))/(HIGH(%K)-LOW(%K))*100


%K would be 5 in my case.

For LOW(%K) I may use the function iLow (M5).

For HIGH(%K) I may use the function iHigh (M5).

CLOSE would be today's closing price. I do not quite understand what is meant here. What function may I use for that?

 

FlashX: I hope the issue became more clear as I would like to get values such as 35.8209 returned instead of the results I received above.


Your 35.8 pop up is for what ever candle your mouse is over. Your iStoch call is for the current candle.
 
Nevermind.
 
WHRoeder:

Your 35.8 pop up is for what ever candle your mouse is over. Your iStoch call is for the current candle.

Where is the difference? Is it possible to get data every minute according to the blue line in the M5 chart? Or is it somehow possible to get this line somehow transfered into M1? I am in need of the results of this line.
 
Your mouse was not over the right most bar when you got the 35.8. iStoch(... 0) always returns the current value.
 
Where my mouse is doesn't matter. I compared 7:35 on the chart with 7:35 in the EA and it's not the same. Therefore my mouse was right where I wanted it to be.
Reason: