Custom indicator keep duplicating itself

To add comments, please log in or register
Leo
41
Leo  
I've developed an Expert Advisor and calling a custom indicator using the iCustom function.

The indicator name is: (ROC) https://www.mql5.com/en/code/46

When I start the Tester it just keep repeating itself and I don't know why. 

Here where I call it:

double Roc()
{
  double RocArray[];
  int RocDef = iCustom(Symbol(),Period(),"roc.ex5",9);
  ArraySetAsSeries(RocArray,true);
  CopyBuffer(RocDef,0,0,3,RocArray);
  double roc = RocArray[0];
  return roc;
}

double PreRoc()
{
  double PreRocArray[];
  int PreRocDef = iCustom(Symbol(),Period(),"roc.ex5",9);
  ArraySetAsSeries(PreRocArray,true);
  CopyBuffer(PreRocDef,0,1,3,PreRocArray);
  double preroc = PreRocArray[0];
  return preroc;
}

I've attached an image to show what's happening here. 

Any thoughts?
Price Rate of Change (ROC)
Price Rate of Change (ROC)
  • www.mql5.com
As you know, prices drop and grow in ondulatory way, in cycles. This cyclic movement is a result of change in investors' expectations and the price control fight between bulls and bears. Price Rate of Change (ROC) reflects this ondulatory movement like an oscillator, measuring the difference in prices in a certain period. ROC grows if prices...
William Roeder
22403
William Roeder  
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
Vladimir Karputov
Moderator
201812
Vladimir Karputov  
Leo:
I've developed an Expert Advisor and calling a custom indicator using the iCustom function.

The indicator name is: (ROC) https://www.mql5.com/en/code/46

When I start the Tester it just keep repeating itself and I don't know why. 

Here where I call it:


I've attached an image to show what's happening here. 

Any thoughts?

Forum on trading, automated trading systems and testing trading strategies

Custom indicator and printing function to chart

Vladimir Karputov, 2020.06.19 04:45

Read help: iCustom

Please note: in MQL5, the indicator handle is created once (in OnInit). Then, to obtain the values, use CopyBuffer


To add comments, please log in or register