Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1547

 
SGarnov:

Number of stops in a row on a currency pair.

The Expert Advisor is standing on several currency pairs and in the history there are several stops and in different sequence, in order to understand the history the EA initially labels the orders with ID but does not find them in the history, I thought that ОrderMagikNumber() will search for them. Maybe, because of the fact that in the history, the EA stops "seeing" stops from different currency pairs? I haven't tried to use the EA on one pair and it will be useless.

Do I have to expose the source code again? All it needs to do is correct "search for stop trades from history and make it add to the newly placed take".

And if there are more than two stops on a pair, how do you resume the EA's work on this pair?

And by the way OrderMagicNumber() sets the EA and manually placed orders without a magician
 
MakarFX:

And if there are more than two stops on a pair in a row, how do you reactivate the EA on that pair?

I do it with a new pendulum, which I set myself.
 
SGarnov:
Anew pendulum, which I put up myself.
Do I have to add points from previous losses to it or a new loss-counting cycle?
 
MakarFX:
Is it necessary to add points of previous losses or new loss cycle?

No. You don't need to add the previous ones. only when the EA starts working.

The Expert Advisor will always implement only 4 variants of events, if the Stop Loss coefficient is 2.

A) Take profit + 1 stop, the Expert Advisor will stop working

B) Take + 1 stop, the EA will stop working

C) Take + 2 stops EA stops working

D) 3 stops EA stops working

 
SGarnov:

Good afternoon. Help with the EA. According to the strategy, if a stop triggered, then the EA should add (the number of points) to the next set takeaway
from the history by ID, but it does not do it for some reason.

What is wrong in the code?

If you want to ensure minimal profit, it is enough to add spread to stop and take profit to some value. More precisely, the amount of arithmetic series * spread (how many spreads are lost, by how much is increased). Just do not increase the range much larger than the daily range.

The best option - in OrderMagic or Comment, save the initial value of the stop in points, or the number of failures in a row. In general, the Expert Advisor should remember all of its orders/positions and not interrogate the terminal (and the server) unnecessarily

 
Maxim Kuznetsov:

To make it work with minimal profit, it is sufficient to add spread to both stop and take. More precisely, the amount of arithmetic series * spread (how many spreads are lost, by how much they are increased). Just do not increase the range much larger than the daily range.

The best option - in OrderMagic or Comment, save the initial value of the stop in points, or the number of failures in a row. In general, the Expert Advisor should remember all of its orders/positions and not interrogate the terminal (and the server) unnecessarily

As for the code, it should, but I don't see it in the history. Can you help?
 

I'm asking for help from the community...
How to declare and create MQL5 global objects correctly?

If I do it this way:

int OnInit()
{
   CIsNewBar* NB_M1=new CIsNewBar(_Symbol,PERIOD_M1);  // Эта строка потом будет в цикле для разных символов
}

void OnTick()
{
    if (NB_M1.IsNewBar())  // (1) Если появился новый бар M1
        {....}
    ......
}

The compiler complains about the line in OnTick(): 'NB_M1' - undeclared identifier, which is logical, because a local variable is created in OnInit().

If you insert the global declaration before OnInit():

CIsNewBar* NB_M1;

it compiles without errors and expert works. It seems that the object is created twice - during the global declaration and in OnInit().
But in the compiler's warnings there is this :

declaration of 'NB_M1' hides global variable -> per line in OnInit()

see previous declaration of 'NB_M1'

Does it mean that a local variable (within a function) is created in OnInit() that hides a global variable with the same name ?
And if so, how can this local variable be "seen" by another function, OnTick() ?




 
SGarnov:

No. You don't need to add the previous ones. only when the EA starts working.

The Expert Advisor will always implement only 4 options, if the Stop Loss value is equal to 2.

A) Take

B) Take + 1 stop

C) Take + 2 stops

D) 3 stops

advisor stops working

I see, I'll give it a try.
 

I don't know who this message is addressed to yet. I cannot create an opaque panel. The OBJ_BITMAP_LABEL, OBJ_RECTANGLE_LABEL functions are designed to decorate or create new objects. But they do not have an option of non-transparency. Perhaps I haven't studied the language well enough or it is a flaw of the creators. The objects that are created in the foreground appear through the control panel. The other way round may be used, but it will overload the Procyc. If anyone knows how to do it please tell me.

 
MakarFX:
I see, I'll try it.

To make it easier take my source code, it has logic that works, except for the problem I described, I don't quite understand it, my head is boiling but I'm not getting anywhere.