Stochastic indicator return values

- 2020.04.09
- www.mql5.com
@Vladimir Karputov Thanks
Figured it out, looks like it was a formatting issue. As it turns out:
Print("Sto_Main: ", Sto_Main); Print("Sto_Sig: ", Sto_Sig);
returns:
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Main: 11.27450980392989
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Sig: 18.47919483886281
whereas
PrintFormat("Sto_Main: %d", Sto_Main); PrintFormat("Sto_Sig: %d", Sto_Sig);
returns:
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Main: -1936941349
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Sig: -2091822104
I have no idea why. I thought %d flag gives a double format (but is actually 'signed decimal integer'?). At the same time, I thought %e should give a double format too, but that results in a large number too. Both %d and %e formats to a value that is much larger than the actual value.
If there are experts who could enlighten me as to why, very much appreciated.
@Vladimir Karputov Thanks
Figured it out, looks like it was a formatting issue. As it turns out:
returns:
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Main: 11.27450980392989
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Sig: 18.47919483886281
whereas
returns:
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Main: -1936941349
2020.04.20 22:13:08.506 2020.04.02 15:26:00 Sto_Sig: -2091822104
I have no idea why. I thought %d flag gives a double format (but is actually 'signed decimal integer'?). At the same time, I thought %e should give a double format too, but that results in a large number too. Both %d and %e formats to a value that is much larger than the actual value.
If there are experts who could enlighten me as to why, very much appreciated.
Use a simple form:
DoubleToString(

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Apologies if a solution has been posted elsewhere, grateful if anyone could point me in the right direction. (Also
The problem encountered is that I'm trying to extract the values for an indicator, the stochastic oscillator in this instance. However the values returned are outside of the expected 0 to 100 range. The indicator when loaded on the chart however does seem to calculate the right values.
Pertinent bits of code below, however please let me know if I should post more.
1) The values for the Stochastic indicator are retrieved via CopyBuffer() per documentation. In this case, the handles are retrieved via iCustom() earlier
2020.04.20 19:02:42.555 2020.04.03 04:58:00 Indicator: Stochastic
2020.04.20 19:02:42.555 2020.04.03 04:58:00 Indicator handle: 12
2020.04.20 19:02:42.555 2020.04.03 04:58:00 Sto_Main: 311222032, Sto_Sig: -165991175
1a) The output values for the Main Line and Signal Line are some huge numbers above.
2) To double check if there wasn't any other issues/errors with referencing the right function, handle, etc, I also retrieved the values via iStochastic()
2a) Which gave this result - same big numbers but is indeed outputting a value.
2020.04.20 19:02:42.555 2020.04.03 04:58:00 New Indicator handle: 34
2020.04.20 19:02:42.555 2020.04.03 04:58:00 Sto_Main: 311222032, Sto_Sig: -165991100
3) On the chart, the values returned look normal:
Why are the return values not within the range of 0 to 100 for the Stochastic Oscillator?
Grateful for your help