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

 
Igor Makanu:

datetime o_open = OrderOpenTime();

MqlDateTime dt_struct;

TimeToStruct( o_open, dt_struct;)

int min = dt_struct.min;

Senx.
 
Do I understand correctly that new sheets cannot be created when writing to the csv (programmatically, from the terminal)?
 
Yevhenii Levchenko:
new sheets when writing to csv
Stumped. I tried to save a book with 3 sheets in csv from Excel:


There are only column separators inside the csv, I don't think there is any other markup
 
Aleksei Stepanenko:
Baffling. Tried from Excel to save a book with 3 sheets to csv:


There's only column separators inside the csv, there's no other markup

Oops! Didn't know this was a feature of the format. Me, when trying to save a book with multiple sheets, it doesn't unsubscribe like that... It just erases the previous sheet and saves a blank new one

Thank you!

 
Yevhenii Levchenko:

You're welcome :)

 
Good day. Please tell me please, Iwrote an indicator with Alert (message and sound outputs under certain conditions), everything works, but every time I change Timeframe chart, it gives a signal again. How can I fix it? The Alert code is placed in a separate function that is called to check from OnCalculate. If it is just an EA, it works fine, but I need it with graphical representation as I have done, without triggering again when change of timeframe.
Как самому создать советника или индикатор - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
Как самому создать советника или индикатор - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
  • www.metatrader5.com
Для разработки торговых систем в платформу встроен собственный язык программирования MetaQuotes Language 5 (MQL5), среда разработки MetaEditor и инструменты тестирования стратегий. Любую информацию о разработке торговых стратегий на языке MQL5 можно найти на официальном сайте MQL5.community. На этом же сайте в разделе Code Base могут быть...
 
Progaus:
Good afternoon. Can you please tell me please, Iwrote an indicator with Alert (message and sound outputs under certain conditions), everything works, but every time you change timeframe chart, again gives a signal. How can I fix it? The Alert code is placed in a separate function that is called to check from OnCalculate. If it is just an EA, it works fine, but I need it with graphical representation as I have done, without triggering again when change of timeframe.

When the timeframe is switched, the indicator starts from 0.

Accordingly, we should teach it to remember that Alert has already been issued - reliably, by storing such information in global variables of the terminal or in a temporary file, and it seems to be possible (I haven't used it myself) just to make a static variable.

For example, you can save time of last alert and not whistle a new Alert if time has passed less than 2 seconds.

 
Maxim Kuznetsov:

and it seems to be possible (I haven't used it myself) just to make a static variable.

When you switch TF, a new copy of the indicator is created and the old one is deleted.

for EA it is possible (and necessary ?) to use static (or globally declared) variables ... there are however some nuances, but in general there are no problems

Maxim Kuznetsov:

when you switch timeframe, indicator will start from 0.

prev_calculated will be reset to zero at the first call of OnCalculated()



i.e., create a global variable of the terminal or a graphic object as a marker that the indicator was already on this chart and look for this graphic object during the first call.

 
Colleagues, apologise at once for the elementary question, it's just that I'm not at my computer at the moment, but I have to.
What's the best way to find out the current time in minutes.
 
Aleksey Masterov:
Colleagues, sorry at once for the elementary question, I just do not have a computer, but I have to.
What is the best way to find out the current time in minutes.

TimeCurrent()https://www.mql5.com/ru/docs/dateandtime/timecurrent

Use the second version of the signature of this function:

datetime  TimeCurrent(
   MqlDateTime&  dt_struct      // переменная типа структуры
   );


ZS: I should tell at once - it works in MT4, I used it ;)

UPD: in MT4 I also used Hour() and Minute() - I don't use them for a long time, but they should give the last server time in hours and minutes

Reason: