Custom symbols. Errors, bugs, questions, suggestions.

 
As the topic is quite extensive, I thought it would be a good idea to have a separate discussion on it.
 

Bug 01.

The custom character chart is open. If, for example, you manually delete all bar and tick history, the chart window just hangs - without refreshing.

Expected behaviour as with an empty custom symbol.

 

Bug 02.

You need to delete the last week of the custom symbol quotes. You can delete it, but even ChartRedraw doesn't give any visual effect.

Only if you scroll the chart with the mouse, it comes back to normal. Could you fix the visualization by ChartRedraw?


ZZY Doing a similar overdraw for now

    ChartSetInteger(0, CHART_SHIFT, !ChartGetInteger(0, CHART_SHIFT));
    Sleep(1000);
    ChartRedraw();
    
    ChartSetInteger(0, CHART_SHIFT, !ChartGetInteger(0, CHART_SHIFT));
 

Bug 03.

TicksAdd has the following protection. If a tick is earlier than the one in the Market Watch, it is ignored.


Unfortunately, this mechanism does not interact with TicksDelete and TicksReplace.

You need to delete the last day of the custom symbol's history and put the last tick after deletion into Market Watch.

If deletion is OK, then exposing the last tick won't work, due to the rule I described above.


I suggest either changing the TicksAdd rule, or that TicksDelete/TicksReplace replaces the tick in Market Watch with the last tick in history if its time is less than the current time.


Replay problem

template <typename T>
T MyPrint( const T Value, const string Str, const bool DebugFlag = false ) { Print(Str + " = " + (string)Value); return(Value); }
#define _P(A) MyPrint(A, __FUNCSIG__ ", Line = " + (string)__LINE__ + ": " + #A)                    // Макрос для удобного и наглядного вывода значений

void OnStart()
{
  const string Name = "TEMP1235";                                                                   // Имя кастомного символа
  const string SymbOrig = "EURUSD";                                                                 // Имя оригинального символа

  MqlTick Ticks[];
  const int Size = _P(CopyTicksRange(SymbOrig, Ticks, COPY_TICKS_ALL, (long)D'2019.01.01' * 1000)); // Считали EURUSD-тики за 2019 год.
    
  if ((Size > 0) && _P(CustomSymbolCreate(Name, NULL, SymbOrig)) && _P(SymbolSelect(Name, true)))   // Создали символ на основе EURUSD.
  {            
    _P(CustomTicksReplace(Name, 0, LONG_MAX, Ticks));                                               // Поместили в него историю EURUSD.
    
    MqlTick AddTicks[1];                                                                            
    AddTicks[0] = Ticks[Size - 1];                                                                  // Последний тик в истории.
    
    _P(CustomTicksAdd(Name, AddTicks));                                                             // Последний тик добавили в Обзор рынка и еще раз в историю
    
    _P(CustomTicksDelete(Name, (long)D'2019.02.01' * 1000, LONG_MAX));                              // Удалили все тики, оставив только данные за январь 2019.
    _P(CopyTicks(Name, AddTicks, COPY_TICKS_ALL, 0, 1));                                            // Взяли последний тик из оставшейся истории.
    
    ArrayPrint(AddTicks);                                                                           // Посмотрели, что это, действительно, последний тик января.
    _P(CustomTicksAdd(Name, AddTicks));                                                             // Попробовали записать его в Обзор рынка - не получилось.
    
    _P(SymbolSelect(Name, false));                                                                  // Удалили символ из Обзора рынка.
    _P(CustomSymbolDelete(Name));                                                                   // Удалили символ.
  }
}


Result

void OnStart(), Line = 11: CopyTicksRange(SymbOrig,Ticks,COPY_TICKS_ALL,(long)D'2019.01.01'*1000) = 3316638
void OnStart(), Line = 13: CustomSymbolCreate(Name,NULL,SymbOrig) = true
void OnStart(), Line = 13: SymbolSelect(Name,true) = true
void OnStart(), Line = 15: CustomTicksReplace(Name,0,LONG_MAX,Ticks) = 3316638
void OnStart(), Line = 20: CustomTicksAdd(Name,AddTicks) = 1
void OnStart(), Line = 22: CustomTicksDelete(Name,(long)D'2019.02.01'*1000,LONG_MAX) = 1159087
void OnStart(), Line = 23: CopyTicks(Name,AddTicks,COPY_TICKS_ALL,0,1) = 1
                 [time]   [bid]   [ask] [last] [volume]    [time_msc] [flags] [volume_real]
[0] 2019.01.31 23:59:58 1.14461 1.14486 0.0000        0 1548979198644       2       0.00000
void OnStart(), Line = 26: CustomTicksAdd(Name,AddTicks) = -1
void OnStart(), Line = 28: SymbolSelect(Name,false) = true
void OnStart(), Line = 29: CustomSymbolDelete(Name) = true


I understand that without the source code the error message will remain in words. How boring it was to describe, but it's probably the most effective way to show, find and fix the bug.

 

Just started sorting out the synthetics yesterday, there's some nonsense in the tester. Do synthetics with formulas work in the tester?

Created a synthetic, formula from the help. Is that correct?

1

This is what the test showed.

2

This is nonsense - all trades are profitable, which cannot be even according to the image; all of them are closed at the end of the test and the profit is zero. I must be doing something wrong. What else should I check? I am attaching the log.

Files:
20190224.log  9322 kb
 
Alexey Volchanskiy:

I must be doing something wrong. What else should I look at?

In the screenshot you can see that the symbol's profit currency is not the same as the account currency. Therefore the conversion gives zero.

To make it work "out of the box", name it like "EURUSD_ALEX1".

 
Can you tell me in which folders the custom symbols and their settings are stored? I can't find it in the terminal or the software.
 
pivomoe:
Can you tell me in which folders the custom symbols and their settings are stored? Deleting in terminal and software doesn't help.

\MetaTrader5\Bases\Custom\

 

Bug 04.

Another bug with specific replay

template <typename T>
T MyPrint( const T Value, const string Str, const bool DebugFlag = false ) { Print(Str + " = " + (string)Value); return(Value); }
#define _P(A) MyPrint(A, __FUNCSIG__ ", Line = " + (string)__LINE__ + ": " + #A)                    // Макрос для удобного и наглядного вывода значений

void OnStart()
{
  const string Name = "TEMP8";                                                                      // Для каждого запуска нужно менять имя символа, чтобы увидеть проблему
  const string SymbOrig = "EURUSD";                                                                 // Имя оригинального символа

  MqlTick Ticks[];
  const int Size = _P(CopyTicksRange(SymbOrig, Ticks, COPY_TICKS_ALL, (long)D'2019.01.01' * 1000)); // Считали EURUSD-тики за 2019 год.
    
  if ((Size > 0) && _P(CustomSymbolCreate(Name, NULL, SymbOrig)) && _P(SymbolSelect(Name, true)))   // Создали символ на основе EURUSD.
  {            
    _P(CustomTicksReplace(Name, 0, LONG_MAX, Ticks));                                               // Поместили в него историю EURUSD.
    
    MqlTick AddTicks[1];                                                                            
    AddTicks[0] = Ticks[Size - 1];                                                                  // Последний тик в истории.
    
    _P(CustomTicksAdd(Name, AddTicks));                                                             // Последний тик добавили в Обзор рынка и еще раз в историю
    
    _P(CustomTicksDelete(Name, (long)D'2019.02.01' * 1000, LONG_MAX));                              // Удалили все тики, оставив только данные за январь 2019.
    _P(CopyTicks(Name, AddTicks, COPY_TICKS_ALL, 0, 1));                                            // Взяли последний тик из оставшейся истории.    
    ArrayPrint(AddTicks);                                                                           // Посмотрели, что это, действительно, последний тик января.

    const int NewSize = _P(CopyTicksRange(Name, Ticks));                                            // Запросили всю историю тиков кастомного символа
    
    _P(CopyTicks(Name, AddTicks, COPY_TICKS_ALL, 0, 1));                                            // Снова Взяли последний тик из истории.    
    ArrayPrint(AddTicks);                                                                           // Увидели, что последний тик изменился!
    
    _P(SymbolSelect(Name, false));                                                                  // Удалили символ из Обзора рынка.
    _P(CustomSymbolDelete(Name));                                                                   // Удалили символ.    
  }
} 


Result

void OnStart(), Line = 11: CopyTicksRange(SymbOrig,Ticks,COPY_TICKS_ALL,(long)D'2019.01.01'*1000) = 3316638
void OnStart(), Line = 13: CustomSymbolCreate(Name,NULL,SymbOrig) = true
void OnStart(), Line = 13: SymbolSelect(Name,true) = true
void OnStart(), Line = 15: CustomTicksReplace(Name,0,LONG_MAX,Ticks) = 3316638
void OnStart(), Line = 20: CustomTicksAdd(Name,AddTicks) = 1
void OnStart(), Line = 22: CustomTicksDelete(Name,(long)D'2019.02.01'*1000,LONG_MAX) = 1159087
void OnStart(), Line = 23: CopyTicks(Name,AddTicks,COPY_TICKS_ALL,0,1) = 1
                 [time]   [bid]   [ask] [last] [volume]    [time_msc] [flags] [volume_real]
[0] 2019.01.31 23:59:58 1.14461 1.14486 0.0000        0 1548979198644       2       0.00000
void OnStart(), Line = 26: CopyTicksRange(Name,Ticks) = 2157552
void OnStart(), Line = 28: CopyTicks(Name,AddTicks,COPY_TICKS_ALL,0,1) = 1
                 [time]   [bid]   [ask] [last] [volume]    [time_msc] [flags] [volume_real]
[0] 2019.02.22 23:57:59 1.13303 1.13316 0.0000        0 1550879879799       6       0.00000
void OnStart(), Line = 31: SymbolSelect(Name,false) = true
void OnStart(), Line = 32: CustomSymbolDelete(Name) = true


Bug contained in CopyTicksRange - changes tick history! Please note that in order to reproduce it, you have to change the name of the custom symbol in the script all the time. And this despite the fact that the script successfully deletes it. It turns out that deleting a symbol is not deletion at all.

 
fxsaber:

In the screenshot you can see that the symbol's profit currency is not the same as the account currency. Therefore, the conversion gives zero.

To make it work "out of the box", name it like "EURUSD_ALEX1".

Thank you, that was the point. I named it as it is in my account and it worked. Another question. What happens during real trading? Are synthetic orders translated into orders and positions on real pairs, in this case (see a formula) EURUSD and USDCAD?

Where can I see it, the tester log only shows synthetic.

й

 
Custom symbols on the real are for information only, not for trading. They can only be traded in the tester.
Reason: