Please help me
Firstly, does the compiled indicator work on a chart?
Did you use the #resource directive to embed the indicator - other than that, its likely related to the indicator parameters in iCustom() - something missing perhaps, it can be very fussy.
Firstly, does the compiled indicator work on a chart?
Did you use the #resource directive to embed the indicator - other than that, its likely related to the indicator parameters in iCustom() - something missing perhaps, it can be very fussy.
Yes the indicator was compiled and works on a chart
Yes I use #resource directive.
#property copyright "" #property link "" #property version "1.0" #property strict #include <Trade\Trade.mqh> #include <Trade\PositionInfo.mqh> #include <Trade\OrderInfo.mqh> #include <Canvas\Canvas.mqh> #include <stdlib.mqh> #resource "\\Indicators\\TDI.ex5"
Then it is likely related to the paramaters of the iCustom() calls - I suggest that you comment out all but the first iCustom() call - easier to find where the problem is.
Could you post the set file, or a screenshot of it?
Then it is likely related to the paramaters of the iCustom() calls - I suggest that you comment out all but the first iCustom() call - easier to find where the problem is.
Could you post the set file, or a screenshot of it?
Like that ? I did it but the same result
int OnInit() { ... TDI_Handle_TF_1 = iCustom(Symbol(), TF_1, "::Indicators\\TDI.ex5", "", RSI_Period, RSI_Price, Volatility_Band, StdDev, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, UpperTimeframe, "", false, false, false, false, false, false); TDI_Handle_TF_2 = iCustom(Symbol(), TF_2, "::Indicators\\TDI.ex5", "", RSI_Period, RSI_Price, Volatility_Band, StdDev, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, UpperTimeframe, "", false, false, false, false, false, false); if(TDI_Handle_TF_2==INVALID_HANDLE) { Print("Expert: iCustom call: Error code_TDI_Handle_TF_2=",GetLastError()); return(INIT_FAILED); } TDI_Handle_TF_3 = iCustom(Symbol(), TF_3, "::Indicators\\TDI.ex5", "", RSI_Period, RSI_Price, Volatility_Band, StdDev, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, UpperTimeframe, "", false, false, false, false, false, false); if(TDI_Handle_TF_3==INVALID_HANDLE) { Print("Expert: iCustom call: Error code_TDI_Handle_TF_3=",GetLastError()); return(INIT_FAILED); } TDI_Handle_TF_4 = iCustom(Symbol(), TF_4, "::Indicators\\TDI.ex5", "", RSI_Period, RSI_Price, Volatility_Band, StdDev, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, UpperTimeframe, "", false, false, false, false, false, false); if(TDI_Handle_TF_4==INVALID_HANDLE) { Print("Expert: iCustom call: Error code_TDI_Handle_TF_4=",GetLastError()); return(INIT_FAILED); } TDI_Handle_TF_Dashboard = iCustom(Symbol(), TF_Dashboard_Only, "::Indicators\\TDI.ex5", "", RSI_Period, RSI_Price, Volatility_Band, StdDev, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, UpperTimeframe, "", false, false, false, false, false, false); if(TDI_Handle_TF_Dashboard==INVALID_HANDLE) { Print("Expert: iCustom call: Error code_TDI_Handle_TF_Dashboard=",GetLastError()); return(INIT_FAILED); } // OnTick(); Comment(""); // clear the chart return(INIT_SUCCEEDED); }
Error 4002 refers to incorrect parameter information. Speculating: it is possible that the indicator has parameter groups (input group) and you are not considering them.
Error 4002 refers to incorrect parameter information. Speculating: it is possible that the indicator has parameter groups (input group) and you are not considering them.
I would like to point out again that the .ex5 file of the robot that my colleague sent works with the same indicator and settings.
The problem occurs when I compile the .mq5 file after adding the additional buy and sell conditions.
Then the resulting .ex5 file refuses to work and displays the backtest errors I mentioned above.
No, like that :
POST the indicator OR a SET file showing the parameters if you need useful help !
I tried this method for all timeframe TF_1 to TF_Dashboard. The errors no longer appear, but the bot only takes about 10% of the positions as its MT4 version on the same pair with the same trade entry conditions.
No, like that :
POST the indicator OR a SET file showing the parameters if you need useful help !
This is the indicator (trader dynamic index) script. Wasn't be able to upload the mq5 or the txt file
//+------------------------------------------------------------------+ //|Based on TradersDynamicIndex.mq4 by Dean Malone | //| TradersDynamicIndex.mq5 | //| Copyright © 2015-2018, EarnForex.com | //| https://www.earnforex.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2015-2018, www.EarnForex.com" #property link "https://www.earnforex.com/metatrader-indicators/Traders-Dynamic-Index/" #property version "1.02" #property description "Shows trend direction, strength, and volatility." #property description "Green line - RSI Price line." #property description "Red line - Trade Signal line." #property description "Blue lines - Volatility Band." #property description "Yellow line - Market Base line." #property indicator_separate_window #property indicator_buffers 6 #property indicator_plots 5 #property indicator_level2 50 #property indicator_levelcolor clrRed #property indicator_levelstyle STYLE_DOT #property indicator_levelwidth 1 #property indicator_color1 clrWhite #property indicator_label1 "VB High" #property indicator_type1 DRAW_LINE #property indicator_width1 2 #property indicator_style1 STYLE_SOLID #property indicator_color2 clrWhite #property indicator_label2 "Market Base Line" #property indicator_type2 DRAW_LINE #property indicator_width2 2 #property indicator_style2 STYLE_SOLID #property indicator_color3 clrWhite #property indicator_label3 "VB Low" #property indicator_type3 DRAW_LINE #property indicator_width3 2 #property indicator_style3 STYLE_SOLID #property indicator_color4 clrMediumSeaGreen #property indicator_label4 "RSI Price Line" #property indicator_type4 DRAW_LINE #property indicator_width4 2 #property indicator_style4 STYLE_SOLID #property indicator_color5 clrRed #property indicator_label5 "Trade Signal Line" #property indicator_type5 DRAW_LINE #property indicator_width5 1 #property indicator_style5 STYLE_SOLID input int RSI_Period = 21; // RSI_Period: 8-25 input ENUM_APPLIED_PRICE RSI_Price = PRICE_CLOSE; input int Volatility_Band = 34; // Volatility_Band: 20-40 input double StdDev = 1.6185; // Standard Deviations: 1-3 input int RSI_Price_Line = 4; input ENUM_MA_METHOD RSI_Price_Type = MODE_SMA; input int Trade_Signal_Line = 7; input ENUM_MA_METHOD Trade_Signal_Type = MODE_SMA; input bool UseAlerts = false; double RSIBuf[], UpZone[], MdZone[], DnZone[], MaBuf[], MbBuf[]; int MaxPeriod = 0; int AlertPlayedonBar = 0; int RSI_handle; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { IndicatorSetString(INDICATOR_SHORTNAME, "TDI(" + IntegerToString(RSI_Period) + "," + IntegerToString(Volatility_Band) + "," + IntegerToString(RSI_Price_Line) + "," + IntegerToString(Trade_Signal_Line) + ")"); SetIndexBuffer(0, UpZone, INDICATOR_DATA); SetIndexBuffer(1, MdZone, INDICATOR_DATA); SetIndexBuffer(2, DnZone, INDICATOR_DATA); SetIndexBuffer(3, MaBuf, INDICATOR_DATA); SetIndexBuffer(4, MbBuf, INDICATOR_DATA); SetIndexBuffer(5, RSIBuf, INDICATOR_CALCULATIONS); ArraySetAsSeries(UpZone, true); ArraySetAsSeries(MdZone, true); ArraySetAsSeries(DnZone, true); ArraySetAsSeries(MaBuf, true); ArraySetAsSeries(MbBuf, true); ArraySetAsSeries(RSIBuf, true); PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0); PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0); PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, 0); PlotIndexSetDouble(3, PLOT_EMPTY_VALUE, 0); PlotIndexSetDouble(4, PLOT_EMPTY_VALUE, 0); IndicatorSetInteger(INDICATOR_DIGITS, Digits()); RSI_handle = iRSI(Symbol(), Period(), RSI_Period, RSI_Price); MaxPeriod = Volatility_Band + RSI_Period; PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, MaxPeriod); PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, MaxPeriod); PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, MaxPeriod); PlotIndexSetInteger(3, PLOT_DRAW_BEGIN, MaxPeriod + RSI_Price_Line); PlotIndexSetInteger(4, PLOT_DRAW_BEGIN, MaxPeriod + Trade_Signal_Line); } //+------------------------------------------------------------------+ //| Traders Dynamic Index | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double& price[] ) { double MA, RSI[]; ArrayResize(RSI, Volatility_Band); int i; int counted_bars = prev_calculated; // Too few bars to work with. if (rates_total < MaxPeriod) return(0); i = rates_total - counted_bars; if (i > rates_total - MaxPeriod - 1) i = rates_total - MaxPeriod - 1; int RSI_bars = CopyBuffer(RSI_handle, 0, 0, rates_total, RSIBuf); if (RSI_bars == -1) return(0); // Calculate BB on RSI. while (i >= 0) { MA = 0; for (int x = i; x < i + Volatility_Band; x++) { RSI[x - i] = RSIBuf[x]; MA += RSIBuf[x] / Volatility_Band; } double SD = StdDev * StDev(RSI, Volatility_Band); UpZone[i] = MA + SD; DnZone[i] = MA - SD; MdZone[i] = (UpZone[i] + DnZone[i]) / 2; i--; } i = rates_total - counted_bars; if (i > rates_total - MaxPeriod - 1) i = rates_total - MaxPeriod - 1; // Calculate MAs of RSI. while (i >= 0) { MaBuf[i] = iMAOnArray(RSIBuf, 0, RSI_Price_Line, 0, RSI_Price_Type, i); MbBuf[i] = iMAOnArray(RSIBuf, 0, Trade_Signal_Line, 0, Trade_Signal_Type, i); i--; } if ((MbBuf[0] > MdZone[0]) && (MbBuf[1] <= MdZone[1]) && (UseAlerts == true) && (AlertPlayedonBar != 0)) { Alert("Bullish cross"); PlaySound("alert.wav"); AlertPlayedonBar = rates_total; } if ((MbBuf[0] < MdZone[0]) && (MbBuf[1] >= MdZone[1]) && (UseAlerts == true) && (AlertPlayedonBar != 0)) { Alert("Bearish cross"); PlaySound("alert.wav"); AlertPlayedonBar = rates_total; } return(rates_total); } // Standard Deviation function. double StDev(double& Data[], int Per) { return(MathSqrt(Variance(Data, Per))); } // Math Variance function. double Variance(double& Data[], int Per) { double sum = 0, ssum = 0; for (int i = 0; i < Per; i++) { sum += Data[i]; ssum += MathPow(Data[i], 2); } return((ssum * Per - sum * sum) / (Per * (Per - 1))); } //+------------------------------------------------------------------+ //| Based on http://www.mql5.com/en/articles/81 | //| Simplified SMA calculation. | //+------------------------------------------------------------------+ double iMAOnArray(double &Array[], int total, int iMAPeriod, int ma_shift, ENUM_MA_METHOD ma_method, int Shift) { double buf[]; if ((total > 0) && (total <= iMAPeriod)) return(0); if (total == 0) total = ArraySize(Array); if (ArrayResize(buf, total) < 0) return(0); switch(ma_method) { // Simplified SMA. No longer works with ma_shift parameter. case MODE_SMA: { double sum = 0; for (int i = Shift; i < Shift + iMAPeriod; i++) sum += Array[i] / iMAPeriod; return(sum); } case MODE_EMA: { double pr = 2.0 / (iMAPeriod + 1); int pos = total - 2; while (pos >= 0) { if (pos == total - 2) buf[pos + 1] = Array[pos + 1]; buf[pos] = Array[pos] * pr + buf[pos + 1] * (1 - pr); pos--; } return(buf[Shift + ma_shift]); } case MODE_SMMA: { double sum = 0; int i, k, pos; pos = total - iMAPeriod; while (pos >= 0) { if (pos == total - iMAPeriod) { for (i = 0, k = pos; i < iMAPeriod; i++, k++) { sum += Array[k]; buf[k] = 0; } } else sum = buf[pos + 1] * (iMAPeriod - 1) + Array[pos]; buf[pos] = sum / iMAPeriod; pos--; } return(buf[Shift + ma_shift]); } case MODE_LWMA: { double sum = 0.0, lsum = 0.0; double price; int i, weight = 0, pos = total - 1; for (i = 1; i <= iMAPeriod; i++, pos--) { price = Array[pos]; sum += price * i; lsum += price; weight += i; } pos++; i = pos + iMAPeriod; while (pos >= 0) { buf[pos] = sum / weight; if (pos == 0) break; pos--; i--; price = Array[pos]; sum = sum - lsum + price * iMAPeriod; lsum -= Array[i]; lsum += price; } return(buf[Shift + ma_shift]); } default: return(0); } return(0); } //+------------------------------------------------------------------+
See the documentation for the iCustom() function:
int iCustom( string symbol, // symbol name ENUM_TIMEFRAMES period, // period string name // folder/custom_indicator_name ... // list of indicator input parameters );
Now look at the input parameters of your indicator:
input int RSI_Period = 21; // RSI_Period: 8-25 input ENUM_APPLIED_PRICE RSI_Price = PRICE_CLOSE; input int Volatility_Band = 34; // Volatility_Band: 20-40 input double StdDev = 1.6185; // Standard Deviations: 1-3 input int RSI_Price_Line = 4; input ENUM_MA_METHOD RSI_Price_Type = MODE_SMA; input int Trade_Signal_Line = 7; input ENUM_MA_METHOD Trade_Signal_Type = MODE_SMA; input bool UseAlerts = false;
Your indicator call should look something like this (total of 9 parameters):
int iCustom( string symbol, // symbol name ENUM_TIMEFRAMES period, // period string name, // folder/custom_indicator_name int RSI_Period, // RSI_Period: 8-25 ENUM_APPLIED_PRICE RSI_Price, int Volatility_Band, // Volatility_Band: 20-40 double StdDev, // Standard Deviations: 1-3 int RSI_Price_Line, ENUM_MA_METHOD RSI_Price_Type, int Trade_Signal_Line, ENUM_MA_METHOD Trade_Signal_Type, bool UseAlerts );
But you are passing an excessive amount of parameters... You need to fix it.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please help me.