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

 
SanAlex:

I also experimented - I opened the camera and couldn't close it - until I killed the process.

https://www.gunsmoker.ru/2015/01/avoid-using-ShellExecuteEx.html

Почему вам не следует использовать ShellExecute(Ex)
  • 2015.01.05
  • GunSmoker
  • www.gunsmoker.ru
В прошлый раз мы узнали, почему вам никогда не следует использовать функцию . В этот раз я расскажу вам о том, почему вам не следует использовать функцию . Заголовки этого и предыдущего постов выбраны крайне тщательно. Предыдущий пост говорил о том, что если вы пишете код в 1995 году или позднее, то вы не должны использовать функцию . Поскольку...
 

Could you please tell me what the problem is?

     if(buy_lots>0||sell_lots>0)
      ChartSetSymbolPeriod(0,Symbol(),PERIOD_M15);
     if(buy_lots==0||sell_lots==0)
      ChartSetSymbolPeriod(0,Symbol(),PERIOD_M5);

If there are no open orders, then M5 is enabled and everything is fine,

But as soon as an order opens, it starts jumping M5,M15,M5,M15...

 
MakarFX:

Could you please tell me what the problem is?

If there are no open orders, then M5 is enabled and everything is fine,

But as soon as I open an order, it starts bouncing on M5, M15, M5, M15...

It's just like it says, that's how it happens.

Or replace in the lower one with AND

 
Valeriy Yastremskiy:

It's just as it's written, that's how it works.

Or replace in the lower one with E

Thanks, I did, but the result is the same

     if(buy_lots>0||sell_lots>0)
      ChartSetSymbolPeriod(0,Symbol(),PERIOD_M15);
     if(buy_lots+sell_lots==0)
      ChartSetSymbolPeriod(0,Symbol(),PERIOD_M5);
 
MakarFX:

Thank you, I replaced it, but the result is the same.

  
      Alert("1 buy_lots ",buy_lots," sell_lots " sell_lots);
    if(buy_lots>0||sell_lots>0)
      ChartSetSymbolPeriod(0,Symbol(),PERIOD_M15);
     Alert("2 buy_lots ",buy_lots," sell_lots " sell_lots);
     if(buy_lots==0 && sell_lots==0)
      ChartSetSymbolPeriod(0,Symbol(),PERIOD_M5);

So something is missing. So the sum ofbuy_lots+sell_lots=0

And better than addition. Either Alert or Print to help.

 
Valeriy Yastremskiy:

So something is missing. So the sum ofbuy_lots+sell_lots=0

And better than addition. Either Alert or Print to help.

How is it better?

(0 == 0 and 1 == 0) - condition is not fulfilled

(0 + 1 == 0) - the condition is also not fulfilled

What is the difference between AND and addition in this particular example?

 
MakarFX:

Thank you, I replaced it, but the result is the same

So check buy_lots and sell_lots values probably lose their values somewhere.
 
Alexey Viktorov:
So check buy_lots and sell_lots values, they are probably losing their values somewhere.

Print


It is not clear why it switches to M5

 
MakarFX:

Print


It is not clear why it switches on M5

When the TF is switched, the EA is restarted. Try putting prints under condition, switch and Print. Or vice versa.

And we should definitely add period check into the condition. If you switch to M15, why switch again?

 
Igor Makanu:

this is why it is recommended to try to do EA work exclusively with your magicians

If the task is to open an order once a day at a certain time, the algorithm is as follows:

- start EA, it checks the number of open orders, if the order with our magician is open, then exit until the next tick

- if there are no orders, the EA waits until the current hour and minutes are greater than the given ones

- this time has come, EA will check the order history and if ha hasn't placed an order with our magik, then it will set an order and exit - exit is useful not to process server errors, if the order has not been set, then on the next tick we will try to do it again, i.e. it is not necessary to organize a cycle for repeated order opening on this tick.... but this is a matter of taste and objectives, it is the easiest implementation)))

Please tell me what EA means in your context. I want to find, and read more detail.....
I want to find it and learn more about it on the following website: Thank you.

Reason: