Help me! iCustom function

To add comments, please log in or register
nhatkhanguyen92
34
nhatkhanguyen92  
I have 1 EA that uses iCustom function to get Fisher indicator data
When back test there are too many windows of the Fisher indicator.

Please help me fix this


Thanks for reading



int OnInit()
  {
   ArraySetAsSeries(priceInfo, true);
   ArraySetAsSeries(fisherArray, true);
   

   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
   nameChart = _Symbol+subName;
   copy = CopyRates( nameChart, _Period, 0 , 10, priceInfo);
   
   if(priceInfo[0].tick_volume == 1){
      if(priceInfo[0].time > (candlesTime + 2*PeriodSeconds() )){
         int _data = iCustom(nameChart, _Period, "Scalping\\Fisher", 10,0,0);
         CopyBuffer(_data, 0, 0, 10, fisherArray);
         fTrend = fisherArray[0];
         ArrayFree( fisherArray );
         order = openOrder(nameChart, _Period, priceInfo, fTrend, nameBot );
        
        }
   }
}

and photo

Files:
backtest.png 56 kb
La_patates
55
La_patates  
nhatkhanguyen92:
I have 1 EA that uses iCustom function to get Fisher indicator data
When back test there are too many windows of the Fisher indicator.

Please help me fix this


Thanks for reading



and photo

Try creating your indicator handle from the OnInit() instead of from the OnTick(). That way it be created once instead of at every tick!
William Roeder
23260
William Roeder  

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 (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 start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010
To add comments, please log in or register