Indicator parameters to iCustom have no effect!

nnemes
18

I wrote a custom indicator that looks like this:

#property copyright "Copyright 2022, Norbert Nemes"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 2;
#property indicator_plots 1;

#property indicator_type1 DRAW_FILLING
#property indicator_label1 "HMA Fast; HMA Slow"
#property indicator_color1 clrGreen, clrRed

input int period = 200; // Period of the moving average

double fastMA[];
double slowMA[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0, fastMA, INDICATOR_DATA);
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, period);
   SetIndexBuffer(1, slowMA, INDICATOR_DATA);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, period);
   return(INIT_SUCCEEDED);
  }

...

It has a single input called period which determines the period of the moving average. Default is 200. I also have an expert advisor that is calling this indicator like this:

int OnInit() {
   profit = 0;
   stopLoss = 0;
   takeProfit = 0;
   previousData = "";
   hasBought = false;
   hasSold = false;
   tradeLine.Create(0,"Trade",0,0);
   tradeLine.Color(clrPurple);
   stopLossLine.Create(0,"StopLoss",0,0);
   stopLossLine.Color(clrRed);
   takeProfitLine.Create(0,"TakeProfit",0,0);
   takeProfitLine.Color(clrBlue);
   trade.SetExpertMagicNumber(123456);
   trade.SetDeviationInPoints(10);
   trade.SetTypeFilling(ORDER_FILLING_RETURN);
   boomerangHandle = iCustom(Symbol(),Period(),"Boomerang");
   volatilityHandle = iCustom(Symbol(),Period(),"VolatilityOscillator");
   hullHandle = iCustom(Symbol(),Period(),"HMA", hullPeriod);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
   if (boomerangHandle != INVALID_HANDLE) IndicatorRelease(boomerangHandle);
   if (hullHandle != INVALID_HANDLE) IndicatorRelease(hullHandle);
   if (volatilityHandle != INVALID_HANDLE) IndicatorRelease(volatilityHandle);
}

...

void createHMA(int count) {
   ArraySetAsSeries(hull, true);
   CopyBuffer(hullHandle,0,0,count,hull);
}

...

The problem is that no matter what value I pass in for the period, I keep getting data for the 200 (default) average. I looked online at the iCustom documentation and I think I'm calling it correctly. What am I doing wrong? I'm using mql5.

Vladimir Karputov
Moderator
305936
Submit (use button Attach file) indicator and advisor files.
jeremiahcooper1212
9
jeremiahcooper1212  
nnemes:

I wrote a custom indicator that looks like this:

It has a single input called period which determines the period of the moving average. Default is 200. I also have an expert advisor that is calling this indicator like this:

The problem is that no matter what value I pass in for the period, I keep getting data for the 200 (default) average. I looked online at the iCustom documentation and I think I'm calling it correctly. What am I doing wrong? I'm using mql5.

I am having the same problem. In the tester journal it reports the correct input values : "variable=x". But it doesnt actually use them after the indicators are loaded. It almost seems as if the default values are overriding what is in the input tab. Its doing it on EVERY indicator including the included indicators in the Examples folder. So frustrating. I'm thinking of doing a clean reinstall. 

Build 3326

William Roeder
27830
William Roeder  
jeremiahcooper1212 #: I'm thinking of doing a clean reinstall.  Build 3326

Perhaps with a non-beta-build 3320

jeremiahcooper1212
9
jeremiahcooper1212  

I tried several reinstalls: MT5 always updates to version 3325 even when using an old installer. It will not install without internet.

I can't find any standalone versions of 3320 online.

Also, I realized I was using a metaquotes account and was connecting to their servers so I started using an OANDA account and it still auto updates to 3326.

I will have to try again later today when I have time

Fernando Carreiro
10836
jeremiahcooper1212 #: I tried several reinstalls: MT5 always updates to version 3325 even when using an old installer. It will not install without internet. I can't find any standalone versions of 3320 online. Also, I realized I was using a metaquotes account and was connecting to their servers so I started using an OANDA account and it still auto updates to 3326. I will have to try again later today when I have time
jeremiahcooper1212
9
jeremiahcooper1212  
Fernando Carreiro #:

Yes!!!! Thank you. Very useful. Actually, its almost mandatory if you want to use MT in any serious capacity

Bernhard Stremayr
4362
Bernhard Stremayr  
Hi, I just want to confirm that I have the same issue (Tester always uses default settings for custom indicators) wit MT5 Build 3326 (15 June 2022). Hopefully there will be a fix soon!
Fernando Carreiro
10836
Bernhard Stremayr #: Hi, I just want to confirm that I have the same issue (Tester always uses default settings for custom indicators) wit MT5 Build 3326 (15 June 2022). Hopefully there will be a fix soon!

Don't use build 3326. It's a "beta" build. Revert back to the official build 3320.

nnemes
18
nnemes  
Correct! Tester always uses default values. Also I don't see a build 3326 in the list of saved installers. Whatever I download from the official metatrader page always upgrades to 3326
nnemes
18
nnemes  
OMG! There's a new update out 3331. That one works fine!