Questions from Beginners MQL5 MT5 MetaTrader 5 - page 591

 
barudkinarseniy:
I don't see any problems, my Expert Advisor just works in such a way that after closing a profitable or losing trade it opens orders immediately and the ticket number in the printer is very big, so I thought it would not have to reload it manually, maybe it can be done automatically. I should thank you for this function also))
If you look at the 1000 orders in a year it's nothing, just look at tickers on real accounts. I have, for example, the last 10179697. Generally, tickets are of int type, hence the maximum value is 2 147 483 647.
 
Alexey Volchanskiy:
1000 orders in a year is nothing, look at the tickets on real accounts. I have, for example, last 10179697. Generally, tickets are of int type, therefore maximum value is 2 147 483 647.
And what will be if the maximum value is reached?
 
in MQL5 the ticket is of the ulong type, you will be out of breath to exceed
 
barudkinarseniy:
And what happens if it reaches the maximum value?
Numbers for orders and trades are assigned by the broker, not by your EA, and the EA will make sure that they do not exceed the maximum value. ) This is not your headache.
 
Thanks for the useful information))) Any idea how to check limit orders with AccountFreeMarginCheck?
 

I took the standard Demark Expert Advisor from the library, it seems to work. I started to refine it.

double DU = iCustom(NULL, 0, "itdlines", Level, 0, 0);

double DD = iCustom(NULL, 0, "itdlines", Level, 1, 0);

double DU1 = iCustom(NULL, 0, "itdlines", Level, 0, 1);

double DD1 = iCustom(NULL, 0, "itdlines", Level, 1, 1);

I added calculations and additional output data to this indicator and it works out as follows

double DU = iCustom(NULL, 0, "itdlines", Level, 0, 0);

double DD = iCustom(NULL, 0, "itdlines", Level, 1, 0);

double DU1 = iCustom(NULL, 0, "itdlines", Level, 0, 1);

double DD1 = iCustom(NULL, 0, "itdlines", Level, 1, 1);

double LUN = iCustom(NULL, 0, "itdlines", Level, 2, 0);

double LDN = iCustom(NULL, 0, "itdlines", Level, 3, 0);

double KUN = iCustom(NULL, 0, "itdlines", Level, 4, 0);

double KDN = iCustom(NULL, 0, "itdlines", Level, 5, 0);

and it starts to lag, i.e. i get errors of invalid data.

The question is if I have created the same indicator 8 times and got the right array from it, or am I wrong? Or am I wrong, an indicator is created once?
If I'm right, how can I create it once and get the required data from it?

 

Hello colleagues!

Please advise on the structure of a trade request to close a position in MT5 with a hedge.

Thank you.

 
Nikita Solodko:

Hello colleagues!

Please advise on the structure of a trade request to close a position in MT5 with a hedge.

Thank you.

You can use the method
bool  PositionClose( 
   const ulong   ticket,                  // тикет позиции 
   ulong         deviation=ULONG_MAX      // отклонение 
   )
from the standard library of the CTrade class
 
Sergey Gritsay:
You can use method from standard library of CTrade class
Thank you, of course, but I'm not using trade classes, I prefer to use OrderSend() function. And everything was fine before the possibility of hedge, but now in the structure of trade request appeared element"position", as it is said in help, to indicate a specific position when modifying and closing it, only it is not said how to close this position (type of operation or so).
 
Milleras1981:

I took the standard EA for the demark from the library, it seems to work. I started to refine it.

double DU = iCustom(NULL, 0, "itdlines", Level, 0, 0);

double DD = iCustom(NULL, 0, "itdlines", Level, 1, 0);

double DU1 = iCustom(NULL, 0, "itdlines", Level, 0, 1);

double DD1 = iCustom(NULL, 0, "itdlines", Level, 1, 1);

I added calculations and additional output data to this indicator and it works out as follows

double DU = iCustom(NULL, 0, "itdlines", Level, 0, 0);

double DD = iCustom(NULL, 0, "itdlines", Level, 1, 0);

double DU1 = iCustom(NULL, 0, "itdlines", Level, 0, 1);

double DD1 = iCustom(NULL, 0, "itdlines", Level, 1, 1);

double LUN = iCustom(NULL, 0, "itdlines", Level, 2, 0);

double LDN = iCustom(NULL, 0, "itdlines", Level, 3, 0);

double KUN = iCustom(NULL, 0, "itdlines", Level, 4, 0);

double KDN = iCustom(NULL, 0, "itdlines", Level, 5, 0);

and it starts to lag, i.e. i get errors of invalid data.

The question is if I have created the same indicator 8 times and got the right array from it, or am I wrong? Or am I wrong, an indicator is created once?
If I'm right, how can I create it once and get the required data from it?

Before you improve it, the Expert Advisor received 4 values: from the zero indicator buffer of the last and penultimate bar, and from the first indicator buffer as well, while you are trying to receive information from 6 indicator buffers... Are you sure you have them in the indicator? What are you trying to achieve?