Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1143

 

Hello.

Can you please tell me if there is any ready-made solution for backtesting by news?

 

Can you tell me what's wrong?

double lostProfit(ulong ticket)
{
   Print("****** "+__FUNCTION__+"******");
   if(HistoryOrderSelect(ticket))
   {
      ulong pos_ID = HistoryOrderGetInteger(ticket,ORDER_POSITION_ID);
      if(my_History.SelectByIndex(pos_ID)) // possible loss of data due to type conversion
      {
         Print("****** "+string(equity_plus[arr_size-1] - my_History.TakeProfit())+" ******");
         return(equity_plus[arr_size-1] - my_History.TakeProfit());
      }
      else Print("--- Не выбрана позиция по ID "+string(pos_ID));
   }
   else Print("--- Не выбран ордер по тикету "+string(ticket));
   
   return(0.0);
}
Позиция с магиком 2810292634423737, тикетом 2 и лотом 0.1 успешно закрыта.
****** lostProfit******
--- Не выбрана позиция по ID 2

How do I know the profit of a closed position on a ticket?
 
Сергей Таболин:

Can you tell me what's wrong?


How do I know the profit of a closed position on a ticket?

Select all trades in the ticketed position and add up the trade's profit, commission and swap.

Документация по MQL5: Торговые функции / HistorySelectByPosition
Документация по MQL5: Торговые функции / HistorySelectByPosition
  • www.mql5.com
Не следует путать между собой ордера из торговой истории и действующие отложенные ордера, которые отображаются на вкладке "Торговля" в панели "Инструменты". Список ордеров, которые были отменены или привели к проведению торговой операции, можно посмотреть  в закладке "История" на панели "Инструменты" клиентского терминала. Функция...
 

Hello!

For myself, I already realized that programming is not mine, but I managed to make friends with the MQL5 Master. However, when compiling some modules of trading signals, warnings appear. How critical are these warnings, and if not difficult, then tell me what needs to be corrected in the code of the trading signals module in order to eliminate the warnings shown in the picture.

With best regards, Vladimir.

Trading signals module code

 //+------------------------------------------------------------------+
//|                                                 SampleSignal.mqh |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
//+------------------------------------------------------------------+
//| включаемые файлы                                                 |
//+------------------------------------------------------------------+
#include <Expert\ExpertSignal.mqh>
// wizard description start
//+------------------------------------------------------------------+
//| Description of the class                                         |
//| Title=Сигнал по пересечению ценой скользящей средней             |
//| со входом на последующем откате                                  |
//| Type=SignalAdvanced                                              |
//| Name=Sample                                                      |
//| Class=CSampleSignal                                              |
//| Page=                                                            |
//| Parameter=PeriodMA,int,12                                        |
//| Parameter=ShiftMA,int,6                                          |
//| Parameter=MethodMA,ENUM_MA_METHOD,MODE_EMA                       |
//| Parameter=AppliedMA,ENUM_APPLIED_PRICE,PRICE_CLOSE               |
//| Parameter=Limit,double,0.0                                       |
//| Parameter=StopLoss,double,50.0                                   |
//| Parameter=TakeProfit,double,50.0                                 |
//| Parameter=Expiration,int,10                                      |
//+------------------------------------------------------------------+
// wizard description end
//+------------------------------------------------------------------+
//| Класс CSampleSignal.                                             |
//| Назначение: Класс генератора торговых сигналов по пересечению    |
//|             ценой скользящей средней                             |
//|             со входом на последующем откате.                     |
//|             Является производным от класса CExpertSignal.        |
//+------------------------------------------------------------------+
class CSampleSignal : public CExpertSignal
  {
protected :
   CiMA               m_MA;                       // объект для доступа к значениям скользящей средней
   CiOpen             m_open;                     // объект для доступа к ценам открытия баров
   CiClose            m_close;                   // объект для доступа к ценам закрытия баров
   //--- параметры настройки
   int                 m_period_ma;               // период усреднения средней скользящей
   int                 m_shift_ma;                 // смещение средней скользящей по оси времени
   ENUM_MA_METHOD      m_method_ma;               // метод усреднения средней скользящей
   ENUM_APPLIED_PRICE m_applied_ma;               // объект усреднения средней скользящей
   double              m_limit;                   // уровень установки отложенного ордера относительно средней скользящей
   double              m_stop_loss;               // уровень установки ордера "stop loss" относительно цены открытия
   double              m_take_profit;             // уровень установки ордера "take profit" относительно цены открытия
   int                 m_expiration;               // время "жизни" отложенного ордера в барах

public :
                      CSampleSignal();
   //--- методы установки параметров настройки
   void                PeriodMA( int value)                 { m_period_ma=value;              }
   void                ShiftMA( int value)                  { m_shift_ma=value;               }
   void                MethodMA( ENUM_MA_METHOD value)      { m_method_ma=value;              }
   void                AppliedMA( ENUM_APPLIED_PRICE value) { m_applied_ma=value;             }
   void                Limit( double value)                 { m_limit=value;                  }
   void                StopLoss( double value)              { m_stop_loss=value;              }
   void                TakeProfit( double value)            { m_take_profit=value;            }
   void                Expiration( int value)               { m_expiration=value;             }
   //--- метод проверки параметров настройки
   virtual bool        ValidationSettings();
   //--- метод проверки параметров настройки
   virtual bool        InitIndicators(CIndicators* indicators);
   //--- методы генерации сигналов входа в рынок
   virtual bool        CheckOpenLong( double & price, double & sl, double & tp, datetime & expiration);
   virtual bool        CheckOpenShort( double & price, double & sl, double & tp, datetime & expiration);
   //--- методы генерации сигналов модификации отложенных ордеров
   virtual bool        CheckTrailingOrderLong(COrderInfo* order, double & price);
   virtual bool        CheckTrailingOrderShort(COrderInfo* order, double & price);

protected :
   //--- метод инициализации объектов
   bool                InitMA(CIndicators* indicators);
   bool                InitOpen(CIndicators* indicators);
   bool                InitClose(CIndicators* indicators);
   //--- методы доступа к данным объектов
   double              MA( int index)                       { return (m_MA.Main(index));       }
   double              Open( int index)                     { return (m_open.GetData(index));  }
   double              Close( int index)                    { return (m_close.GetData(index)); }
  };
//+------------------------------------------------------------------+
//| Конструктор CSampleSignal.                                       |
//| INPUT:  нет.                                                     |
//| OUTPUT: нет.                                                     |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
void CSampleSignal::CSampleSignal()
  {
//--- установка значений по-умолчанию
   m_period_ma  = 12 ;
   m_shift_ma   = 6 ;
   m_method_ma  = MODE_EMA ;
   m_applied_ma = PRICE_CLOSE ;
   m_limit      = 0.0 ;
   m_stop_loss  = 50.0 ;
   m_take_profit= 50.0 ;
   m_expiration = 10 ;
  }
//+------------------------------------------------------------------+
//| Проверка параметров настройки.                                   |
//| INPUT:  нет.                                                     |
//| OUTPUT: true-если настройки правильные, иначе false.             |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::ValidationSettings()
  {
//--- проверка параметров
   if (m_period_ma<= 0 )
     {
       printf ( __FUNCTION__ + ": период скользящей средней должен быть больше нуля" );
       return ( false );
     }
//--- успешное завершение
   return ( true );
  }
//+------------------------------------------------------------------+
//| Инициализация индикаторов и таймсерий.                           |
//| INPUT:  indicators - указатель на объект-коллекцию               |
//|                      индикаторов и таймсерий.                    |
//| OUTPUT: true-в случае успешного завершения, иначе false.         |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::InitIndicators(CIndicators* indicators)
  {
//--- проверка указателя
   if (indicators== NULL )       return ( false );
//--- инициализация скользящей средней
   if (!InitMA(indicators))     return ( false );
//--- инициализация таймсерии цен открытия
   if (!InitOpen(indicators))   return ( false );
//--- инициализация таймсерии цен закрытия
   if (!InitClose(indicators)) return ( false );
//--- успешное завершение
   return ( true );
  }
//+------------------------------------------------------------------+
//| Инициализация скользящей средней.                                |
//| INPUT:  indicators - указатель на объект-коллекцию               |
//|                      индикаторов и таймсерий.                    |
//| OUTPUT: true-в случае успешного завершения, иначе false.         |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::InitMA(CIndicators* indicators)
  {
//--- инициализация объекта скользящей средней
   if (!m_MA.Create(m_symbol.Name(),m_period,m_period_ma,m_shift_ma,m_method_ma,m_applied_ma))
     {
       printf ( __FUNCTION__ + ": ошибка инициализации объекта" );
       return ( false );
     }
   m_MA.BufferResize( 3 +m_shift_ma);
//--- добавление объекта в коллекцию
   if (!indicators.Add( GetPointer (m_MA)))
     {
       printf ( __FUNCTION__ + ": ошибка добавления объекта" );
       return ( false );
     }
//--- успешное завершение
   return ( true );
  }
//+------------------------------------------------------------------+
//| Инициализация таймсерии цен открытия.                            |
//| INPUT:  indicators - указатель на объект-коллекцию               |
//|                      индикаторов и таймсерий.                    |
//| OUTPUT: true-в случае успешного завершения, иначе false.         |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::InitOpen(CIndicators* indicators)
  {
//--- инициализация объекта таймсерии
   if (!m_open.Create(m_symbol.Name(),m_period))
     {
       printf ( __FUNCTION__ + ": ошибка инициализации объекта" );
       return ( false );
     }
//--- добавление объекта в коллекцию
   if (!indicators.Add( GetPointer (m_open)))
     {
       printf ( __FUNCTION__ + ": ошибка добавления объекта" );
       return ( false );
     }
//--- успешное завершение
   return ( true );
  }
//+------------------------------------------------------------------+
//| Инициализация таймсерии цен закрытия.                            |
//| INPUT:  indicators - указатель на объект-коллекцию               |
//|                      индикаторов и таймсерий.                    |
//| OUTPUT: true-в случае успешного завершения, иначе false.         |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::InitClose(CIndicators* indicators)
  {
//--- инициализация объекта таймсерии
   if (!m_close.Create(m_symbol.Name(),m_period))
     {
       printf ( __FUNCTION__ + ": ошибка инициализации объекта" );
       return ( false );
     }
//--- добавление объекта в коллекцию
   if (!indicators.Add( GetPointer (m_close)))
     {
       printf ( __FUNCTION__ + ": ошибка добавления объекта" );
       return ( false );
     }
//--- успешное завершение
   return ( true );
  }
//+------------------------------------------------------------------+
//| Проверка выполнения условия для покупки.                         |
//| INPUT:  price      - ссылка для размещения цены открытия,        |
//|         sl         - ссылка для размещения цены stop loss,       |
//|         tp         - ссылка для размещения цены take profit,     |
//|         expiration - ссылка для размещения времени истечения.    |
//| OUTPUT: true-если условие выполнено, иначе false.                |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::CheckOpenLong( double & price, double & sl, double & tp, datetime & expiration)
  {
//--- подготовка данных
   double spread=m_symbol.Ask()-m_symbol.Bid();
   double ma    =MA( 1 );
   double unit  =PriceLevelUnit();
//--- проверка условия
   if (Open( 1 )<ma && Close( 1 )>ma && ma>MA( 2 ))
     {
      price=m_symbol.NormalizePrice(m_symbol.Bid()+m_limit*unit);
      sl   =m_symbol.NormalizePrice(price-m_stop_loss*unit);
      tp   =m_symbol.NormalizePrice(price+m_take_profit*unit);
      expiration+=m_expiration* PeriodSeconds (m_period);
       //--- условие выполнено
       return ( true );
     }
//--- условие не выполнено
   return ( false );
  }
//+------------------------------------------------------------------+
//| Проверка выполнения условия для продажи.                         |
//| INPUT:  price      - ссылка для размещения цены открытия,        |
//|         sl         - ссылка для размещения цены stop loss,       |
//|         tp         - ссылка для размещения цены take profit,     |
//|         expiration - ссылка для размещения времени истечения.    |
//| OUTPUT: true-если условие выполнено, иначе false.                |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::CheckOpenShort( double & price, double & sl, double & tp, datetime & expiration)
  {
//--- подготовка данных
   double ma  =MA( 1 );
   double unit=PriceLevelUnit();
//--- проверка условия
   if (Open( 1 )>ma && Close( 1 )<ma && ma<MA( 2 ))
     {
      price=m_symbol.NormalizePrice(m_symbol.Bid()+m_limit*unit);
      sl   =m_symbol.NormalizePrice(price+m_stop_loss*unit);
      tp   =m_symbol.NormalizePrice(price-m_take_profit*unit);
      expiration+=m_expiration* PeriodSeconds (m_period);
       //--- условие выполнено
       return ( true );
     }
//--- условие не выполнено
   return ( false );
  }
//+------------------------------------------------------------------+
//| Проверка выполнения условия для модификации ордера на покупку.   |
//| INPUT:  order - указатель на объект-ордер,                       |
//|         price - ссылка для размещения новой цены открытия.       |
//| OUTPUT: true-если условие выполнено, иначе false.                |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::CheckTrailingOrderLong(COrderInfo* order, double & price)
  {
//--- проверка указателя
   if (order== NULL ) return ( false );
//--- подготовка данных
   double spread   =m_symbol.Ask()-m_symbol.Bid();
   double ma       =MA( 1 );
   double unit     =PriceLevelUnit();
   double new_price=m_symbol.NormalizePrice(ma-m_limit*unit+spread);
//--- проверка условия
   if (order.PriceOpen()==new_price) return ( false );
   price=new_price;
//--- условие выполнено
   return ( true );
  }
//+------------------------------------------------------------------+
//| Проверка выполнения условия для модификации ордера на продажу.   |
//| INPUT:  order - указатель на объект-ордер,                       |
//|         price - ссылка для размещения новой цены открытия.       |
//| OUTPUT: true-если условие выполнено, иначе false.                |
//| REMARK: нет.                                                     |
//+------------------------------------------------------------------+
bool CSampleSignal::CheckTrailingOrderShort(COrderInfo* order, double & price)
  {
//--- проверка указателя
   if (order== NULL ) return ( false );
//--- подготовка данных
   double ma  =MA( 1 );
   double unit=PriceLevelUnit();
   double new_price=m_symbol.NormalizePrice(ma+m_limit*unit);
//--- проверка условия
   if (order.PriceOpen()==new_price) return ( false );
   price=new_price;
//--- условие выполнено
   return ( true );
  }
//+------------------------------------------------------------------+
 
MrBrooklin:

Hello!

I have already understood that programming is not for me, but I have managed to make friends with the MQL5 Wizard. However, when compiling some modules of trading signals, I get warnings. How critical are these warnings and, if possible, please advise on what to change in the code of the trading signals module to avoid the warnings shown in the picture.

Best regards, Vladimir.

Trading Signal Module Code

The language is developing.

Make substitutions: (ctrl+h)

m_open -> m_open_sample

m_close -> m_close_sample

m_expiration -> m_expiration_sample

 
Vladimir Karputov:

The language is evolving.

Make substitutions: (ctrl+h)

m_open -> m_open_sample

m_close -> m_close_sample

m_expiration -> m_expiration_sample

Thank you, Vladimir, for your quick and clear answer. All warnings have been eliminated.

Sincerely, Vladimir.

 

Hello!

Please advise what you should correct in the code of the trading signals module to exclude the compiler warning in the line highlighted in yellow.

Best regards, Vladimir.

//+------------------------------------------------------------------+
//|                                             BykovTrendSignal.mqh |
//|                             Copyright © 2011,   Nikolay Kositsin | 
//|                              Khabarovsk,   farria@mail.redcom.ru | 
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Nikolay Kositsin"
#property link      "farria@mail.redcom.ru"
//+------------------------------------------------------------------+
//| Included files                                                   |
//+------------------------------------------------------------------+
#property tester_indicator "BykovTrend.ex5"
#include <Expert\ExpertSignal.mqh>
//--- wizard description start
//+------------------------------------------------------------------+ 
//|  Declaration of constants                                        |
//+------------------------------------------------------------------+ 
#define  OPEN_LONG     80  // The constant for returning the buy command to the Expert Advisor
#define  OPEN_SHORT    80  // The constant for returning the sell command to the Expert Advisor
#define  CLOSE_LONG    40  // The constant for returning the command to close a long position to the Expert Advisor
#define  CLOSE_SHORT   40  // The constant for returning the command to close a short position to the Expert Advisor
#define  REVERSE_LONG  100 // The constant for returning the command to reverse a long position to the Expert Advisor
#define  REVERSE_SHORT 100 // The constant for returning the command to reverse a short position to the Expert Advisor
#define  NO_SIGNAL      0  // The constant for returning the absence of a signal to the Expert Advisor
//+----------------------------------------------------------------------+
//| Description of the class                                             |
//| Title=The signals based on BykovTrend indicator                      |
//| Type=SignalAdvanced                                                  |
//| Name=BykovTrend                                                      |
//| Class=CBykovTrendSignal                                              |
//| Page=                                                                |
//| Parameter=BuyPosOpen,bool,true,Permission to buy                     |
//| Parameter=SellPosOpen,bool,true,Permission to sell                   |
//| Parameter=BuyPosClose,bool,true,Permission to exit a long position   |
//| Parameter=SellPosClose,bool,true,Permission to exit a short position |
//| Parameter=Ind_Timeframe,ENUM_TIMEFRAMES,PERIOD_H4,Timeframe          |
//| Parameter=RISK,int,4,Risk level                                      |
//| Parameter=SSP,int,9,SSP                                              |
//| Parameter=SignalBar,uint,1,Bar index for entry signal                |
//+----------------------------------------------------------------------+
//--- wizard description end
//+----------------------------------------------------------------------+
//| CBykovTrendSignal class.                                             |
//| Purpose: Class of generator of trade signals based on                |
//| BykovTrend indicator http://www.mql5.com/en/code/497/.&nbsp;              |
//|            Is derived from the CExpertSignal class.                  |
//+----------------------------------------------------------------------+
class CBykovTrendSignal : public CExpertSignal
  {
protected:
   CiCustom          m_indicator;        // the object for access to BykovTrend values

   //--- adjusted parameters
   bool              m_BuyPosOpen;       // permission to buy
   bool              m_SellPosOpen;      // permission to sell
   bool              m_BuyPosClose;      // permission to exit a long position
   bool              m_SellPosClose;     // permission to exit a short position
   
   ENUM_TIMEFRAMES   m_Ind_Timeframe;    // BykovTrend indicator timeframe
   uint              m_RISK;             // Risk level
   uint              m_SSP;              // SSP
   uint              m_SignalBar;        // bar index for getting entry signal

public:
                     CBykovTrendSignal();

   //--- methods of setting adjustable parameters
   void               BuyPosOpen(bool value)                  { m_BuyPosOpen=value;       }
   void               SellPosOpen(bool value)                 { m_SellPosOpen=value;      }
   void               BuyPosClose(bool value)                 { m_BuyPosClose=value;      }
   void               SellPosClose(bool value)                { m_SellPosClose=value;     }
   void               Ind_Timeframe(ENUM_TIMEFRAMES value)    { m_Ind_Timeframe=value;    }
   void               RISK(uint value)                        { m_RISK=value;             }
   void               SSP(uint value)                         { m_SSP=value;              }
   void               SignalBar(uint value)                   { m_SignalBar=value;        }

   //--- adjustable parameters validation method
   virtual bool      ValidationSettings();
   //--- adjustable parameters validation method
   virtual bool      InitIndicators(CIndicators *indicators); // indicators initialization
   //--- market entry signals generation method
   virtual int       LongCondition();
   virtual int       ShortCondition();

   bool              InitBykovTrend(CIndicators *indicators);   // BykovTrend indicator initializing method
  };
//+------------------------------------------------------------------+
//| CBykovTrendSignal constructor.                                   |
//| INPUT:  no.                                                      |
//| OUTPUT: no.                                                      |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
void CBykovTrendSignal::CBykovTrendSignal()
  {
//--- setting default values
   m_BuyPosOpen=true;

//--- indicator input parameters   
   m_SellPosOpen=true;
   m_BuyPosClose=true;
   m_SellPosClose=true;
   m_Ind_Timeframe=PERIOD_H4;
   m_RISK=4;
   m_SSP=4;
//---  
   m_SignalBar=1;
   m_used_series=USE_SERIES_OPEN+USE_SERIES_HIGH+USE_SERIES_LOW+USE_SERIES_CLOSE;
  }
//+------------------------------------------------------------------+
//| Checking adjustable parameters.                                  |
//| INPUT:  no.                                                      |
//| OUTPUT: true, if the settings are valid, false - if not.         |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
bool CBykovTrendSignal::ValidationSettings()
  {
//--- checking parameters
   if(m_RISK<=0)
     {
      printf(__FUNCTION__+": Risk level must be above zero");
      return(false);
     }
     
   if(m_SSP<=0)
     {
      printf(__FUNCTION__+": SSP must be above zero");
      return(false);
     }

//--- successful completion
   return(true);
  }
//+------------------------------------------------------------------+
//| Initialization of indicators and time series.                    |
//| INPUT:  indicators - pointer to an object-collection             |
//|                      of indicators and time series.              |
//| OUTPUT: true - in case of successful, otherwise - false.         |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
bool CBykovTrendSignal::InitIndicators(CIndicators *indicators)
  {
//--- check of pointer
   if(indicators==NULL) return(false);

//--- indicator initialization 
   if(!InitBykovTrend(indicators)) return(false);

//--- successful completion
   return(true);
  }
//+------------------------------------------------------------------+
//| BykovTrend indicator initialization.                             |
//| INPUT:  indicators - pointer to an object-collection             |
//|                      of indicators and time series.              |
//| OUTPUT: true - in case of successful, otherwise - false.         |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
bool CBykovTrendSignal::InitBykovTrend(CIndicators *indicators)
  {
//--- check of pointer
   if(indicators==NULL) return(false);

//--- adding an object to the collection
   if(!indicators.Add(GetPointer(m_indicator)))
     {
      printf(__FUNCTION__+": error of adding the object");
      return(false);
     }

//--- setting the indicator parameters
   MqlParam parameters[3];
   parameters[0].type=TYPE_STRING;
   parameters[0].string_value="BykovTrend.ex5";
   parameters[1].type=TYPE_INT;
   parameters[1].integer_value=m_RISK;
   parameters[2].type=TYPE_INT;
   parameters[2].integer_value=m_SSP;

//--- object initialization   
   if(!m_indicator.Create(m_symbol.Name(),m_Ind_Timeframe,IND_CUSTOM,3,parameters))
     {
      printf(__FUNCTION__+": object initialization error");
      return(false);
     }
     
//--- number of buffers
   if(!m_indicator.NumBuffers(2)) return(false);
   
//--- BykovTrend indicator initialized successfully
   return(true);
  }
//+------------------------------------------------------------------+
//| Checking conditions for opening                                  |
//| a long position and closing a short one                          |
//| INPUT:  no                                                       |
//| OUTPUT: Vote weight from 0 to 100                                |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
int CBykovTrendSignal::LongCondition()
  {
//--- buy signal is determined by buffer 1 of the BykovTrend indicator
   double Signal=m_indicator.GetData(1,m_SignalBar);

//--- getting a trading signal 
   if(Signal && Signal!=EMPTY_VALUE)
     {
      if(m_BuyPosOpen)
        {
         if(m_SellPosClose) return(REVERSE_SHORT);
         else return(OPEN_LONG);
        }
      else
        {
         if(m_SellPosClose) return(CLOSE_SHORT);
        }
     }

//--- searching for signals for closing a short position
   if(!m_SellPosClose) return(NO_SIGNAL);

   int Bars_=Bars(m_symbol.Name(),m_Ind_Timeframe);

   for(int bar=int(m_SignalBar); bar<Bars_; bar++)
     {
      Signal=m_indicator.GetData(0,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(NO_SIGNAL);

      Signal=m_indicator.GetData(1,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(CLOSE_SHORT);
     }

//--- no trading signal
   return(NO_SIGNAL);
  }
//+------------------------------------------------------------------+
//| Checking conditions for opening                                  |
//| a short position and closing a long one                          |
//| INPUT:  no                                                       |
//| OUTPUT: Vote weight from 0 to 100                                |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
int CBykovTrendSignal::ShortCondition()
  {
//--- sell signal is determined by buffer 0 of the BykovTrend indicator
   double Signal=m_indicator.GetData(0,m_SignalBar);
   
//--- getting a trading signal
   if(Signal && Signal!=EMPTY_VALUE)
     {
      if(m_SellPosOpen)
        {
         if(m_BuyPosClose) return(REVERSE_LONG);
         else return(OPEN_SHORT);
        }
      else
        {
         if(m_BuyPosClose) return(CLOSE_LONG);
        }
     }

//--- searching for signals for closing a long position
   if(!m_BuyPosClose) return(NO_SIGNAL);

   int Bars_=Bars(Symbol(),m_Ind_Timeframe);  // ПРЕДУПРЕЖДЕНИЕ В ЭТОЙ СТРОКЕ КОДА: deprecated behavior, hidden method calling will be disabled in a future MQL compiler version
   for(int bar=int(m_SignalBar); bar<Bars_; bar++)
     {
      Signal=m_indicator.GetData(1,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(NO_SIGNAL);

      Signal=m_indicator.GetData(0,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(CLOSE_LONG);
     }

//--- no trading signal   
   return(NO_SIGNAL);
  }
//+------------------------------------------------------------------+
 

Hello, dear developers of MQL5!

You have created such an excellent tool like the MQL5 Wizard for people with no programming knowledge that can generate Expert Advisors based on trading modules. The MQL5 website contains a lot of interesting trading signal modules that were written a few years ago by MQL5 professionals and other MQL5 forum members. By the way,thank you all for your work! However, there is a little "but" that keeps hampering the full power of the MQL5 Wizard.

Due to the fact that the programming language is under constant development, I ask you to create a branch reflecting all the nuances of these changes and describing the necessary actions in terms of code corrections, for example, in trading signals modules to avoid such issues:

MrBrooklin:

Hello!

Please advise what you should fix in the code of the Trading Signals module to avoid the compiler warning in that line, which is highlighted in yellow.

Sincerely, Vladimir.

If my suggestion is acceptable, this topic could be titled, for instance, "Revision of Trading Signals Modules".

Sincerely, Vladimir.

 
MrBrooklin:

Hello!

Please advise what you should correct in the code of the trading signals module to exclude the compiler warning in the line highlighted in yellow.

Sincerely, Vladimir.

Why do you address the "m_symbol" object in one place

   int Bars_=Bars(m_symbol.Name(),m_Ind_Timeframe);

and then suddenly to Symbol():

   int Bars_=Bars(Symbol(),m_Ind_Timeframe);  // ПРЕДУПРЕЖДЕНИЕ В ЭТОЙ СТРОКЕ КОДА: deprecated behavior, hidden method calling will be disabled in a future MQL compiler version


You shouldn't do it that way.

To understand why there is suddenly a warning about calling the hidden method, just put the mouse cursor on Symbol and press the middle mouse button: you will see that there is such a method in

in the ExpertBase file.


Therefore, you should use m_symbol in the signals module.

 
Vladimir Karputov:

Why do you access the "m_symbol" object in one place

and then suddenly to Symbol():

You should not do that.

Thanks, Vladimir, for the tip!

The thing is that this module was downloaded from the website and simply compiled into MetaEditor. I haven't performed any other operations (e.g., code changes, etc.) withthe trading signals module and the warning was generated by the compiler itself.

Sincerely, Vladimir.

Reason: