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

 
Alexey Viktorov #:

It doesn't work likethis?

Artyom Trishkin #:
For example, ZeroMemory().

Thank you very much! I will try

 
A curious thing: when reading the date of the earliest minute bar(iBars(....) about 30000 bars) which is in the chart window, the value appears to be 1970. Although the bar there is somewhere from February last year.

Is this a specificity or is the history messed up?
 
Ivan Butko (iBars(....) about 30000 bars) which is in the chart window, the value turns out to be 1970. Although the bar is somewhere around February of last year.

Is this specific, or is the story messed up?

January 1, 1970 is a null value in datetime type.

 
JRandomTrader #:

January 1, 1970 is a null value in datetime type.

I don't quite understand.

Please tell me why iTime(Symbol(), PERIOD_M1, iBars(Symbol(),PERIOD_M1)) = 1970.01.01 00:00:00 ?

iBars(Symbol(),PERIOD_M1)) = 39487

And iTime(Symbol(), PERIOD_M1, iBars(Symbol(),PERIOD_M1)) + 2 = 2022.02.09 08:04:00


 
Ivan Butko #:

Not quite clear.

Please tell me why iTime(Symbol(), PERIOD_M1, iBars(Symbol(),PERIOD_M1)) = 1970.01.01 00:00:00 ?

iBars(Symbol(),PERIOD_M1)) = 39487

The iBars() function returns the number of bars, but they are numbered starting from zero. If you put the

#property strict

you will get an error of array overrun.

Check it this way

iTime(Symbol(), PERIOD_M1, iBars(Symbol(),PERIOD_M1)-1)
 
Alexey Viktorov #:

The iBars() function returns the number of bars, but they are numbered from zero. If you put

at the beginning of the code, you will get an error of array overrun.

Check it this way!

Thank you!

It works!

 

Colleagues, I'm stumped. I need some help.

I have a normally working indicator, I made it from two, but that's not the point. I want to hide the first block of external variables, but when I remove any input in this block after compilation, the terminal with the indicator installed on the chart hangs.

The code fragment from line 76 to 86

input string     01 = "••  Channel:";   // ------------------------------------------------------------
input string     02 = "";       //  

input ENUM_TF_MINUTES   TMA_TimeFrame = TF_CURR;                        // Time Frame
input uint              TMA_Half_Length = 55;                                                                   // Averaging Period
input ENUM_APPLIED_PRICE        TMA_Price = PRICE_CLOSE;        // Applied _Price
input double    TMA_ATR_Multiplier = 3;                                                         // ATR Multiplier
input uint              TMA_ATR_Period = 100;                                                                   // ATR Period
input double    TMA_Band_Deviation_Percent = 50;                        // Band Deviation Percent
input bool              TMA_Interpolate = true;                                                         // Interpolate?
input uint Bars_Limit=1000;

It also hangs if I move all this block lower than other variables and even if I move outermost variables up or down:

If I change the order of the variables within the block, it compiles normally. The terminal does not freeze.

I don't understand what's going on. Maybe I don't see something obvious, my eye has blurred ((( I attach the code

P.S. The issue has been resolved, the code has been removed.
 
Andrey Kaunov #:

Colleagues, I'm stumped. I need some help.

I have a normally working indicator, I made it from two, but that's not the point. I want to hide the first block of external variables, but when I remove any input in this block after compilation, the terminal with the indicator installed on the chart hangs.

The code fragment from line 76 to 86

It also hangs if I move all this block lower than other variables and even if I move outermost variables up or down:

If I change the order of the variables within the block, it compiles normally. The terminal does not freeze.

I don't understand what's going on. Maybe I'm missing something obvious, my eye is blurry (((( I'm attaching the code

Replace input with const

and rejoice !

 
Maxim Kuznetsov #:

replace input with const

and rejoice !

Doesn't help, still hangs the terminal when adding an indicator to the chart.

 
Andrey Kaunov #:

Doesn't help, terminal still hangs when adding indicator to chart.

Does it compile?

So if the parameter has an input attribute, it works, but if const, it hangs ?

there is no such a miracle

Reason: