Questions from Beginners MQL5 MT5 MetaTrader 5 - page 928

 
Juer:

What shared folder? I don't use it at all. I always start in portable mode. I have everything in my installation folder.

LifeHack articlefor trader: Comparative report of several tests.

*** Here is an example of a simpleCheck_TerminalPaths.mq5 script:

//+------------------------------------------------------------------+
//|                                          Check_TerminalPaths.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   Print("TERMINAL_PATH = ",TerminalInfoString(TERMINAL_PATH));
   Print("TERMINAL_DATA_PATH = ",TerminalInfoString(TERMINAL_DATA_PATH));
   Print("TERMINAL_COMMONDATA_PATH = ",TerminalInfoString(TERMINAL_COMMONDATA_PATH));
  }
//+------------------------------------------------------------------+

This script outputs three parameters:

  • TERMINAL_PATH - folder from which the terminal is launched
  • TERMINAL_DATA_PATH - folder where terminal data are stored
  • TERMINAL_COMMONDATA_PATH - the common folder of all client terminals installed in the computer

Example for three terminals (one of them is started with /Portable switch):

// Терминал запускается в основном режиме
TERMINAL_PATH 			= C:\Program Files\MetaTrader 5
TERMINAL_DATA_PATH 			= C:\Users\KVN\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075
TERMINAL_COMMONDATA_PATH 			= C:\Users\KVN\AppData\Roaming\MetaQuotes\Terminal\Common

// Терминал запускается в основном режиме
TERMINAL_PATH 			= D:\MetaTrader 5 3
TERMINAL_DATA_PATH 			= C:\Users\KVN\AppData\Roaming\MetaQuotes\Terminal\0 C46DDCEB43080B0EC647E0C66170465
TERMINAL_COMMONDATA_PATH 			= C:\Users\KVN\AppData\Roaming\MetaQuotes\Terminal\Common

// Терминал запускается в режиме Portable
TERMINAL_PATH 			= D:\MetaTrader 5 5
TERMINAL_DATA_PATH 			= D:\MetaTrader 5 5
TERMINAL_COMMONDATA_PATH 			= C:\Users\KVN\AppData\Roaming\MetaQuotes\Terminal\Common

***

 
Vladimir Karputov:

Shared folder:FILE_COMMON. Search, read. Thinking.

Why do I get error 5004 in the tester with the same file, but when debugging on real data everything is fine?

 
Juer:

And why do I get error 5004 in the tester with the same file, while debugging it with real data is OK?

You don't give the full picture. You have to pincer the information out of you.

Try to describe the situation intelligently. Provide a CODE that can be STARTED.

 

With FILE_COMMON it passes without error both on real data and in the tester.

 

Can you please tell me how to calculate the cost per lot without using OrderCalcMargin?

bool l=OrderCalcMargin(ORDER_TYPE_BUY,Symbol(),Lts,SymbolInfoDouble(Symbol(),SYMBOL_ASK),Margin);

Alert(l);

because my function returns false

 
Fast528:

I need the indicator to display entry/exit positions on the chart and draw a line between them, on a period of today minus 1 day for example, as is usually done in an indicator or robot?

I do not understand what is the connection between the original question and the lines. Today minus 1 day can be set in several ways. or is it a different question?
 
Alexey Viktorov:
I don't understand the connection between the original question and the lines. Today minus 1 day can be assigned with several options. or the question is different?

you asked what the time variable is for? here's looking at how to set the calculation of "Server date" minus 1-2 days

and so of course there was a question and what is the difference between those two options for completing the Structure,

MqlDateTime dt;
TimeTradeServer(dt);

и

MqlDateTime tm;
TimeToStruct(TimeTradeServer(),tm);
 
Fast528:

you asked what the time variable is for? here's looking at how to set the calculation of "Server date" minus 1-2 days

and so of course there was a question and what is the difference between those two options for filling the Structure,

Well, if only filling the structure, it's unlikely there will be any difference.

And why determine the time of the server through the time of the local computer? Why don't you like TimeCurrent() and use it?

 
WithTimeTradeServer at the weekend it is more convenient to experiment with trading ranges
 

Code

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   for(int i=0;i<=21;i++)
     {
      Print("Timeframe: "+EnumToString((ENUM_TIMEFRAMES)i));
     }
  }

Gives this result:

2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_CURRENT
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M1
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M2
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M3
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M4
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M5
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M6
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::7
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::8
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::9
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M10
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::11
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M12
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::13
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::14
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M15
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::16
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::17
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::18
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::19
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: PERIOD_M20
2018.09.17 00:59:59.716 CheckTF (EURUSD,H4)     Timeframe: ENUM_TIMEFRAMES::21
What am I doing wrong?