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

 

Please advise how to solve the problem. The Expert Advisor opens several positions in a row to buy, the same for selling.

The Expert Advisor does not see that there are already open Buy and Sell positions and opens new ones, despite the fact that there is a check in the code

for already open positions. The check does not work for some reason.

 
Korobejnik:
Please advise how to solve the problem. The Expert Advisor opens several positions in a row to buy. The same for selling.

The error is in line 230. Fix the error.

 
Vladimir Karputov:

Error in line #230. Correct the error.

Vladimir Karputov:

Error in line #230. Correct the error.

bool Sell_Condition_1 = (maVal[0]<maVal[1]) && (maVal[1]<maVal[2]); // MA-8 is down

What's wrong with it?

 
Korobejnik:

bool Sell_Condition_1 = (maVal[0]<maVal[1]) && (maVal[1]<maVal[2]); // MA-8 goes down

What's wrong with it?

That was humour. The point is that this is a technical forum and there are no psychics and mind-reading telepaths here.

If you want to get the right answer, ask the question correctly: specify who, what, where and where you can't get it. Otherwise there will be answers like above :)

 
Vladimir Karputov:

That was humour. The thing is that here is a technical forum and there are no psychics and mind-reading telepaths on staff.

You want to get the right answer - ask the question correctly: specify who, what, where and where you can not get. Otherwise there will be answers like above :)

The Expert Advisor opens several positions in a row to buy, and the same for selling.

The Expert Advisor does not see that there are already open Buy and Sell positions and opens new ones, despite the fact that there is a check in the code for already opened positions.

for already open positions. The check does not work for some reason.
 
Korobejnik:
The Expert Advisor opens several positions in a row to buy, the same for selling.

The Expert Advisor does not see that there are already open Buy and Sell positions and opens new ones, despite the fact that there is a check in the code for already open positions.

for already open positions. The check does not work for some reason.

There are thousands of Expert Advisors in KodoBase. At the end of each description of an Expert Advisor in KodoBase there is a button: go to forum discussion. Ask your question in the topic of the Expert Advisor you downloaded.

 

Goodnight. In post 77 I think the question has already been asked:

Tron_KZ 2015.01.14 16:20 #77 RU
From the article:
A new bar is characterised by the tick volume value equal to 1. If it is greater than 1, the OnTick function is terminated.

Where is the code that satisfies this description? I don't understand something, or there is no such thing in the code.


No one has given me an answer. I join the question, I just want to be sure that it's not me, but just some rudiment from the manuscript that has got lost. Or there is a code fragment with the check for tick volume ,,,,????.

 
Sergey Voytsekhovsky:
No one has given me an answer. I join the question, I just want to be sure that it's not me, but just some rudiment from the manuscript that has got lost. Or there is a code fragment with the check for tick volume ,,,,????.
You are right, there is no such code in the proposed source. The check of tick to a new bar is performed by comparing the opening time of the current bar between ticks.
 
Congratulations! Excellent article! It helped me a lot.
 

Hello, in the downloadable .mq5 file there are two errors:

In lines 210 and 256 the attribute "type_filling" should be ORDER_FILLING_FOK instead of ORDER_FILLING_AON, it would look like this: mrequest.type_filling = ORDER_FILLING_FOK;

Best regards!