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

 
Galim_V:

Is there a simple software solution to my problem?

There is!


 
Yevhenii Levchenko:

Yes, we do!


Thank you for replying. Yes, we know the current value of the swap. And I need the result of the comparison with yesterday's value.

 
Galim_V:

Thank you for replying. Yes, we will know the current value of the swap. And I need the result of the comparison with yesterday's value.

Save yesterday's value in a variable and compare! :)

 
Yevhenii Levchenko:

Save yesterday's value in a variable and compare! :)

When you restart the terminal, will it be saved? Or are you talking about the terminal's global variable?

 
Galim_V:

When you restart the terminal, will it be saved? Or are you talking about the terminal's global variable?

No, it won't. To save, you need either a global variable or save to a file
 
Yevhenii Levchenko:
No, they won't. You either need a global variable or save to a file to make them saved.

I was making an info-panel, but I lost the source code. In doing so, avoided all entries, used informer functions. Decided to restore everything and add this swap problem. That's why I asked the question. Doesn't swap leave any traces in history, which is written by the terminal itself? But if there is no other option but to write, I'd like a hint, as I haven't worked with files and global. Considering that I need to compare 20 instruments once a day. Thanks for the time.

 
Galim_V:

I was making an info-panel, but I lost the source code. In doing so, avoided all entries, used informer functions. Decided to restore everything and add this swap problem. That's why I asked the question. Doesn't swap leave any traces in history, which is written by the terminal itself? But if there is no other option but to write, I'd like a hint, as I haven't worked with files and global. Considering that I need to compare 20 instruments once a day. Thanks for the time.

It's easier to use a global variable... The files are more of a hassle...
 

Finished the indicator on mt5 (translated from mt4). I wrote about it yesterday. It worked fine for me, but not so well for the client. As I understand, the problems appeared when the indicator was adding or removing other indicators programmatically. I blame theIndicatorRelease function...During deinitialization, indicators (except the current one) are removed from chart via ChartIndicatorDelete, then release handle via IndicatorRelease. The help states:

IndicatorRelease()

Удаляет хэндл индикатора и освобождает расчетную часть индикатора, если ею больше никто не пользуется.
Функция позволяет удалять хэндл индикатора, если он больше не нужен, и таким образом позволяет экономить память. Удаление хендла производится сразу, 
удаление расчетной части индикатора производится через некоторое небольшое время (если обращений к ней больше нет). 

During initialisation, handles are created back. And at first counting in OnCalculate, the indicators are added to the chart again. I added an empty loop in OnDeinit for 1000 passes to add some delay. I have no confidence in this solution. It worked fine for me before (although the terminal hung up once today), and the client started working fine today (at least for now).

The algorithm on mt4 works fine (never hung up there). The difference of mt5 is that here indicators are added programmatically (and calculated values of indicators need to be constantly copied in order to use them). While in mt4 they just copy the buffers for visualization (muwings and zigzags... like "adding indicators programmatically").

Do you know, may the problem be connected with the deletion and re-creation of handles (when parameters are changed, deinitialization and initialization immediately follow each other...)? Is there any way to check whether there is a handle of such indicator or not?

 

I still get non-normalized values after normalization - MQL5

up    = NormalizeDouble((up == 0 ? 1 * point : up),_Digits);
down  = NormalizeDouble((down == 0 ? 1 * point : down),_Digits);
sum   = NormalizeDouble((sum == 0 ? 1 * point : sum),_Digits);
minus = NormalizeDouble((minus == 0 ? 1 * point : minus),_Digits);
if(index <= 65 && index >= 55) Print(index," ",up," ",down," ",sum," ",minus);

Most unfavourable 1e-05, What to do?

 

Please advise how to solve the problem with calling indicator on MT5 windows 10 X64, I am doing it this way:

#resource "\\Indicators\\\MyIndicator.ex5"

handle=iCustom(NULL,0,"\\Indicators\\\\MyIndicator");

It used to work without #resource, then it only started working with #resource, now nothing works, error 4804 is generated

Reason: