Questions from a "dummy" - page 66

 
Yedelkin:

It all depends on the logic of the custom indicator. In principle, it can recalculate its values once a day, skipping all other ticks. According to the author's will, so to speak.

Basically, some people try to use this monster approach: create a copy of the indicator via iCustom, copy the necessary data, delete the copy of the indicator. The procedure is repeated as needed.

There is also the function OnTimer(). I haven't worked with it myself, but maybe you can adapt it to your task.

Thank you. I thought so. The OnTimer is not suitable.

There is a situation when the indicator is on M5 but it is called once an hour, for example. It turns out that the indicator will be calculated in the Expert Advisor in idle every 5 minutes for the sake of calling it once an hour. That's why I am wondering if there is a possibility to pause the recalculation of the indicator.

 
masharov:

There is a situation when the indicator is on M5, but it is called once an hour for example. It turns out that the indicator will be calculated in the Expert Advisor idly every 5 minutes for the sake of calling it once an hour.

And you can't rewrite the indicator so that it is called hourly?
 
Yedelkin:
Can I rewrite the indicator so that it calculates hourly as well?
The trade is on M5. It is unknown when the indicator will be called. It may be once every two hours, or it may be three times per hour. The indicator is used to confirm the decision to make a trade.
Способы вызова индикаторов в MQL5
Способы вызова индикаторов в MQL5
  • 2010.03.09
  • KlimMalgin
  • www.mql5.com
C появлением новой версии языка MQL, не только изменился подход к работе с индикаторами, но и появились новые способы создания индикаторов. Кроме того, появилась дополнительная гибкость при работе с индикаторными буферами - теперь вы можете самостоятельно указать нужное направление индексации и получать ровно столько значений индикатора, сколько вам требуется. В этой статье рассмотрены базовые методы вызова индикаторов и получения данных из индикаторных буферов.
 
masharov:
trading is going on M5. It is not known when the indicator will be called. It could be once every two hours, or it could be three times in an hour. The indicator is used to confirm the decision to trade.
The logic is clear. In such cases, I did it in a smart and simple way: I transferred the block of calculations from the indicator directly into the Expert Advisor. I.e. instead of the external data source (indicator), the Expert Advisor used one of its functions - the one that reproduced the indicator's calculation algorithm. In this case, this function was called as needed, with complete recalculation of the necessary values.
 

Hello, Could you please tell me,

1)What to do with errors likeTRADE_RETCODE_LOCKED,TRADE_RETCODE_FROZENand in which case request is blocked or position/order is frozen?

2)Also I wonder what to do withTRADE_RETCODE_INVALID_FILLand in what case it occurs?

 
PunkBASSter:

Hello, Could you please tell me,

1)What to do with errors likeTRADE_RETCODE_LOCKED,TRADE_RETCODE_FROZENand in which case request is blocked or position/order is frozen?

2)Also wondering what to do with TRADE_RETCODE_INVALID_FILLand in which case it occurs?

1) Check the forum search. It was discussed about a year ago.

2) Look in the ENUM_ORDER_TYPE_FILLING reference . Probably a mismatch in the trade request for the specified "execution order type" to the execution mode and will result in the specified return code.

For example ORDER_FILLING_FOK and SYMBOL_TRADE_EXECUTION_MARKET.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
Yedelkin, thank you very much)
 
masharov:

I have a suspicion that if the indicator is activated through iCustom, it is calculated on every tick. And it doesn't depend on the calls to it through the CopyBuffer. Is it correct?

If it is correct, then is it possible to disable the calculation of indicator and enable it only before calling the CopyBuffer?

If I understood you correctly, then you can try to limit calculations on next ticks by example from iFractals help (see multiple conditions in OnCalculate).

Perhaps, you can also flag in OnCalculate the initial execution of indicator calculations for all necessary bars and check the server time of the terminal, and after it happens, to reset the flag to false, thereby allowing the recalculation, and set it to true again... and so on.

Or even so: write an external function with calculations, call it in OnInit, where it will run once at first start of indicator (as well as when changing TFs and etc., that occurs at the user's initiative), and then call the same function in OnCalculate in the second way (at the specified time on the server and by flagging).

But the first method is good, not only doesn't load the processor with full recalculations (often leading to no new results) at every tick, but won't even do full recalculations at a given time interval, and will only calculate the newest bars (if at every tick, then one new one, and if once t, then several accumulated during this time)... Although this version is better to check personally, I can be wrong... Also, everything depends on the specific purpose of the indicator. If it depends on a large or even the whole market history, then you can't get rid of recalculations of the whole history.

 

Didn't get the humour of the joke (writing an indicator, though it makes no difference):

struct TBuffer
{
  double buffer[];
};

TBuffer BuffArray[4];

Compiles without errors or warnings.

int elements=4;

struct TBuffer
{
  double buffer[];
};

TBuffer BuffArray[elements];

Compiled with1 error(s), 0 warning(s): 'elements' - invalid index value.

What can be past the obvious common sense here?

 
x100intraday:


What can be past the obvious common sense here?

the number of array elements is specified by a constant

If the number of elements is not known beforehand, use ArrayResize to set the size using variables.

This is the basics of c++.

So either

#define  elements 4
Reason: