get indicator values with out plotting

samjesse

Active Trader
Aug 30, 2011
118
0
27
Hello

I am using iStochastic in a .mqh file in a class which is being used in a .mq5 file.
MQL5:
 stoHandle = iStochastic(_symbol, _period, x, y, z, MODE_SMA, STO_CLOSECLOSE);
 
int copied=CopyBuffer(stoHandle, 0, 0, bar_count, stochBuffer);
How can I use the above indicator without having to have it present "plotted" on the MetaQoute chart?

It appears to only work if the plot is present.

thx
 
Last edited by a moderator:

samjesse

Active Trader
Aug 30, 2011
118
0
27
That's strange... All my MT5 EAs that use indicators never add them to the plot and they work perfectly. Is copied = 0 always?

copied = -1
What is your built number? mine is Version 5.00 built 496 running under Win7
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
19,297
1,529
144
Odesa
www.earnforex.com
Same version but WinXP.

Where do you call CopyBuffer()? Inside OnCalculate() or OnTick()? If so, then does it return -1 on every tick?

CopyBuffer() may return -1 when the chart data isn't yet ready, e.g. on the first run after the indicator/EA is attached.
 

samjesse

Active Trader
Aug 30, 2011
118
0
27
Thx Enivid

I used the wizard to create an EA and left the other file which was created using the wizard as well but as an Indicator. Now the problem is no longer present "in the EA".
:)