- Adnan S: It loads in terminal just fine. When called via EA it fails.
Alert: Error 0 while getting handle on Price_Density
It has not failed. Zero mean no error.
int OnInit() { Noise_Handle=iCustom(_Symbol,_Period,NOISE_INDICATOR,Noise_Filtering_Period,Noise_Filtering_Level); { Alert(StringFormat("Error %i while getting handle on %s",_LastError,NOISE_INDICATOR)); return(INIT_FAILED); }
You are issuing the message and killing the EA always.
-
void OnTick() { int Noise_Handle=INVALID_HANDLE; Noise_Handle=iCustom(_Symbol,_Period,NOISE_INDICATOR,Noise_Filtering_Period,Noise_Filtering_Level);
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (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)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
How to call indicators in MQL5 - MQL5 Articles (2010)
-
It has not failed. Zero mean no error.
You are issuing the message and killing the EA always.
-
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (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)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
How to call indicators in MQL5 - MQL5 Articles (2010)
Thanks William I figured out what the issue was,
if(Noise_Handle==INVALID_HANDLE) is what I forgot to add above {Alert.........,
But I do sincerely appreciate the help.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I found this indicator on github.
It loads in terminal just fine. When called via EA it fails.
Alert: Error 0 while getting handle on Price_Density
I replicated the error by using a test EA.
Any help would be much appreciated.
This is sample code of EA getting handle in OnInit, that generates an error. Now if I don't use OnInit and move everything to OnTick it works. Code is attached for that as well. I am just curious what am I missing here?
OnTick Code Below
// TEST EA FOR PRICE DENSITY using Only OnTick()// #include<Trade\Trade.mqh> #define NOISE_INDICATOR "Price_Density" input int Noise_Filtering_Period = 20.0; input double Noise_Filtering_Level = 5.0; void OnTick() { int Noise_Handle=INVALID_HANDLE; double Noise_Value_Array[]; Noise_Handle=iCustom(_Symbol,_Period,NOISE_INDICATOR,Noise_Filtering_Period,Noise_Filtering_Level); if(Noise_Handle==INVALID_HANDLE) { Alert(StringFormat("Error %i while getting handle on %s",_LastError,NOISE_INDICATOR)); return; } ArraySetAsSeries(Noise_Value_Array,true); if(CopyBuffer(Noise_Handle,0,0,3,Noise_Value_Array)==-1) return; Comment( "NOISE BUFFER 0 : ",Noise_Value_Array[0],"\n" "NOISE BUFFER 1 : ",Noise_Value_Array[1],"\n" ); }
This is the Indicator Code.