Questions from Beginners MQL5 MT5 MetaTrader 5 - page 868

 
Aleksey Vyazmikin:

For a one-bar shift, I've done this so far

Can you tell me whereiTime is located? I couldn't find it in the help, it looks like a standard library.

 
Aleksey Vyazmikin:

For a shift of one bar I have done so far

Alexey, is this a mql4 question?

If not, then please tell me, why are you pulling mql5 by the ears to mql4?

 
Sergey Savinkin:

Can you tell me whereiTime is located? I couldn't find it in the help, it looks like a standard library.

This is a self written function

Forum on trading, automated trading systems & strategy tester

FAQ from Beginners MQL5 MT5 MetaTrader 5

Aleksey Vyazmikin, 2018.05.23 11:48


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
datetime iTime(string symbol,int tf,int index)
  {
   if(index < 0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[];
   if(CopyTime(symbol,timeframe,index,1,Arr)>0)
      return(Arr[0]);
   else return(-1);
  }



 
Aleksey Vyazmikin:

This is a self-written function.


Thanks. Then I won't ask whatTFMigrate(tf) is))))

Only if it's self-written, how many forum users know about it? Uploaded to codebase?

 
Alexey Viktorov:

Alexey, is this a question on mql4?

If not, then please tell me why we have to pull mql5 to mql4?

I don't see the point in writing a separate code for every sneeze - I'm used to using functions similar to MT4, so it's logical, if it has already been thought through by MT4, then it has to be thought through.

If you have already thought about it in MT4, it may be more appropriate to transfer it to MT5, that will also increase compatibility.

 
Sergey Savinkin:

Thank you. Then I won't ask whatTFMigrate(tf) is))))

Only if it's self-written, how do so many forumers know about it? Uploaded to codebase?

All collected by bits and pieces, but the bulk of similar functions I took originally from here, though I don't know what's left of it.

ENUM_TIMEFRAMES TFMigrate(int tf)
  {
   switch(tf)
     {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);

      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);
      default: return(PERIOD_CURRENT);
     }
  }
 
Aleksey Vyazmikin:

It's all coming together bit by bit, but I got the bulk of similar features originally from here, though I don't know what's left of it.

Thank you, Alexey.

Since we're in this thread, I have an off-topic question. The text displayed in MQL5 messages is nicely formatted (with indentation and in different colors), I have either plain text or (in case of distortions) plain black text. How do I do the formatting?

 
Press Alt+s before inserting the code
 
Alexey Viktorov:
Press Alt+s before inserting the code
bool Спасибо = true;

It works. ))

 
Aleksey Vyazmikin:

EvenVladimir Karputov uses functions similar to those of MT4, so am I not worse, because my ideology does not allow me to do so?

I don't see the point in writing a separate code for each situation, I'm used to using functions, and if MT4 has already thought about it, it would be logical to transfer it to MT5, which would also add compatibility.

And really... why strive to be better...

If you want to know how much extra code is written in these functions, think about how much code you're writing by calling these self-written functions.

Reason: