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

 

What is the problem with the code? I change the timeframe for the indicator using buttons from the panel
but the comment returns an incomprehensible number

   zz_handle=iCustom(_Symbol,TF,"Examples\\ZigZag",ExtDepth,5,3);
   int _bars=Bars(_Symbol,TF);
   ArrayFree(zz_time);
   ArrayFree(zz_value);
   CopyBuffer(zz_handle,0,1,_bars,zz_value);
   CopyTime(_Symbol,TF,1,_bars,zz_time);
   Comment(zz_time[_bars-1]);
 
Roman Sharanov:

What is the problem with the code? I change the timeframe for the indicator with the buttons from the panel
but the comment returns some unclear number

If I'm not stupid, it'sComment(zz_time[0]);

 
Vitaly Muzichenko:

If I'm not stupid, it'sComment(zz_time[0]);

I didn't put it as a timeseries, I need it to go from the back of the story to the last bar

 

Oh, I found the mistake!

I'm copying from 1 bar and the number of bars counts from the current bar, so I was always going outside the array

I madebars=Bars(_Symbol,TF) - 1; and at least the errors disappeared

 
Roman Sharanov:

Oh, I found the mistake!

I'm copying from 1 bar and the number of bars counts from the current bar, so I was always going outside the array

I madebars=Bars(_Symbol,TF) - 1; and at least the errors disappeared

Read carefully whatCopyBuffer(handle,0,1,bars, value) can do;

 
lil_lil:

Says, how do I get it to write every 120 seconds within 30 minutes of the bar opening?

Here's the answer.

Forum on trading, automated trading systems & strategy testing

Any MQL4 beginners questions, help and discussion on algorithms and codes

Alexey Viktorov, 2018.02.13 18:58

If you have any questions, please do not hesitate to use this article, we will solve them.

So why write them? Take any day and read the opening price of even or odd minutes PERIOD_M1...
datetime начало_дня;
CopyOpen(_Simbol, PERIOD_M1, начало_дня, начало_дня+30*PeriodSeconds(PERIOD_M1));
This will be an array of 30 elements every 60 seconds. Each even-numbered element of the array will be 120 seconds apart.
 
Roman Sharanov:

Oh, I found the error!

I'm copying from 1 bar and the number of bars counts from the current bar, so I was always going outside the array

I madebars=Bars(_Symbol,TF) - 1; and at least the errors disappeared

Put a directive at the beginning of the program:

#property strict

Then all errors, like array overruns and division by 0, will cause the program to stop and print out a log message about the error, specifying the line where the error occurred. 90% of "incomprehensible" actions of the program will disappear at once.

 
snegosplav:
Good day! Please help me to improve copier code. The problem is the following: EA (Slave) prints the message about no access to the file, no matter what I do... What's wrong?

Decompiled by Artyom Trishkin

Note to you.

How can you post the code?
 
snegosplav:
And how can you post the code?

The one you had - you can't - it's a decompile. If you violate it again, you're banned for 24 hours, then it's up to a week, a month, 10 years, and the account is deleted.

 
Can the function itself be called from the function? and do this until the condition is true
Reason: