Read the documentation for copybuffer, this is wron in oninit
Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.)
You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get
the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
Also see my example for encapsulating calls
Detailed
explanation of iCustom - MQL4 programming forum
2017.05.23
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Indicator is working fine in OnCalculate,OnTick,OnTimer but why not in OnInit. Is there any other option to load indicator data on Initialization.?
int OnInit()
{
double mabuff[];
ArraySetAsSeries(mabuff,true);
int ma=iMA(_Symbol,_Period,14,0,MODE_SMA,PRICE_CLOSE);
if(CopyBuffer(ma,0,0,2,mabuff)==-1)
{
Print("error in loading Inidcator data");
}
return(INIT_SUCCEEDED);
}
2020.05.17 21:29:19.736 MA ONINIT (USDCAD,H1) error in loading Inidcator data
Main Idea I'm looking for is,I want to load indicator data only once in beginning.
Thanks,
Philip Pankaj