Questions from Beginners MQL5 MT5 MetaTrader 5 - page 614

 
newnek:

Hello, could you please tell meif I need parameter Parameter=Ka,int,21 in the signal of the standard library?

Selected in the process of optimization from the enumeration of the type

But, when the signal disappears from selection when generating EA, but it's compiling normally, it's hard to make conclusions - what's wrong ......, help with code, wasn't there already an implementation?

p.s. I have to change int to intTypeevery time in the final EA

Specify exact signal module file and line of code...
 
Karputov Vladimir:
Specify the exact signal module file and code line...

For example, here is part of the top code SignalRVI.mqh. In this case, it disappears from signal selection when I change int type to intType

If the scope is wrong, I put it in a separate file with enumeration #include <Libraries\myfunc.mqh>
//+------------------------------------------------------------------+
//|                                                    SignalRVI.mqh |
//|                   Copyright 2009-2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#include <Expert\ExpertSignal.mqh>
// wizard description start
//+------------------------------------------------------------------+
//| Description of the class                                         |
//| Title=----------------Signals of oscillator 'Relative Vigor Index'               |
//| Type=SignalAdvanced                                              |
//| Name=Relative Vigor Index                                        |
//| ShortName=RVI                                                    |
//| Class=CSignalRVI                                                 |
//| Page=signal_rvi                                                  |
//| Parameter=PeriodRVI,intType,15,Period of calculation                 |
//+------------------------------------------------------------------+
// wizard description end
//+------------------------------------------------------------------+
//| Class CSignalRVI.                                                |
//| Purpose: Class of generator of trade signals based on            |
//|          the 'Relative Vigor Index' oscillator.                  |
//| Is derived from the CExpertSignal class.                         |
//+------------------------------------------------------------------+
enum intType
  {
   p0 = 15, 
   p1 = 21, 
   p2 = 29 
}
;
class CSignalRVI : public CExpertSignal
  {
protected:
   CiRVI             m_rvi;            // object-oscillator
   //--- adjusted parameters
   intType               m_periodRVI;      // the "period of calculation" parameter of the oscillator
   //--- "weights" of market models (0-100)
   int               m_pattern_0;      // model 0 "the oscillator has required direction"
   int               m_pattern_1;      // model 1 "crossing of main and signal line"

public:
                     CSignalRVI(void);
                    ~CSignalRVI(void);
   //--- methods of setting adjustable parameters
   void              PeriodRVI(intType value)            { m_periodRVI=value;                 }
   //--- methods of adjusting "weights" of market models
   void              Pattern_0(int value)            { m_pattern_0=value;                 }
   void              Pattern_1(int value)            { m_pattern_1=value;                 }
   //--- method of verification of settings
   virtual bool      ValidationSettings(void);
   //--- method of creating the indicator and timeseries
   virtual bool      InitIndicators(CIndicators *indicators);
   //--- methods of checking if the market models are formed
   virtual int       LongCondition(void);
   virtual int       ShortCondition(void);

protected:
   //--- method of initialization of the oscillator
   bool              InitRVI(CIndicators *indicators);
   //--- methods of getting data
   double            Main(int ind)                   { return(m_rvi.Main(ind));           }
   double            DiffMain(int ind)               { return(Main(ind)-Main(ind+1));     }
   double            Signal(int ind)                 { return(m_rvi.Signal(ind));         }
   double            DiffSignal(int ind)             { return(Signal(ind)-Signal(ind+1)); }
   double            DiffMainSignal(int ind)         { return(Main(ind)-Signal(ind));     }
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CSignalRVI::CSignalRVI(void) : m_periodRVI(15),
                               m_pattern_0(60),
                               m_pattern_1(100)
  {
  }
 
newnek:

Hello, could you please tell meif I need parameter Parameter=Ka,int,21 in the signal of the standard library?

Selected in the process of optimization from the enumeration of the type

But, when the signal disappears from selection when generating EA, but it's compiling normally, it's hard to make conclusions - what's wrong ......, help with code, wasn't there already an implementation?

p.s. I have to change int to intType every time in the final EA

You don't have to change anything - just generate your Expert Advisor based on the "Relative Vigor Index" indicator, then in the strategy tester, in the "Settings" tab select one of the optimizations, go to the "Parameters" tab and set the interval and value for the "Relative Vigor Index(10) Period of calculation" parameter:

RVI

But since you only want to use three values from the interval 15-29, you need to write a check condition in OnInit():

//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(Signal_RVI_PeriodRVI!=15 && Signal_RVI_PeriodRVI!=21 && Signal_RVI_PeriodRVI!=29)
      return(INIT_PARAMETERS_INCORRECT);
//--- Initializing expert

After running the optimization, you can see that the tester has worked only for parameters 15, 21 and 29:

Selective optimisation

 
Karputov Vladimir:

You don't have to change anything - just generate your Expert Advisor based on the "Relative Vigor Index" indicator, then select one of the optimizations in the Strategy Tester, go to the "Parameters" tab and set the interval and values for the "Relative Vigor Index(10) Period of calculation" parameter:


But since you only want to use three values from the interval 15-29, you need to write a check condition in OnInit():

After running the optimization, you can see that the tester has worked only for parameters 15, 21 and 29:

Thanks, I get your idea, very interesting, but there will be a lot of wasted steps (although probably no time wasted either). I have managed to manually change to enum type in generated EA. And I would like to automate it even more.
 
newnek:
Thanks, I get your idea, very interesting, but there will be a lot of wasted steps (although it probably won't waste time either). I have managed to manually change to enum type in the generated EA. And I would like to automate it even more.
There will be empty steps, but they don't take time, because OnInit() will be exited for non-compliance of condition and next step of optimization will be started immediately.
 

Good afternoon... A C++ programmer myself. I decided to try myself in this field recently... I want to write an Expert Advisor or an Expert Advisor, my strategy is OK, my platform is MT4... So, I'm facing this problem, I use in my Expert Advisor MACD.... I will write it shortly...

For example, I create a new template EA, add x=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); and let's say there is nothing else... I compile, test, everything is OK, at the end of the test, displays a macd chart with the specified parameters, everything is OK.

The second option - I create a new template EA in the OnTick, add a third-party indicator RSICur = iCustom(NULL,0, "My_Induk",14,1,0,21,1,65,35, "DodgerBlue", "Magenta",50,50, "Red", "Green",0,0); compile, test, all is OK, but!When I finish the test or cancel the test in the window of thousands of these indicators, I understand that on every tick a new indicator is created ... I don't understand why, because the standard MAKD is born once and that's it ...

Can someone please explain the problem... I am trying to explain the problem with the other non-standard indicators, but the same problem...

P.S. this is my first post... Please don't blame me for not finding a way to hide the photo under a spoiler.

Screenshot
 

I don't know what it's about but I found a solution...

RSICur=iCustom(NULL,0, "My_Induk",14,1,0,0,21,1,65,35, "DodgerBlue", "Magenta",50,50, "Red", "Green",0,0);- draws chart per tick

RSICur=iCustom(NULL,0, "My_Induk",0,0); - Ok, one chart, only data in theRSICur variable is updated per tick...What's the logic I don't understand, in principle it's enough for me, but I'd like to understand why it works fine only with default settings...

 
Игорь Марин:

Good afternoon... A C++ programmer myself. I decided to try myself in this field recently... I want to write an Expert Advisor or an Expert Advisor, my strategy is OK, my platform is MT4... So, I'm facing this problem, I use in my Expert Advisor MACD.... I will write it shortly...

For example, I create a new template EA, add x=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); and let's say there is nothing else... I compile, test, everything is OK, at the end of the test displays a macd chart with the specified parameters, everything is OK.

The second option - I create a new template EA in the OnTick, add a third-party indicator RSICur = iCustom(NULL,0, "My_Induk",14,1,0,21,1,65,35, "DodgerBlue", "Magenta",50,50, "Red", "Green",0,0); compile, test, all is OK, but!When I finish the test or cancel the test in the window of thousands of these indicators, I understand that on every tick a new indicator is created ... I don't understand why, because the standard MAKD is born once and that's it ...

Can someone please explain the problem... I am trying to explain the problem with the other non-standard indicators...

P.S. this is my first post... Please do not scold me for not finding a way to hide the photo under the spoiler.

The photo is OK, it's not hidden.

Did you write this My_Induk or did you find it somewhere? I understand the indicator is crooked. If you have the source code, post it - let's see what the problem is.

 
Игорь Марин:

I don't know what it's about but I found a solution...

RSICur=iCustom(NULL,0, "My_Induk",14,1,0,0,21,1,65,35, "DodgerBlue", "Magenta",50,50, "Red", "Green",0,0);- draws chart per tick

RSICur=iCustom(NULL,0, "My_Induk",0,0); - Ok, one chart, only data in theRSICur variable is updated per tick...What's the logic I don't understand, in principle it's enough for me, but I'd like to understand why it works fine only with default settings...

This happens when you have not correctly passed the parameters of the indicator.
 
Alexey Volchanskiy:

The photo is OK, there's no hiding here.

Did you write this My_Induk or did you find it somewhere? I take it the indicator is crooked. If you have the source code, post it - let's see what the problem is.

Vladislav Andruschenko:
This happens when you have not properly passed the parameters of the indicator.

Thank you. I figured it out... I've been poking around all day and couldn't figure it out... I'm a programmer myself, but it happens... I made a syntax error, I had to pass the colour parameters in quotes when calling the indicator...

iCustom(NULL,0,"My_Induk",14,1,0,21,1,65,35,"DodgerBlue","Magenta",50,50,"Red","Green",0,0);

that's what caused this malfunction... ) Thank you!!! Surely there will be more questions!!!

Reason: