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

 
the bar index and I take it to determine the timing of the bar. Apparently we need to dig deeper here, going to seconds in bar formation time
 
Evgeniy Butakov:
I take the bar index to determine the time of the bar. Apparently, we need to dig deeper here, to pass to the seconds in bar formation time

Read the documentation carefully. Pay attention to the function overloads.

Why are you taking the number of bars from time to time? I am writing you from time to time.

int  CopyRates( 
   string           symbol_name,       // имя символа 
   ENUM_TIMEFRAMES  timeframe,         // период 
   datetime         start_time,        // с какой даты 
   datetime         stop_time,         // по какую дату 
   MqlRates         rates_array[]      // массив, куда будут скопированы данные 
   );

From what date to what date, not just date, but date_time. So, take from bar open time minus 2*PeriodSeconds(PERIOD_M15) to the time of the next bar H4

 
Alexey Viktorov:

Read the documentation carefully. Pay attention to the function overloads.

Why are you taking the number of bars from time to time? I am writing you from time to time.

From what date to what date, not just date, but date_time. You need to take from the bar open time minus 2*PeriodSeconds(PERIOD_M15) to the time of the next bar H4

I have got the hang of it... I converted the needed time "from which date" and "to which date" to seconds and I am following it... And why exactly 2*PeriodSeconds(PERIOD_M15)? 900 seconds is enough for me, i.e. one bar on M15. Thanks a lot!!!

 
Evgeniy Butakov:

I've figured it out... I converted the required time "from which date" and "to which date" to seconds and I'm dancing from them... And why exactly 2*PeriodSeconds(PERIOD_M15)? 900 seconds is enough for me, i.e. one bar on M15. Thanks a lot!!!

Based on this wish

Evgeniy Butakov:

Good afternoon!

For the second time with my task to calculate inside the bar of higher frame (H4) at the expense of bars of lower one. I have understood how to get the data on M15 on the bar from H4. But I got stuck at this point. For example, I collect data from the M15 TF on the 3rd H4 candle and as a result I process all 16 candles within the 3rd bar. But how do I get some more bars on M15 in addition to those 16, because they will already be from the 4th candle on H4? Please guide me, give me a hint.

To retrieve data from M15 uses the following code:

If you need one bar, just don't multiply and that's it.

And one more free tip: Give up seconds. Which is clearer when reading someone else's or your own code after some time 1800 or 2*PeriodSeconds(PERIOD_M15) which means 2 bars of M15 period expressed in seconds. And what will a week or a month be in seconds? Should I recalculate every time or clog my memory cells with unnecessary information?

 
Alexey Viktorov:

Based on this wish.

If you need one bar, just don't multiply and that's it.

And one more free tip: Do away with seconds. Which is clearer when reading someone else's or your own code after some time 1800 or 2*PeriodSeconds(PERIOD_M15) which means 2 bars of M15 period expressed in seconds. And what will a week or a month be in seconds? Should I recalculate every time or clog my memory cells with unnecessary information?

Yes, Alexey, thanks for the guidance and direction. I completely forgot about the PeriodSeconds function ;).
 
int file = FileOpen("expert_file", FILE_WRITE | FILE_BIN);
   if (file != INVALID_HANDLE){
      uint file_bytes = FileWriteArray(file, file_data);
      FileClose(file);
      Print("Bytes count: ", file_bytes);
      Print("Error: ", GetLastError());
   } else{
      return false;  
   }    

Trying to write an array of bytes to a file.

Log

The file itself.

That is, the program returns that it has written 186368 bytes into the file, but the file itself is completely empty. And there is no error.

 

Hi.

There's a problem. A deposit of, let's say, 1k has been made to a brokerage account. Then this deposit was replenished with 5k more. As the result in MT5 "history" report the initial 1k is shown as a deposit and the replenishment is shown as a profit, and naturally all trade results are going over the top.


Question: Can I manually set the size of the initial trading balance, from which it should calculate the profit?


Thanks in advance ^^

 
MQL_User:

Is there any way to determine from the OnChartEvent whether a button was pressed on the keyboard when the mouse clicked on the graphic?

There is a function called GetAsyncKeyState. Can it be used in the code?

I tried such a construction:

#import "user32.dll"
int GetAsyncKeyState(int a0);
#import

printf("--"+(GetAsyncKeyState(88)));

But the DLL loading is not allowed.

I ticked the "Allow DLL imports " box at the start. Didn't help.
 
Maybe I'm in the wrong thread. May the gods forgive me Mcl!!! I need to write an indicator, which would give a signal from a combination of four or five indicators.Set in the basement.Maybe there is a template. Or a ready-made advisor.Possible advice please!!!!!!!!!!
 
How can I add an expert advisor to an mql5 folder and for it to show in the advisor section?
Reason: