Questions from Beginners MQL5 MT5 MetaTrader 5 - page 408

 
Tapochun:
It all depends on the logic of the indicator. Most often - yes, in the OnCalculate() function.
The"OnCalculate() function is called only in custom indicators when it's necessary to calculate the indicator values by theCalculate event. This usually happens when a new tick arrives for a symbol" - how then to make the calculation run only once at the appearance of a candle. In mql4 there was some kind of check.
 
first_may:
The"OnCalculate() function is called only in custom indicators when it's necessary to calculate the indicator values by theCalculate event. This usually happens when a new tick is received by the symbol" - how then to make the calculation run only once at the appearance of a candle. In mql4 there is a check.
The easiest way, if not the first tick (prev_calculated != 0) and rates_total > prev_calculated.
 
Tapochun:
Easiest if not the first tick (prev_calculated != 0) and rates_total > prev_calculated.
Yeah :). Maybe I should find an example of two exponential moving averages crossing (I saw it somewhere) and redo it.
 
first_may:
Yeah :). Maybe I should find an example of two exponential moving averages crossing (I've seen it somewhere) and redo it.
When you start - it's always better to do by examples! Separate lines of code will hardly help you. Good luck!
 

How do I intercept the closing event on the current tick? There are no standard means? I.e. when opening a trade you have to write something like:and then check on every tick:

//Инициализация
int totalOrders=0;
...
//Открытие новой сделки
int ticket = OrderSend(....)
if(ticket > 0)
    totalOrders++;

and then check on every tick:

if(totalOrders != OrdersTotal())
    //Обработка события закрытия сделки
 
gammaray:

How do I intercept the closing event on the current tick? There are no standard means? I.e. when opening a trade you have to write something like:and then check on every tick:

and then check on every tick:

You need to compare the number of positions monitored on the previous tick with the number on the current tick. If the current tick has become less - we save (remember) the current value of the positions being tracked as "past" and process the fact of closing.
 
gammaray:

How do I intercept the closing event on the current tick? There are no standard means? I.e. when opening a trade you have to write something like:and then check on every tick:

and then check on every tick:

I do not understand anything. What value do you want to get?

I read what you wrote this way

{

Opening of an order;

If the order opens, then

TotalOrder = TotalOrder+1;

}

) by default totalOrder =0, but after each opening of an order the value will increase, after 10 openings (the value will be exactly 10) the counter of all ever opened positions (no check by type, by Magik and by symbol = it will add absolutely all open orders)

And the next condition looks like this

if TotalOrder is not equal toOrdersTotal {}

 
Good afternoon to all! I appeal to the knowledgeable. I need a simple EA, whose task will be to change the stops on triggered orders on LOW or HIGH candlesticks every period of the TF. I have a table myself unfortunately. I don't know if it has already been placed there. I have not found it. What was it - with additives that clutter up.

 
mefos:
Good afternoon to all! I appeal to the knowledgeable. I need a simple Expert Advisor, whose task will be to change the stops on the triggered orders on LOW or HIGH candlesticks every period of the TF. I have a table myself unfortunately. I don't know if it has already been placed there. I have not found it. What was it - with additives that clutter up.

That's for you, dear boy, to the order desk. Here only advise and help with code problems.
 
Ivan Vorontsov:
It's up to you, mate, to the order desk. They only give advice and help with code problems here.
+++
Reason: