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

 

New article Create Your Own Trading Robot in 6 Steps! is published:

If you don't know how trade classes are constructed, and are scared of the words "Object Oriented Programming", then this article is for you. In fact, you do not need to know the details to write your own module of trading signals. Just follow some simple rules. All the rest will be done by the MQL5 Wizard, and you will get a ready-to-use trading robot!


Author: MetaQuotes

 

Very good article. Thanks for the help.

 

 

 

good article


 

A very well written article which, however, left me frustrated as already for the first/second (?) step I got two error messages:

In line 10 the compiler was able to find but not to open the file "ExpertSignal.mqh". I cross-checked this by downloading the attached file "MA_...", which the compiler gave the same error message for. Then, of course, it was also not able to discern the structure of "CExpertSignal" in line 33 ("MA_..."), thus derailing the whole process. 

What was wrong there?

Thanks!

Locan.BBS

 
locan.BBS:

A very well written article which, however, left me frustrated as already for the first/second (?) step I got two error messages:

In line 10 the compiler was able to find but not to open the file "ExpertSignal.mqh". I cross-checked this by downloading the attached file "MA_...", which the compiler gave the same error message for. Then, of course, it was also not able to discern the structure of "CExpertSignal" in line 33 ("MA_..."), thus derailing the whole process. 

What was wrong there?

The ExpertSignal.mqh is located in terminal_data_folder\MQL5\Include\Expert\ExpertSignal.mqh.

Maybe the problem is wrong location of MA_Cross.mqh (it must be created in terminal_data_folder\MQL5\Include\Expert\MySignals\MA_Cross.mqh):



 

I tried to use this article to make my own program,  but it's too complicated for my simple purposes. Here I tried to make a simple program, but the compiler found (only) one error: Class with "no type". And no matter what I put in as a Class "type" or "name" there was no change.

Here is the beginning. What am I doing wrong?:


//|                                                  KaufVerkauf.mq5 |

//|                                             Copyright ....  2012 |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright .... 2012"
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>


//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert object initialization                              |
//+------------------------------------------------------------------


//---- handles for indicators
int         RSI_handle = 0;           // handle of the indicator iRSI
int         ADX_handle = 0;           // handle of the indicator iADX
int         Force_handle = 0;           // handle for the indicator iForce
int         AD_handle = 0;           // handle for the indicator iAD
int         Close_handle = 0;
int         High_handle = 0;
int         Low_handle = 0;
int         VTick_handle = 0;
int         VReal_handle = 0;
int         sig =0;

                
  double MqlParams[];      // Array for storing indicator params

//+------------------------------------------------------------------+
//| Expert initialization function RSI                               |
//+------------------------------------------------------------------+

Class CExpertSignal

{
private:

int OnInit()
 
//--- creation of the indicator iRSI...........
 
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

Thanks alot.

I try to test this:

- Download your code, copy to MQL5 and compiled: successful no errors.

- But EA cannot run, it generate an error as below:

  TestMA_Cross (EURUSD,H1)	MA_Cross::CreateFastMA: Error initializing the object of the fast MA

Please help me what wrong with this parameters:

//--- Setting parameters of the fast MA
   MqlParam parameters[4];
//---
   parameters[0].type=TYPE_STRING;
   parameters[0].string_value="Examples\\Custom Moving Average.ex5";
   parameters[1].type=TYPE_INT;
   parameters[1].integer_value=m_period_fast;      // Period
   parameters[2].type=TYPE_INT;
   parameters[2].integer_value=0;                  // Shift
   parameters[3].type=TYPE_INT;
   parameters[3].integer_value=m_method_fast;      // Method of averaging
//--- Object initialization
   if(!m_fast_ma.Create(m_symbol.Name(),m_period,IND_CUSTOM,4,parameters))
     {
      printf(__FUNCTION__+": Error initializing the object of the fast MA");
      return(false);
     }

Once again, thank you alot.

  

 

 

First off all I would like to thank the author(s) for this article.
I'm new to MetaTrader, MQL5 and Forex trading, so these articles are really useful!

When I test this EA, I notice that for closing a long position, it gives a sell signal with a doubled lot size.
Why does it not only close my long position, but directly enters a short at the same signal?
As a first test to understand all the programming, I would like to only go long, so only open and close a long
position without entering a short position at the closing/sell signal.

Thanks in advance.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
 

I do not have any experience (yet) with programming in MQL, but I do have some experience in programming in other languages.  One of the easiest errors to make in programming (my specific class was Java, which is very similar in style to C++ and apparently MQL) is not closing the braces properly.  It is one of the easiest errors to make, and conversely, also one of the harder ones to find.  KJG, as far as the closing a long and heading right into a short, it is probably what this style of EA is designed to do.  I have seen many trading styles with just that type of setup, I believe they were designed for a market that has a lot of volatility and wide price swings happening all the time, like something that would likely happen on a minute time frame chart.

Good article as well.  I definitely will be making use of this one and many others here I am sure.

 
I followed the instructions in steps 1 and 2, but the signal doesn't appear in the Wizard list of available signals. I tried with other signals and none works. Maybe there's a limitation in the number of signals that can be displayed in the wizard. Anyone can help?
 

The different stages of construction are well explained. It's a clear and useful job, especially for those who have never developed a robot.  Thank you

Reason: