Questions from a "dummy" - page 237

 
forward666:

Good morning!

A word of advice to a very novice))). The question is as follows:

Let's assume a position was opened by a price jump and an ascending MA (it is set in the code), but almost immediately the chart changed, that is, the MA started going down (as well as the entire chart of course)) ). I have to write a function that will close the position at this point, but I have not reached stop loss or limit and reopen the position with the new data. And it all has to be checked each time. I hope the description is clear:)))

Please advise, who knows).
 
forward666:
Please advise, who knows)

In the attachment is the situation of what I would like to avoid or at least make less.

MA changes direction during opening and closing a position several times.

Files:
 

forward666: Хочется добиться того,чтоб при первом же изменении МА в обратную сторону происходило закрытие минусовой позиции и открытие новой позиции по верным условиям 

1. Compare the previous and current MA value.

2. If the current MA value has changed to the "wrong" side, check the position for "minus".

If the position turned out to be negative, check the conditions for opening an opposite position. 3:

3а. If there are no conditions to open the opposite position - send an order to close the initial negative position;

3б. If there are conditions to open the opposite position - send an order to reverse the position.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства сделок
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства сделок
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства сделок - Документация по MQL5
 
Yedelkin:

1. Compare the previous and current MA value.

2. If the current MA value has changed to the "wrong" side, check the position for "minus".

If the position turned out to be negative, check the conditions for opening an opposite position. 3:

3а. If there are no conditions to open the opposite position - send an order to close the initial negative position;

3б. If there are conditions to open the opposite position - send an order to reverse the position.

Thank you! I understand what needs to be done, I'm having trouble completing the code myself, I can't figure it out! I'm a complete beginner:)
 
Well, good luck in learning the language, I don't think anyone will write everything for you. At least share your code, tell us where there are errors, we will help you.
 
lazarev-d-m:
Good luck in learning the language, I doubt someone will write everything for you. At least share your code, tell us where there are errors, we will help you.

It is clear that no one will write for me!) Maybe someone has a link to similar codes, at least to see what and how!

If I had this part of the code at least somehow described, then share it.

 
forward666:

It is clear that no one will write for me!) Maybe someone has a link to similar codes, at least to see what and how!

If I had this part of the code at least somehow described, I would share it. but I don't even know where to start(

Start with articles. There are articles for beginners with detailed examples. As you read the article and study the code, see the description in the Help for each function.
 
Lester:

Let's say the deposit is 20 thousand rubles.

For each transaction, 2% of the stop loss - i.e. 400 rubles.

Staples is set at 150 points. So 1 point is no more than 2.6 roubles.

So, in order to cover 1.5% monthly inflation (300r) and make 5% monthly increase of deposit - you should make more than 6.5% monthly - i.e. 1300r or 1300/2.6 = 500 points minimum. Overall, the minimum is 78% per annum.

What is your minimum number of points in profit every month?


 

I am reading the articles and studying the manual.)

I have one more question: when I run a robot, it opens a position that obviously does not reflect the reality of the chart, so it goes into deep red. How do I make this position not open right away when I run the robot? Where in the code should I add something?

 
forward666:

I am reading the articles and studying the manual.)

I have one more question: when I run a robot, it opens a position that obviously does not reflect the reality of the chart, so it goes into deep red. How do I make this position not open right away when I run the robot? Where in the code should I add something?

I don't know if I should open one or the other.)