Questions from Beginners MQL5 MT5 MetaTrader 5 - page 384

 
le0nid2014:
...

if (OrdersTotal() == 0 && ********** )

OrderSend("USDCHF",OP_BUY,Lots,Ask,0,0,0, "5891",MagicNumb,0,Red);


if (OrdersTotal() == 0 && ***********)

OrderSend("USDCHF",OP_SELL,Lots,Bid,0,0,0, "58892",MagicNumb,0,Red);

...
You are looking in the wrong direction. Everything was already told to you. I even gave an abstract example above. Or is it too lazy to do a search?
 
Artyom Trishkin:
If you have two Expert Advisors, they should have the same wizard. They should be launched on different charts for one symbol. In general, of course, it is easier to improve the main one than to start another one.

I can't improve it, it's from the Market.

I can't use it on 2 charts because I can't find any suitable conditions. It will open orders in 2 directions when there are 0 left.

 
Artyom Trishkin:

Well, the check is a function call that returns a flag:

if(!Function_check_open_position(symbol,OP_BUY,magic)) function_open_position(symbol,OP_BUY,Lots,stop_loss,take_profit,magic,comment);
if(!Function_check_open_position(symbol,OP_SELL,magic)) Function_open_position(symbol,OP_SELL,Lots,stop_loss,take_profit,magic,comment);

Here, first, if we need to find out if there is an order following the code again, we will have to call the function once again. And if we memorize the value into variables, we can pass them further without calling the function again. Secondly, it is a matter of taste, I don't like to make complex constructions, especially if there are a few conditions or a lot of arguments are passed to a function. It worsens understanding of the code.
 
Vitalie Postolache:
Yeah, my mistake came out when talking about "no inludes", this feature is just in the Trade.mqh inluder.

No problem. I closed with the opposite one.

The end is written in a blink of an eye, it takes longer to make a signal.

on the 4-rka it seems to be worse from this point of view....

and that multicurrency is a beauty, I can't believe my eyes.

BRAVO to the developers! //transition for the first time was exactly 1 day.

 
Tapochun:
First of all, if you want to find out if there is an order again, you will have to call the function again. And if you want to store the value in variables, you can pass them further without calling the function again. Secondly, it is a matter of taste, I don't like to make complex constructions, especially if there are a few conditions or a lot of arguments are passed to a function. It makes understanding the code worse.
Judging by the question, there is nothing else you need there.
 
le0nid2014:

I can't improve it, it's from the Market.

It can't work on 2 charts because I can't find suitable conditions. it will open orders in 2 directions when there are 0 of them left. it needs 2 directions to work

I have already told you how to implement it and how to open orders in 2 directions. You have already been told how to do it.
 
Artyom Trishkin:
Judging by the question, there is nothing else needed there.
Projects are expanding, you should try to think ahead.
 
Tapochun:
The projects are expanding,

Artyom Trishkin:
It should work on one chart, and the second - a simple one that opens two positions - on the other. You have already been told how to do it.

You're not a bit inadequate.Goodbye.

 
Tapochun:
Projects are expanding, you have to try to think ahead.

Yeah, thanks for the science. I'll be sure to think about it...

ZS. What prevents then to return the check not in a condition, but in a variable and already check it? Probably the wildest complexity of this project in the future...

And one more thing: if the project is being expanded, the code execution time may increase too. As a result, there will be a lot of calculations to be performed after the data is written into the variable. So, isn't it possible that by the time we need a second check, the order will have already been closed (at a stop, for example ... or take ...), and the program will then calculate an incorrect value stored in the variable?

Exactly - we must think in advance about large projects and all the possible situations that may occur. So I stand by my conviction - always have the latest data just before you use it. As far as possible.

 

le0nid2014:

You're a bit inadequate.Goodbye.

Are you talking to me? All right, have a nice day. But you'll go back to what I suggested at the end, thereby joining the ranks of the inadequate.
Reason: