Download MetaTrader 5

Error: CExpertBase::SetPriceSeries: changing of timeseries is forbidden

To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
Luis Sampaio
146
Luis Sampaio 2011.11.06 19:21 

Hi Guys,

Anyone could help me with this?

I`ve done a simple EMA Cross signal, after that I used MQL5 Wizard to built my EA...

When I try to run the EA it show the following errors:

CExpertBase::SetPriceSeries: changing of timeseries is forbidde
CExpertBase::SetOtherSeries: changing of timeseries is forbidden

Debugging the code I could see that the exception throws in this method of the Created EA:

//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(-9);
     }
//--- ok


I enter the method debbuging the code and I`ve seen that inside ExpertBase.mqh there is a check of init_phase, that if isnt iqual to Validation it is impossible to change the timeseries:

bool CExpertBase::SetPriceSeries(CiOpen *open,CiHigh *high,CiLow *low,CiClose *close)
  {
//--- check the initialization phase
   if(m_init_phase!=INIT_PHASE_VALIDATION)
     {
      printf(__FUNCTION__+": changing of timeseries is forbidden");
      return(false);
     }
//--- check pointers
   if((IS_OPEN_SERIES_USAGE  && open==NULL) ||
      (IS_HIGH_SERIES_USAGE  && high==NULL) ||
      (IS_LOW_SERIES_USAGE    &&  low==NULL) ||
      (IS_CLOSE_SERIES_USAGE && close==NULL))
     {
      printf(__FUNCTION__+": NULL pointer");
      return(false);
     }
   m_open =open;
   m_high =high;
   m_low  =low;
   m_close=close;
//--- ok
   return(true);
  }


I didnt understand this error because I`m using MQL5 wizard and the code was generated automatically.


// EMA CROSS EA
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
//--- available signals
#include <Expert\Signal\SignalEMACross.mqh>
//--- available trailing 
#include <Expert\Trailing\TrailingNone.mqh>
//--- available money management
#include <Expert\Money\MoneyFixedRisk.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for expert
input string             Expert_Title                      ="EMACross_V4_0"; // Document name
ulong                    Expert_MagicNumber                =6980;            // 
bool                     Expert_EveryTick                  =false;           // 
//--- inputs for main signal
input int                Signal_ThresholdOpen              =10;              // Signal threshold value to open [0...100]
input int                Signal_ThresholdClose             =10;              // Signal threshold value to close [0...100]
input double             Signal_PriceLevel                 =0.0;             // Price level to execute a deal
input double             Signal_StopLevel                  =50.0;            // Stop Loss level (in points)
input double             Signal_TakeLevel                  =100.0;            // Take Profit level (in points)
input int                Signal_Expiration                 =4;               // Expiration of pending orders (in bars)
input int                Signal_SignalEMACross_PeriodFastMA=5;               // SignalEMACross(5,21,0,...) 
input int                Signal_SignalEMACross_PeriodSlowMA=21;              // SignalEMACross(5,21,0,...) 
input int                Signal_SignalEMACross_ShiftMA     =0;               // SignalEMACross(5,21,0,...) 
input ENUM_MA_METHOD     Signal_SignalEMACross_MethodMA    =MODE_EMA;        // SignalEMACross(5,21,0,...) 
input ENUM_APPLIED_PRICE Signal_SignalEMACross_AppliedMA   =PRICE_CLOSE;     // SignalEMACross(5,21,0,...) Prices series
input double             Signal_SignalEMACross_Limit       =0.0;             // SignalEMACross(5,21,0,...) 
input double             Signal_SignalEMACross_StopLoss    =50.0;            // SignalEMACross(5,21,0,...) 
input double             Signal_SignalEMACross_TakeProfit  =100.0;           // SignalEMACross(5,21,0,...) 
input int                Signal_SignalEMACross_Expiration  =2;               // SignalEMACross(5,21,0,...) 
input double             Signal_SignalEMACross_Weight      =1.0;             // SignalEMACross(5,21,0,...) Weight [0...1.0]
//--- inputs for money
input double             Money_FixRisk_Percent=1.0;             // Risk percentage
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(-1);
     }
//--- Creating signal
   CExpertSignal *signal=new CExpertSignal;
   if(signal==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating signal");
      ExtExpert.Deinit();
      return(-2);
     }
//---
   ExtExpert.InitSignal(signal);
   signal.ThresholdOpen(Signal_ThresholdOpen);
   signal.ThresholdClose(Signal_ThresholdClose);
   signal.PriceLevel(Signal_PriceLevel);
   signal.StopLevel(Signal_StopLevel);
   signal.TakeLevel(Signal_TakeLevel);
   signal.Expiration(Signal_Expiration);
//--- Creating filter CSignalEMACross
   CSignalEMACross *filter0=new CSignalEMACross;
   if(filter0==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating filter0");
      ExtExpert.Deinit();
      return(-3);
     }
   signal.AddFilter(filter0);
//--- Set filter parameters
   filter0.PeriodFastMA(Signal_SignalEMACross_PeriodFastMA);
   filter0.PeriodSlowMA(Signal_SignalEMACross_PeriodSlowMA);
   filter0.ShiftMA(Signal_SignalEMACross_ShiftMA);
   filter0.MethodMA(Signal_SignalEMACross_MethodMA);
   filter0.AppliedMA(Signal_SignalEMACross_AppliedMA);
   filter0.Limit(Signal_SignalEMACross_Limit);
   filter0.StopLoss(Signal_SignalEMACross_StopLoss);
   filter0.TakeProfit(Signal_SignalEMACross_TakeProfit);
   filter0.Expiration(Signal_SignalEMACross_Expiration);
   filter0.Weight(Signal_SignalEMACross_Weight);
//--- Creation of trailing object
   CTrailingNone *trailing=new CTrailingNone;
   if(trailing==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating trailing");
      ExtExpert.Deinit();
      return(-4);
     }
//--- Add trailing to expert (will be deleted automatically))
   if(!ExtExpert.InitTrailing(trailing))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing trailing");
      ExtExpert.Deinit();
      return(-5);
     }
//--- Set trailing parameters
//--- Creation of money object
   CMoneyFixedRisk *money=new CMoneyFixedRisk;
   if(money==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating money");
      ExtExpert.Deinit();
      return(-6);
     }
//--- Add money to expert (will be deleted automatically))
   if(!ExtExpert.InitMoney(money))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing money");
      ExtExpert.Deinit();
      return(-7);
     }
//--- Set money parameters
   money.Percent(Money_FixRisk_Percent);
//--- Check all trading objects parameters
   if(!ExtExpert.ValidationSettings())
     {
      //--- failed
      ExtExpert.Deinit();
      return(-8);
     }
//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(-9);
     }
//--- ok
   return(0);
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| "Trade" event handler function                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
   ExtExpert.OnTrade();
  }
//+------------------------------------------------------------------+
//| "Timer" event handler function                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+


Thanks,

MQL5 Wizard: Creating Expert Advisors without Programming
  • 2011.01.11
  • MetaQuotes Software Corp.
  • www.mql5.com
Do you want to try out a trading strategy while wasting no time for programming? In MQL5 Wizard you can simply select the type of trading signals, add modules of trailing positions and money management - and your work is done! Create your own implementations of modules or order them via the Jobs service - and combine your new modules with existing ones.
Slawa
Moderator
6840
Slawa 2011.11.08 17:09  

Please wait for the next build. Such problem was fixed

Luis Sampaio
146
Luis Sampaio 2011.11.09 23:29  
stringo:

Please wait for the next build. Such problem was fixed


Stringo,

Thanks for your answer!!


Regards,

Victor Kirillin
491
Victor Kirillin 2011.11.11 07:58  

Insert underlined line to file Expert\Signal\SignalEMACross.mqh


//+------------------------------------------------------------------+
//| Validation settings protected data.                              |
//| INPUT:  no.                                                      |
//| OUTPUT: true-if settings are correct, false otherwise.           |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
bool CSignalCrossMA::ValidationSettings()
  {
//--- validation settings of additional filters
   if(!CExpertSignal::ValidationSettings()) return(false);
//--- initial data checks
   if(m_fast_period>=m_slow_period)
     {
      printf(__FUNCTION__+": period of slow MA must be greater than period of fast MA");
      return(false);
     }
//--- ok
   return(true);
  }
blueyes
10
blueyes 2011.11.15 00:54  

Hello Guys,

1. Using MQL5 Wizard I compile successfully an EA using  SignalCBC_WS_MFI.mqh class

2. When I try to run the EA it show the following errors: 
CExpertBase::SetPriceSeries: changing of timeseries is forbidden
CExpertBase::SetOtherSeries: changing of timeseries is forbidden 

3. Client v5.00 build540 (11/11/2011)

Thanks for your help.

MQL5 Wizard: Creating Expert Advisors without Programming
  • 2011.01.11
  • MetaQuotes Software Corp.
  • www.mql5.com
Do you want to try out a trading strategy while wasting no time for programming? In MQL5 Wizard you can simply select the type of trading signals, add modules of trailing positions and money management - and your work is done! Create your own implementations of modules or order them via the Jobs service - and combine your new modules with existing ones.
Luis Sampaio
146
Luis Sampaio 2011.11.17 04:54  
blueyes:

Hello Guys,

1. Using MQL5 Wizard I compile successfully an EA using  SignalCBC_WS_MFI.mqh class

2. When I try to run the EA it show the following errors: 
CExpertBase::SetPriceSeries: changing of timeseries is forbidden
CExpertBase::SetOtherSeries: changing of timeseries is forbidden 

3. Client v5.00 build540 (11/11/2011)

Thanks for your help.


Blueyes,

Even with this message your expert can work normally.


To add comments, please log in or register