[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 545

 
Vinin:

There are time constraints for init() function to work
I pull at least a dozen values from the market environment in my EA in init(). At the initial stage there were sometimes problems - now everything works. This is my personal experience - I do not claim to be a rule. ;)
 
silhouette:

Please help me to understand the problem of looking for divergence on the oscillators correctly. In this case let it be MACD. I have sketched out the following algorithm:

1) Count bars from the beginning and look for peaks on the oscillator:

2) Create arrays containing peak times:

and enter into them the MACD[i] value if the condition is fulfilled. The last new peak must have the index [n] and the penultimate one [n+1];

3) Let us consider a further solution under situation (1):

Actually, the problem with point 2: how to organize such an array like in a timeseries so that the values would shift at every new peak?


Please help!
 
paladin80:

Decided to poke around in your code a bit...


I'm very grateful to you for analyzing my code. Thank you for taking the time to do it.

I am just beginning to learn programming, so these comments are very important and will be helpful in the future.

Now to the point:

if (OrdersTotal()>0)
{  for (int i=OrdersTotal()-1; i>=0; i--)
   {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {   if(OrderSymbol() != Symb) continue;
          if(OrderMagicNumber() != 777) continue;
          return;
      }
   }
}

Really, the full search of orders is performed in this form, and further analysis is performed using open orders (everything is clear here)

Symb=  Symbol();
...
Min_Lot= MarketInfo(Symbol(),MODE_MINLOT);
...
Steep=   MarketInfo(Symbol(),MODE_LOTSTEP);

This part of the code is also changed but forum participants write that the market environment is not always available for the init() function.

Some variables may not be defined or I got something wrong?

I don't understand the logic of this post - (I'm explaining my view of this operator)

while(true)
...

I have an error handling block.

if (Fun_Error(GetLastError())==1)      // Обработка ошибок
continue;                              // Повторная попытка

If the error is correct, we try again to check the conditions and open the order.

And while operator works when its value is true, i.e. it turns out that it doesn't accept false.

Thank you guys for your help.

 
silhouette:

Please help!


Read here:https://www.mql5.com/ru/articles/1357 It's simple and straightforward

 
r772ra:


Read here:https://www.mql5.com/ru/articles/1357 It's simple and straightforward

Thank you!
 
Good day please help, I can not adjust my Expert Advisor (opening and closing orders do not work as expected (by crossing stochastic every time), open at stochastic very rarely and I can not understand why ((((), also all orders are closed only at stoploss or takeprofit (error ticket number, also can not understand where the error). thanks for any answers:
 
Vinin:
Just don't forget that the market environment is not always available in init()
Frankly speaking, I was very intrigued by this news. I tried to imagine under what conditions the market environment may not be available: maybe a connection failure at the moment of enabling the EA or if you run the EA on Saturday or Sunday. I have not noticed such problems with mine. On the one hand, they say that it is possible to loop in init() to find a value, but I have learned that init() is limited in time. Maybe at the beginning of start() at appearance of a new bar (at least at M1) to find values from the market environment, it is better than on every tick.
 
Pacman:


I am very grateful to you for analyzing my code. Thank you for taking the time to do it.

...

And the while statement works when its value is true, i.e. it turns out that it does not take false.

In while you should place a condition that can at least take two values, e.g., flag (true or false). If the code should contain a constant (true) instead of a condition, while is useless. Remove while (true) and brackets and you will get the same result.
 
Question for connoisseurs. In the OrderSend() help, slippage is 3. Is it for 4-digit quotes, for example? For 5-digit quotes can we leave 3 or do we need 30?
 
paladin80:
Question for Expert Advisors. The OrderSend() in place of slippage is 3. Is it for example for 4-digit quotes? For 5-digit quotes can I leave 3 or do I need 30?

For 5-digit ones you need 30.

I insert such a construction in init() of each EA, then it makes no difference for 4 or 5 digits DT, I recommend it:

  if (Digits==3 || Digits==5){myPoint=Point*10; slpg=slpg*10;}
  else myPoint=Point;