Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 4

 
Stacy:
I am very thankful for this article it has helped a great deal. After writing my codes for my EA I pressed the debugging button and i was told that I have 10 errors, in your article their isn't any information for correcting these errors. So how do I solve this problem, please write back as soon as possible ?

Hi Stacy,

Thanks for your compliments, like you said, correcting some of the code errors were not discussed in the article, however, another article will soon be published that explained how to resolve code errors in detail.

Just wait for it.

 Thank you

Samuel. 

 

hi everyone!

i am a beginer and i am trying to write an E.A follow the guide but it did not make sell or buy order.

my algorithm is use 2 ma( 6 and 12) and 1 rsi(14), like that:


bool Buy_Condition_1 =  (maVal_fast[0]<maVal_slow[0]) && (maVal_fast[1] > maVal_slow[1]);

bool Buy_Condition_2 = (rsiVal[0] < Pereprod);

if(Buy_Condition_1 && Buy_Condition_2)

{

            // blah...blah...

              mrequest.price = NormalizeDouble(latest_price.ask,_Digits);           // latest ask price

              mrequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits); // Stop Loss

              mrequest.tp = NormalizeDouble(latest_price.ask + TKP*_Point,_Digits); // Take Profit
              mrequest.volume = Lot;                                                 // number of lots to trade

              mrequest.type = ORDER_TYPE_BUY;

             // .............


}

but it dont jump into  segment code above. so it cannot automated trading. = =!.

i need help :(.

i use PRICE_MEDIAN instead of PRICE_CLOSE ( i dont know differences between them ).

thank you.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

hi everyone!

i am a beginer and i am trying to write an E.A follow the guide but it did not make sell or buy order.

 

Hi,

Can you please make available your code so we can see where the problem is? 

 

Мы решили хранить значения Stop Loss и Take Profit в определенных ранее переменных STP и TKP. Почему мы это сделали?

This is done because the values of input parameters cannot be modified, they are read-only.

We need to be sure that our Expert Advisor will work correctly with all brokers. To determine the accuracy of the quote price by the current symbol of the chart, you can use.

An amazing "approach" is used by respected and experienced programmers to "solve the problem" of the 5-digit symbol. And now this "approach" is also cultivated among beginners, in educational, we may say, literature.

The "approach" given by the author completely nullifies the whole advantage of 5-digit. Instead of explaining to a beginner that the introduction of a 5-digit quote makes it possible to set, for example, take profit not 10 pips, but 10.5. And also to explain that when using an Expert Advisor with a 5-digit quote it is necessary to specify take profit not 10 pips but 100. Instead of such explanations, strings are introduced into the program code that programmatically make it impossible to take advantage of 5-digit quotes.

"We must be sure that our EA will work correctly with all brokers". Well, we are sure and then what? How to use the advantage of 5-digit quotes now, if programmatically the Expert Advisor has "sentenced to serve correctly".

 
abolk:

An amazing "approach" is used by respected and experienced programmers to "solve the problem" of 5-digits. And now this "approach" is also cultivated among beginners, in educational, we may say, literature.

The "approach" given by the author completely nullifies the whole advantage of 5-digit. Instead of explaining to a beginner that the introduction of a 5-digit quote makes it possible to set, for example, take profit not 10 pips, but 10.5. And also to explain that when using an Expert Advisor with a 5-digit quote it is necessary to specify take profit not 10 pips but 100. Instead of such explanations, lines are introduced into the programme code, which programmatically do not make it possible to use the advantages of 5-digit quotes.

"We must be sure that our EA will work correctly with all brokers". Well, we are sure and then what? How can we use the advantage of 5-digit quotes now, if the Expert Advisor has been programmatically "sentenced to serve correctly".

10.5 is another argument :)

And standardisation on 4 digits is quite understandable, if we consider the need for universal work on accounts with different accuracy.

Perhaps if all brokers will use accounts with 5 digits such processing will not be necessary (though for the code universality the presence of such a block will not hurt) IMHO.

But I can't understand how it prevents from using the advantages of the 5th digit.

The accuracy of this block allows you to use the 1st four-digit point (conditionally "standard"), in terms of five digits it will be 10 pips.

PS

I don't think most brokers will allow to use a smaller value. Even if they do and it will be necessary, it will be possible to get out of the situation (even if applying such oddities as 0.1-0.9).

 
Interesting:

10.5 is still an argument :)

And standardisation on 4 digits is quite understandable, if we consider the need for universal work on accounts with different accuracy.

Perhaps if all brokers will use accounts with 5 digits such processing will not be necessary (although for code universality the presence of such a block will not hurt) IMHO.

But I can't understand how it prevents from using the advantages of the 5th digit.

The accuracy of this block allows to use 1 four-digit point (conditionally "standard"), in terms of five digits it will be 10 pips.

PS

I don't think most brokers will allow to use a smaller value. Even if they do and it will be necessary, it will be possible to get out of the situation (even by applying such oddities as 0.1-0.9).

With 4 digits the price changes by 0.0001, with 5 digits it changes by 0.00001.

There is no possibility to make it possible to close on takeout after 10.5 standard points on a 4-digit, but on a 5-digit there is such a possibility.

If the above block is used programmatically, then when using an Expert Advisor on a 5-digit symbol, there will be no possibility to change, for example, the Take Stop at 10.5 standard points. This is important for scalpers.

In order for the Expert Advisor to work correctly on 4 and 5 digits , it is necessary to take into account the sign of quotes during rounding, and in the input parameters, when setting, for example, the take, manually take into account that 10 standard points are written as 100.

Otherwise, if you use such blocks, then when switching from k5 digit to 4-digit, what will you have to divide?

These are input parameters, why do "strange" conversion operations with them?

 
abolk:

On the 4-digit there is no possibility to make it possible to close on the take after 10.5 standard pips, but on the 5-digit there is such a possibility.

Do you trade? Or are you just trying to theorise?

I can hardly imagine an EA, for which changing the TP by 0.5 points will greatly affect the results. For 99% of Expert Advisors it is easier and more convenient to specify all values in 4-digit points. And there is no point in describing the remaining 1% in general education articles.

 
komposter:

Are you trading? Or do you just want to theorise?

I can hardly imagine an EA for which changing the TP by 0.5 points would have a strong impact on the results. For 99% of Expert Advisors it is easier and more convenient to specify all values in 4-digit points. And for the remaining 1%, there is no point in describing them in general education articles.

+1.

It's not about what accuracy to trade with, but about what these 10.5 pips will sound like and how it will confuse everyone (especially beginner traders).

A pip is by definition the smallest unit of price change. Maybe I am wrong?

And EAs trading with TP and SL of 5 five-digit points (0.5 standard points) are unlikely to be found in real life.

I would even define the number of such Expert Advisors as 0.1-0.01% of the total number.

PS

Internal calculations based on the results of trading operations are not taken into account here (everyone can round up to the necessary accuracy).



 
abolk:

The "approach" given by the author completely nullifies all the advantages of the 5-digit quote. Instead of explaining to a beginner that the introduction of a 5-digit quote makes it possible to set, for example, take profit not 10 pips, but 10.5. And also to explain that when using an Expert Advisor with a 5-digit quote it is necessary to specify take profit not 10 pips but 100. Instead of such explanations, lines are introduced into the program code, which programmatically do not allow using the advantages of 5-digit quotes.

I fully support the author of this comment.

Those who need it will round up to the 3rd digit. But it is a gross mistake to do it in a general case.

The higher the accuracy - the better, and it is not worth it to nullify it for everyone by some purely subjective views of practical use.

P.S. In general case SL and TP are set not in absolute values (as it is accepted everywhere), but in relative values. Then the problems of pips, 5-signs, pips-dollars and other far-fetched bullshit disappear by themselves.

 

abolk, hrenfx, what, in fact, is the argument about? Let's read carefully the title of the article: "... The article fully justifies its purpose, both in title and content. Take my word for it, for beginners it makes no difference what the rounding accuracy of the expert is, the main approach is: "we just need to deal with the EA writing ". For me personally, as a beginner, the trick with "rounding" to 4 digits (though in another article) turned out to be very useful, revealing one of the programming techniques. And with experience, highly qualified specialists will be able to decide with what accuracy to perform calculations/trading, and the article under discussion will not hinder them in any way. This article did not hinder you in any way :). So do others: "when they grow up to your level, they will figure it out for themselves".

I would like to draw your attention once again: the author of the article does not impose his vision of the issue and does not discuss the value of using 4 or 5 digits. The author only helps beginners to master the initial steps of programming in MQL5, using certain programming techniques.