Custom symbols. Errors, bugs, questions, suggestions. - page 18

 

Bug 24.

The databases of probed and imported ticks do not coexist correctly.

#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnInit()
{
  MathSrand((int)TimeLocal());
  EventSetMillisecondTimer(20); // С такой частотой будем пробрасывать тики
}

void OnTimer()
{
  static bool FirstRun = true;
  static const string Name = _Symbol + (string)MathRand();
    
  static MqlTick Ticks[];
  static int Pos = 0;
    
  if (FirstRun)
  {    
    if (CustomSymbolCreate(Name, NULL, _Symbol) && SymbolSelect(Name, true)) // Создали символ
      PRINT(CopyTicks(_Symbol, Ticks, COPY_TICKS_ALL, (ulong)D'2019.06.20' * 1000, 5)); // Взяли 5 тиков для проброса
      
    FirstRun = false;
  }
  else if (Pos < ArraySize(Ticks))
  {
    MqlTick Tick[1];
    
    Tick[0] = Ticks[Pos++];
    
    PRINT(CustomTicksAdd(Name, Tick)); // Пробросили тик.
    PRINT(CustomTicksReplace(Name, Tick[0].time_msc, Tick[0].time_msc, Tick)); // Заменили его же через импорт.
  }
  else
  {
    PRINT(CopyTicksRange(Name, Ticks)); // Взяли всю тиковую историю
    ArrayPrint(Ticks);                  // Распечатали ее.
    
    ExpertRemove();
  }
}


Result

CopyTicks(_Symbol,Ticks,COPY_TICKS_ALL,(ulong)D'2019.06.20'*1000,5) = 5
CustomTicksAdd(Name,Tick) = 1
CustomTicksReplace(Name,Tick[0].time_msc,Tick[0].time_msc,Tick) = 1
CustomTicksAdd(Name,Tick) = 1
CustomTicksReplace(Name,Tick[0].time_msc,Tick[0].time_msc,Tick) = 1
CustomTicksAdd(Name,Tick) = 1
CustomTicksReplace(Name,Tick[0].time_msc,Tick[0].time_msc,Tick) = 1
CustomTicksAdd(Name,Tick) = 1
CustomTicksReplace(Name,Tick[0].time_msc,Tick[0].time_msc,Tick) = 1
CustomTicksAdd(Name,Tick) = 1
CustomTicksReplace(Name,Tick[0].time_msc,Tick[0].time_msc,Tick) = 1
CopyTicksRange(Name,Ticks) = 10
                 [time]   [bid]   [ask] [last] [volume]    [time_msc] [flags] [volume_real]
[0] 2019.06.20 00:00:05 1.12255 1.12268 0.0000        0 1560988805004       6       0.00000
[1] 2019.06.20 00:00:07 1.12259 1.12268 0.0000        0 1560988807693       2       0.00000
[2] 2019.06.20 00:00:08 1.12259 1.12267 0.0000        0 1560988808627       4       0.00000
[3] 2019.06.20 00:00:09 1.12256 1.12267 0.0000        0 1560988809561       2       0.00000
[4] 2019.06.20 00:00:10 1.12255 1.12268 0.0000        0 1560988810083       6       0.00000
[5] 2019.06.20 00:00:05 1.12255 1.12268 0.0000        0 1560988805004       6       0.00000
[6] 2019.06.20 00:00:07 1.12259 1.12268 0.0000        0 1560988807693       6       0.00000
[7] 2019.06.20 00:00:08 1.12259 1.12267 0.0000        0 1560988808627       6       0.00000
[8] 2019.06.20 00:00:09 1.12256 1.12267 0.0000        0 1560988809561       6       0.00000
[9] 2019.06.20 00:00:10 1.12255 1.12268 0.0000        0 1560988810083       6       0.00000


Five ticks were resampled/imported in succession, but 10 ticks are found in the history. At the same time, five ticks go first, and then the same five ticks. I.e. even the time of entries in the tick database is not consecutive.

Pay attention to the flags of the second half of the ticks, they are different from the first.

 
Slava:

Not reproducible. Empty graph is updated immediately after importing bars.

What happens if the chart is not opened? Open chart after importing bars.

Or close and open the chart.

Or update the chart from the context menu of the chart.

Leading question )))

I imported bars and closed all the windows.

Then reopened the symbols, and went to the Bars tab, selected my symbol there.

Should the bars be showing? It's blank.

When I pressed the Load button (with preselection of covering period), they don't appear either.

I tried version 1970 - same situation.

Opening/closing the chart and the program does not help.

I have not got down to programming yet.

Well, it must be so...


If you have a possibility, connect remotely and see what she needs, please.

 

https://www.mql5.com/ru/forum/147666/page2#comment_3720399

Might help someone.
But I had a different problem
1. In addition to the file 2019.hcc the file 1970.hcc was generated
After deleting it, it seemed to come back to life.
2. there were red lines where o or h was outside of l h

it's not clear where 1970 came from.
there were no such dates, no empty lines
maybe a lot of candles, under 50k

it is possible to look, but how to widen the graph more visible amplitude?
I need to precisely target the candlestick ends when drawing objects
it is not convenient to enter the properties and set values manually
it shifts the graph to the end and I have to rewind it
how do i fix it so it won't jump to the last bar?

Тестер не работает
Тестер не работает
  • 2013.11.04
  • www.mql5.com
2013.11.03 17:25:58 TestGenerator: no history data 'EURUSD1' Вот такое сообщение появляется в журнале после нажатия кнопки "Старт"...
 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

Stanislav Korotky, 2019.08.22 17:34

Has anyone encountered the following problem with custom characters? The CustomRatesUpdate function passes normal quotes, but in fact the chart and data window gets something strange (in this case, in close and low values are 100 times less than passed):

Also, in parallel, single ticks are emulated with CustomTicksAdd with the same values of close price as in the log (immediately before CustomRatesUpdate), i.e. it's not clear where the reduced values in quotes come from.

UPD:

I've got "reverse" situation on USDCAD - quotes increase 10 times after writing. This is the log I'm getting:

2019.08.23 00:04:10.579 RenkoCharts (USDCAD,M1)                  [time]  [open]  [high]   [low] [close] [tick_volume] [spread] [real_volume]
2019.08.23 00:04:10.579 RenkoCharts (USDCAD,M1) [0] 2019.08.23 00:02:00 1.32987 1.32987 1.32980 1.32987           457       48             0
2019.08.23 00:04:10.579 RenkoCharts (USDCAD,M1) Retry: 1 0
2019.08.23 00:04:10.579 RenkoCharts (USDCAD,M1)                  [time]  [open]   [high]   [low]  [close] [tick_volume] [spread] [real_volume]
2019.08.23 00:04:10.579 RenkoCharts (USDCAD,M1) [0] 2019.08.23 00:02:00 1.32980 13.29730 1.32980 13.29730           457       52             0

The first ArrayPrint is what was written in CustomRatesUpdate, and the second ArrayPrint is what was read using CopyRates from the last most recent bar immediately after writing. First, the difference is the last digit in open, but more importantly, high and close are increased by a factor of 10.

PS. In ticks everything is OK:

 

Stanislav Korotky:

PS. Everything is fine in the ticks:

Bug 22.

 
fxsaber:

Bug 22.

Has it been fixed in any of the latest builds?

 

What is the 4022 error? Something to do with trying to write a bar to a custom character. But judging by the code, it's a generic one.

At first, it came up with this:

KI      0       16:24:20.957    RenkoCharts (XAUUSD,M1) Alert: Error on writing custom record: 3082, err: 4401
HS      0       16:24:20.957    RenkoCharts (XAUUSD,M1) Failed to add:
LE      0       16:24:20.957    RenkoCharts (XAUUSD,M1)                  [time]   [open]   [high]    [low]  [close] [tick_volume] [spread] [real_volume]
KG      0       16:24:20.957    RenkoCharts (XAUUSD,M1) [0] 2019.08.28 00:06:00 1542.500 1542.500 1542.400 1542.400            15      170             0
GF      0       16:24:20.957    RenkoCharts (XAUUSD,M1) Last known 10 M1:
JN      0       16:24:20.973    RenkoCharts (XAUUSD,M1)                  [time]   [open]   [high]    [low]  [close]       [tick_volume] [spread]       [real_volume]
JJ      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [0] 2019.08.28 00:00:00 1543.100 1543.100 1543.000 1543.000                   4      180                   0
DE      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [1] 2019.08.28 00:01:00 1543.000 1543.000 1542.900 1542.900                   2      180                   0
EP      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [2] 2019.08.28 00:02:00 1542.900 1542.900 1542.800 1542.800                   1      180                   0
ES      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [3] 2019.08.28 00:03:00 1542.800 1542.800 1542.700 1542.700                   1      180                   0
EN      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [4] 2019.08.28 00:04:00 1542.700 1542.700 1542.600 1542.600                   1      180                   0
QH      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [5] 2019.08.28 00:05:00 1542.600 1542.700 1542.500 1542.500                  30      170                   0
RE      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [6] 1970.01.01 00:00:00   +0.000   +0.000   +0.000   +0.000          5365435195        1 1827299883397152768
FF      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [7] 2106.02.07 06:28:16    0.078   +0.000   +0.000   +0.000 4597373804417646592        1                9481
KR      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [8] 1970.01.01 00:00:00   +0.000   +0.000   +0.000   +0.000           136454688        1 1827300776750350336
KL      0       16:24:20.973    RenkoCharts (XAUUSD,M1) [9] 0000.00.00 00:00:00   +0.000    2.150   +0.000   +0.000 1287860306076237824        0          4294967300
CH      0       16:24:20.973    RenkoCharts (XAUUSD,M1) Timeout before retry...

4401 when callingCustomRatesUpdate. Then a reading of last 10 bars for custom symbol with CopyRates (we can see some nonsense in the base). Then through timeouts several attempts to write one bar again, until 4022 comes up. And then Abnormal termination of the EA, after which it restarted itself.

 

The question is this.

I need to dynamically change stop and freeze levels in a custom symbol.

There is the following code for the test EA:

//+------------------------------------------------------------------+
//| Globals                                                          |
//+------------------------------------------------------------------+
string symbol_name="EURUSD_1";
string symbol_path="";
string symbol_origin="EURUSD";
long stop_lvl=20;
long freeze_lvl=30;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 1) create
   if(!::SymbolInfoInteger(symbol_name,SYMBOL_CUSTOM))
     {
      ResetLastError();
      if(!::CustomSymbolCreate(symbol_name,symbol_path,symbol_origin))
        {
         PrintFormat("Error code: %d",GetLastError());
         return INIT_FAILED;
        }
     }
//--- 2) set levels
   ResetLastError();
   if(!::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_STOPS_LEVEL,stop_lvl))
     {
      PrintFormat("Error code: %d",GetLastError());
      return INIT_FAILED;
     }
   if(!::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_FREEZE_LEVEL,freeze_lvl))
     {
      PrintFormat("Error code: %d",GetLastError());
      return INIT_FAILED;
     }
//---
   return INIT_SUCCEEDED;
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 1) stop level
   stop_lvl=::SymbolInfoInteger(symbol_name,SYMBOL_TRADE_STOPS_LEVEL);
   if(stop_lvl==20)
      stop_lvl=30;
   else
      stop_lvl=20;
   ResetLastError();
   if(::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_STOPS_LEVEL,stop_lvl))
     {
      PrintFormat("Error code while setting a new value for the stop level: %d",
                  GetLastError());
      return;
     }
//--- 2) freeze level
   freeze_lvl=::SymbolInfoInteger(symbol_name,SYMBOL_TRADE_FREEZE_LEVEL);
   if(freeze_lvl==30)
      freeze_lvl=40;
   else
      freeze_lvl=30;
   if(::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_FREEZE_LEVEL,freeze_lvl))
     {
      PrintFormat("Error code while setting a new value for the freeze level: %d",
                  GetLastError());
      return;
     }
  }
//+------------------------------------------------------------------+

In normal debugging mode, I get an error only in the OnTick() handler body. And the error is with code 0.

2019.09.09 23:25:05.010 TestingLevels (EURUSD,M1)       Error code while setting a new value for the stop level: 0


In the debugging mode on the history I get an error during initialization. The error is like this:

2019.09.09 23:29:43.005 2019.09.02 00:00:00   Error code: 4014

I.e. there is a ban on calling the system function.

ERR_FUNCTION_NOT_ALLOWED

4014

System function is not allowed to be called


In general, is it possible to change stop-levelling and free-levelling values as the EA is running on a custom symbol?

 
Denis Kirichenko:

The question is this.

I need to dynamically change stop and freeze levels in a custom symbol.

There is the following code for the test EA:

In normal debugging mode, I get an error only in the OnTick() handler body. The error has code 0.


In the debugging mode on the history I get an error during initialization. The error is like this:

I.e. there is a ban on calling the system function.

ERR_FUNCTION_NOT_ALLOWED

4014

System function is not allowed to be called


In general, is it possible to change stop lev and freeze lev values as the EA is running on a custom symbol?

And why in the OnTick() lines

if(::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_STOPS_LEVEL,stop_lvl))

и

if(::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_FREEZE_LEVEL,freeze_lvl))

enter the body of the error handling block on successful character property change? (no "!" sign)

 
Artyom Trishkin:

Why do the lines in OnTick()

и

enter error handling block body on successful character property change? (no "!" sign).

Artyom, thank you! My oversight.

Updated version:

//+------------------------------------------------------------------+
//| Globals                                                          |
//+------------------------------------------------------------------+
string symbol_name="EURUSD_1";
string symbol_path="";
string symbol_origin="EURUSD";
long stop_lvl=20;
long freeze_lvl=30;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 1) create
   if(!::SymbolInfoInteger(symbol_name,SYMBOL_CUSTOM))
     {
      ResetLastError();
      if(!::CustomSymbolCreate(symbol_name,symbol_path,symbol_origin))
        {
         PrintFormat("Error code: %d",GetLastError());
         return INIT_FAILED;
        }
     }
//--- 2) set levels
   ResetLastError();
   if(!::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_STOPS_LEVEL,stop_lvl))
     {
      PrintFormat("Error code: %d",GetLastError());
      return INIT_FAILED;
     }
   if(!::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_FREEZE_LEVEL,freeze_lvl))
     {
      PrintFormat("Error code: %d",GetLastError());
      return INIT_FAILED;
     }
//---
   return INIT_SUCCEEDED;
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 1) stop level
   stop_lvl=::SymbolInfoInteger(symbol_name,SYMBOL_TRADE_STOPS_LEVEL);
   if(stop_lvl==20)
      stop_lvl=30;
   else
      stop_lvl=20;
   ResetLastError();
   if(!::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_STOPS_LEVEL,stop_lvl))
     {
      PrintFormat("Error code while setting a new value for the stop level: %d",
                  GetLastError());
      return;
     }
//--- 2) freeze level
   freeze_lvl=::SymbolInfoInteger(symbol_name,SYMBOL_TRADE_FREEZE_LEVEL);
   if(freeze_lvl==30)
      freeze_lvl=40;
   else
      freeze_lvl=30;
   if(!::CustomSymbolSetInteger(symbol_name,SYMBOL_TRADE_FREEZE_LEVEL,freeze_lvl))
     {
      PrintFormat("Error code while setting a new value for the freeze level: %d",
                  GetLastError());
      return;
     }
  }
//+------------------------------------------------------------------+

Everything now works in normal debug mode. But not in the Tester. It keeps writing there:

2019.09.10 07:16:49.867 2019.09.03 00:00:00   Error code: 4014