Discussion of article "Create Your Own Trading Robot in 6 Steps!" - page 2

 
bivmail:

I was getting excited, but I can't get around this (comm - I read about memory address transfer, but it didn't work that way either):

The compiler returns the error 'm_MethodFast' - constant expression required, ' m_MethodSlow' - constant expression required

Of course, these are questions for a dummies. maybe I should ask such questions in another thread, so as not to clog up the article?


ENUM_MA_METHOD l_array1_select_method[2];
l_array1_select_method[0]=MethodFast();
l_array1_select_method[1]=MethodSlow();
 

Yeah. the second way didn't work out so well either:

it stumbles

1)'=' - l-value required //...Search(l_array1_select_method_n2.At(i_array1_n2))=-1)

2) 'At' - parameter for EnumToString must be an enumeration //...EnumToString(l_array1_select_method_n2.At(i_array1_n2)));

expression not boolean

#include <Arrays\ArrayInt.mqh>
   CArrayInt l_array1_select_method_n2;
   l_array1_select_method_n2.Add(m_MethodFast);
   l_array1_select_method_n2.Add(m_MethodSlow);
   //int total_array1_n2=l_array1_select_method_n2.Total()-1;// ArraySize(l_array1_select_method_n2);

   CArrayInt l_array2_enum_ma_method_n2;
   l_array2_enum_ma_method_n2.Add(MODE_SMA);
   l_array2_enum_ma_method_n2.Add(MODE_EMA);
   l_array2_enum_ma_method_n2.Add(MODE_SMMA);
   l_array2_enum_ma_method_n2.Add(MODE_LWMA);

   bool YesErrorsFlag_n2=false;
   for(int i_array1_n2=0;i_array1_n2<l_array1_select_method_n2.Total()-1;i_array1_n2++)
     {
      if(l_array2_enum_ma_method_n2.Search(l_array1_select_method_n2.At(i_array1_n2))=-1)
        {
         YesErrorsFlag_n2=true;
         PrintFormat("Invalid smoothing type %s moving average!",EnumToString(l_array1_select_method_n2.At(i_array1_n2)));
        }
     }

   if(YesErrorsFlag_n2)
     {
      return(false);
     }

Now this has no practical purpose. Let's leave it as it is in the example...

 
bivmail:

Yeah. the second way didn't work out so well either:

it stumbles

1)'=' - l-value required //...Search(l_array1_select_method_n2.At(i_array1_n2))=-1)

2) 'At' - parameter for EnumToString must be an enumeration //...EnumToString(l_array1_select_method_n2.At(i_array1_n2)));

expression not boolean

Now this has no practical purpose. Let's leave it as it is in the example....

Let's attach the code suitable for compilation (because telepaths are tedious).
 

Hello, I have the following problem.

I have done all the steps according to the instructions up to the end. I compiled EA and tried to test it - no trades occurred during the whole year of the test and it gives an error - genetic pass (nn, sequence number) tested with error "cannot initialise expert".

I tried to compile the Expert Advisor from the ma_cross.mqh signal, which came with the article, it gives the same error. And finally, I tried the ready-made Expert Advisor that came with the article, and again the same error!!! What is the problem, can you tell me?


 
Try to recompile the supplied custom indicator "Custom Moving Average.mq5". If the version of the Custom Moving Average.ex5 file does not coincide with the current version of the compiler, the indicator handle will not be created during initialisation of the generated Expert Advisor. It looks like you have this case.
Переход на новые рельсы: пользовательские индикаторы в MQL5
Переход на новые рельсы: пользовательские индикаторы в MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
Я не буду перечислять все новые возможности и особенности нового терминала и языка. Их действительно много, и некоторые новинки вполне достойны освещения в отдельной статье. Вы не увидите здесь кода, написанного по принципам объектно-ориентированного программирования — это слишком серьезная тема для того, чтобы просто быть упомянутой в контексте как дополнительная вкусность для кодописателей. В этой статье остановимся подробней на индикаторах, их строении, отображении, видах, а также особенностях их написания по сравнению с MQL4.
 

Thanks for your help. I recompiled, but the problem remains. Moreover, I want to clarify that I downloaded metatrader a week ago from the official metatrader site, so I doubt that anything has had time to become outdated.

Moreover, I tried to test this Expert Advisor from two different computers.

 
danielalmaty:

Thanks for your help. I recompiled, but the problem remains. Moreover, I want to clarify that I downloaded metatrader a week ago from the official metatrader site, so I doubt that anything has had time to become outdated.

Moreover, I tried to test this Expert Advisor from two different computers.

You should try to run single testing (not optimisation). The log will contain more detailed information about the reason of non-initialisation of the Expert Advisor.
 

I tried to run a single test without optimisation, no errors, everything goes smoothly, but not a single trade was made in the test for the whole period.

 
danielalmaty:

I tried running a single test without optimisation, no errors, everything goes smoothly, but not a single trade was made in the test during the whole period.

Can you show the Expert Advisor settings and tell me on which trading server you run the testing? Do you have an active account?
 

Starting testing on the MIGBank-Demo server.

The settings of the Expert Advisor are like this

//+------------------------------------------------------------------+
//| Inputs|
//+------------------------------------------------------------------+
//--- inputs for expert
input string         Expert_Title             ="ssssa";  // Document name
ulong                Expert_MagicNumber       =847;      // 
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         =50.0;     // Take Profit level (in points)
input int            Signal_Expiration        =4;        // Expiration of pending orders (in bars)
input int            Signal_MaCross_FastPeriod=13;       // My_MA_Cross(13,MODE_SMA,21,...) Period of fast MA
input ENUM_MA_METHOD Signal_MaCross_FastMethod=MODE_SMA; // My_MA_Cross(13,MODE_SMA,21,...) Method of fast MA
input int            Signal_MaCross_SlowPeriod=21;       // My_MA_Cross(13,MODE_SMA,21,...) Period of slow MA
input ENUM_MA_METHOD Signal_MaCross_SlowMethod=MODE_SMA; // My_MA_Cross(13,MODE_SMA,21,...) Method of slow MA
input double         Signal_MaCross_Weight    =1.0;      // My_MA_Cross(13,MODE_SMA,21,...) Weight [0...1.0]
//--- inputs for money
input double         Money_FixLot_Percent     =10.0;     // Percent.
input double         Money_FixLot_Lots        =0.1;      // Fixed volume

As I said, I tried to run the Expert Advisor that came with the article and it led to the same result. So you can see the settings just by downloading the file from the article.