I share with you my first EA! I need some help, do you see any errors?

 

Hello there,

I have followed the instructions of <a href="https://www.mql5.com/en/articles/496">this cool article</a> written by Дмитрий to create Pithecus, my first EA. Pithecus, which means monkey in old Latin, is able to open a position on a symbol every given number of seconds. We will all agree that this is not a very profitable trading strategy!, but because it is a very simple one Pithecus is rich in teaching objectives, IMHO.

I've also tested Pithecus in MT5's Strategy Tester and everything works as expected, I think. However, I would be very pleased to receive some feedback from you to ensure that my first FOREX robot is technically correct. So could you please help me and have a look at the following MQL5 program? Can you see any error? All comments are welcome. Thank you very much in advance!

A Quick Start Or a Short Guide for Beginners
A Quick Start Or a Short Guide for Beginners
  • 2012.09.25
  • Dmitriy Parfenovich
  • www.mql5.com
Hello dear reader! In this article, I will try to explain and show you how you can easily and quickly get the hang of the principles of creating Expert Advisors, working with indicators, etc. It is beginner-oriented and will not feature any difficult or abstruse examples.
Files:
phitecus.mq5  1 kb
 
laplacianlab:

Hello there,

I have followed the instructions of <a href="https://www.mql5.com/en/articles/496">this cool article</a> written by Дмитрий to create Pithecus, my first EA. Pithecus, which means monkey in old Latin, is able to open a position on a symbol every given number of seconds. We will all agree that this is not a very profitable trading strategy!, but because it is a very simple one Pithecus is rich in teaching objectives, IMHO.

I've also tested Pithecus in MT5's Strategy Tester and everything works as expected, I think. However, I would be very pleased to receive some feedback from you to ensure that my first FOREX robot is technically correct. So could you please help me and have a look at the following MQL5 program? Can you see any error? All comments are welcome. Thank you very much in advance!


As you said :..everything works as expected", so if no error, it's ok.

Note : this EA only provide BUY order, right? I think you need to add SELL order.

 
achidayat:

As you said :..everything works as expected", so if no error, it's ok.

Note : this EA only provide BUY order, right? I think you need to add SELL order.

Thank you! Your response is very helpful. Congratulations for all your work with EAs.

I did not put any sales order because I felt that it was the same concept as the purchase. I've applied the KISS principle as fas as I've been able. After your feedback I will make Pithecus evolve a bit more.

 
laplacianlab:

Thank you! Your response is very helpful. Congratulations for all your work with EAs.

I did not put any sales order because I felt that it was the same concept as the purchase. I've applied the KISS principle as fas as I've been able. After your feedback I will make Pithecus evolve a bit more.

Thank you,

I do not know about the KISS principle, but it means you ignore the advantages of the forex market, where we can take advantage of the rising and falling market. This is very different from trading commodities and stocks, where we could only take profit when prices rise.
 
achidayat:

Thank you,

I do not know about the KISS principle, but it means you ignore the advantages of the forex market, where we can take advantage of the rising and falling market. This is very different from trading commodities and stocks, where we could only take profit when prices rise.

Yes, I know that in FOREX and financial derivatives you can hold a position long or short, as you want.

The KISS principle states that when writing an app (or making whatever) you should avoid complexity. It is something like a "state of the mind" from which you do things. I applied the KISS principle in Pithecus because I wanted to focus on the technical aspects of my learning process. I thought: "I am not selling because it is technically the same thing as buying, I am going to use a very similar API call!, so let's avoid that line of code".

By the way, you said "if no error when compiling, it's ok". Anyway, I have a question for you and those of you who write EAs. My question is "Is there a log file somewhere where we can see in more detail the result of that compiling process?". Otherwise, I guess that what we have left is the log of the Strategy Tester to obtain more details on the robot. I don't want me to happen this https://www.mql5.com/en/articles/538!!

Andrey Voitenko: Programming errors cost me $15,000 (ATC 2010)
Andrey Voitenko: Programming errors cost me $15,000 (ATC 2010)
  • 2010.12.15
  • Automated-Trading
  • www.mql5.com
Andrey Voitenko is participating in the Automated Trading Championship for the first time, but his Expert Advisor is showing mature trading. For already several weeks Andrey's Expert Advisors has been listed in the top ten and seems to be continuing his positive performance. In this interview Andrey is telling about his EA's features, errors and the price they cost him.
 
laplacianlab:

Yes, I know that in FOREX and financial derivatives you can hold a position long or short, as you want.

The KISS principle states that when writing an app (or making whatever) you should avoid complexity. It is something like a "state of the mind" from which you do things. I applied the KISS principle in Pithecus because I wanted to focus on the technical aspects of my learning process. I thought: "I am not selling because it is technically the same thing as buying, I am going to use a very similar API call!, so let's avoid that line of code".

By the way, you said "if no error when compiling, it's ok". Anyway, I have a question for you and those of you who write EAs. My question is "Is there a log file somewhere where we can see in more detail the result of that compiling process?". Otherwise, I guess that what we have left is the log of the Strategy Tester to obtain more details on the robot. I don't want me to happen this https://www.mql5.com/en/articles/538!!

I think no log files for compiling process, but in strategy tester we can obtain log files.

If technical errors like https://www.mql5.com/en/articles/538, in this case the trailing stop, then we will know from Strategy Tester logs. But if the error occurred due to mistake of strategy will not be recorded in the log, we only know from the strategy tester results, whether profitable or not.

Andrey Voitenko: Programming errors cost me $15,000 (ATC 2010)
Andrey Voitenko: Programming errors cost me $15,000 (ATC 2010)
  • 2010.12.15
  • Automated-Trading
  • www.mql5.com
Andrey Voitenko is participating in the Automated Trading Championship for the first time, but his Expert Advisor is showing mature trading. For already several weeks Andrey's Expert Advisors has been listed in the top ten and seems to be continuing his positive performance. In this interview Andrey is telling about his EA's features, errors and the price they cost him.
 
achidayat:

I think no log files for compiling process, but in strategy tester we can obtain log files.

If technical errors like https://www.mql5.com/en/articles/538, in this case the trailing stop, then we will know from Strategy Tester logs. But if the error occurred due to mistake of strategy will not be recorded in the log, we only know from the strategy tester results, whether profitable or not.

Yes, those are the so called "execution errors" such as an infinite loop, etc. which are only detectable by humans. For those of you wondering this question here you have this great article here: https://www.mql5.com/en/articles/586

Ok, I am glad :-) to know that I am on the right way and hope soon to share with you a slightly more sofisticated EA. I didn't expect to find here so much research in automated trading as I am seeing right now. This is one of the best places in the world in this area, sure. Thank you!

How to Test a Trading Robot Before Buying
How to Test a Trading Robot Before Buying
  • 2012.11.09
  • MetaQuotes Software Corp.
  • www.mql5.com
Buying a trading robot on MQL5 Market has a distinct benefit over all other similar options - an automated system offered can be thoroughly tested directly in the MetaTrader 5 terminal. Before buying, an Expert Advisor can and should be carefully run in all unfavorable modes in the built-in Strategy Tester to get a complete grasp of the system.
 

Are you sure you really read that article, following it and learning from it ?, because if you are, your code is showing that you are NOT reading it.

1. You use input for symbol, and yet you don't use it

input string Pair = "EURUSD";

2. You Working with Eventsyet you're not killing your EventSetTimer using EventKillTimer in OnDeinit. In fact your code does not have OnDeinit().

3. You only have open buy - which will open buy position for more on every OnTimer(), and you don't have sell trade, which in MT5 is also useful to close a buy position.

I won't call your code an EA, and I suggest you to learn more and in the future, please post a decent EA in the forum.

And NO, I don't think you read that article, because if you read it, you won't create something like this.


<EDIT : your code here https://www.mql5.com/en/forum/9759  still have error but much better than this> 

Are you learning MQL5 and want to have a couple of very simple EAs? Here you have my two micro robots!
Are you learning MQL5 and want to have a couple of very simple EAs? Here you have my two micro robots!
  • www.mql5.com
This is the classical trading system which consists in buying when MACD crosses above the waterline line and selling when crosses below it.
 
phi.nuts:

Are you sure you really read that article, following it and learning from it ?, because if you are, your code is showing that you are NOT reading it.

1. You use input for symbol, and yet you don't use it

2. You Working with Eventsyet you're not killing your EventSetTimer using EventKillTimer in OnDeinit. In fact your code does not have OnDeinit().

3. You only have open buy - which will open buy position for more on every OnTimer(), and you don't have sell trade, which in MT5 is also useful to close a buy position.

I won't call your code an EA, and I suggest you to learn more and in the future, please post a decent EA in the forum.

And NO, I don't think you read that article, because if you read it, you won't create something like this.


<EDIT : your code here https://www.mql5.com/en/forum/9759  still have error but much better than this> 

Well, it is Pithecus (monkey in old Latin), not a sapiens yet, it is at an early stage in evolution...
Reason: