How to get data from custom indicator in mql4

sulfred
21
sulfred  

I would like to get data from a custom indicator in mql4.

I know that how to do that in mql5 like this.

int indicatorHandle = iCustom(Symbol(), Period(), indicatorName, ...);
double tempArray[1000];
CopyBuffer(indicatorHandle, 0, 0, 1000, tempArray);

I search the document https://docs.mql4.com/indicators/icustom and find that I can get the value one by one. But this is too slow if I have asking for 1000 value. I would like to ask if there is a good method to get data from custom indicator in mql4 ?


Thank you very much.

iCustom - Technical Indicators - MQL4 Reference
iCustom - Technical Indicators - MQL4 Reference
  • docs.mql4.com
[in]  Custom indicator compiled program name, relative to the root indicators directory (MQL4/Indicators/). If the indicator is located in subdirectory, for example, in MQL4/Indicators/ The passed parameters and their order must correspond with the declaration order and the type of extern variables of the custom indicator...
Seng Joo Thio
1821
Seng Joo Thio  
sulfred:

I would like to get data from a custom indicator in mql4.

I know that how to do that in mql5 like this.

I search the document https://docs.mql4.com/indicators/icustom and find that I can get the value one by one. But this is too slow if I have asking for 1000 value. I would like to ask if there is a good method to get data from custom indicator in mql4 ?

Thank you very much.

It'll be one by one.

Depending on how you code, you need not call iCustom() 1000 times every tick (worst case - just call once when your program starts, then just update the latest value every tick/bar will do).

Nikolaos Pantzos
45383
Nikolaos Pantzos  
sulfred:

I would like to get data from a custom indicator in mql4.

I know that how to do that in mql5 like this.

I search the document https://docs.mql4.com/indicators/icustom and find that I can get the value one by one. But this is too slow if I have asking for 1000 value. I would like to ask if there is a good method to get data from custom indicator in mql4 ?


Thank you very much.

Hello,

try something this..

datetime LastTimeBar=0;//Put it outside of any function/class


//Add it OnTick Function
if(iTime(Symbol(),0,0)!=LastTimeBar)
     {

      double IndicatorBuffer_1=iCustom(NULL,0,"Indicator Name",IndicatorsParameter_1,IndicatorsParameter_2,NoOfIndicatorBufferGet,Shift);
      LastTimeBar=iTime(NameOfSymbol,0,0);
     }
sulfred
21
sulfred  

Thank you.

I updated the indicator so that I can get 1 value instead of 1000 values.