OK found something out.
No data coming in when code below is in "OnInit".
So I moved the following code to CheckForOpen:
CopyBuffer(stoM15,SIGNAL_LINE,1,2,buf);
DStoM15 = buf[0];
So now I got values in buf[0] and buf[1].
But they dont change over time. Do I really have to go all the way around and create and release the indicator when I want fresh values??
ingvar_e:
Got it working finally!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
So I tried to figure it out.
This is my code in "OnInit()
--------------------
int stoM30;
MqlParam pars[5];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
string name=_Symbol;
ENUM_TIMEFRAMES period;
ENUM_MA_METHOD ma_method = MODE_SMA;
ENUM_STO_PRICE price_field = STO_LOWHIGH;
pars[0].type=TYPE_INT;
pars[0].integer_value = 9;
pars[1].type=TYPE_INT;
pars[1].integer_value = 3;
pars[2].type=TYPE_INT;
pars[2].integer_value = 3;
pars[3].type=TYPE_INT;
pars[3].integer_value = ma_method;
pars[4].type=TYPE_INT;
pars[4].integer_value = price_field;
period = PERIOD_M30;
stoM30=IndicatorCreate(name,period,IND_STOCHASTIC,5,pars);
if(stoM30==INVALID_HANDLE)
{
//--- tell about the failure and output the error code
PrintFormat("Failed to create handle of the iStochastic indicator for the symbol %s/%s, error code %d",
name,
EnumToString(period),
GetLastError());
Logger("OnInit", "Sto indicator fail");
//--- the indicator is stopped early, if the returned value is negative
return(-1);
}
double buf[];
CopyBuffer(stoM30,SIGNAL_LINE,1,2,buf);
Logger("Testit","handle",IntegerToString(stoM30),DoubleToString(buf[0]),DoubleToString(buf[1]));
----------------------------------
Logger output;
2011-10-04-00-00 Testit_______ handle_______ 10___________ 0.00000000___ 0.00000000___ _____________
Obviopusly I am doing something wrong since I just get zeroes in "buf"