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

 
Slava :

At the moment, it is not possible to form custom tool bars with ticks from a day not today (yesterday, the day before, last year etc.).

But. We have made a correction.

When using CustomTicksReplace (not CustomTicksAdd! don't use CustomTicksAdd to bulk add ticks), the last day of added ticks becomes "current" if there were no ticks for today before.

Wait for the next build. Then we'll continue the experiments and discussions

I'm using Build 2177. I think it's the most recent one.

But I can't work with CUSTOMSYMBOL. Can you tell me when I can expect a build that will help me?

Where can I see the changes in the build?

 

The attached indicator works in the current build 2177

This is your indicator. It is edited, but the algorithm is the same. I have placed Symbol.mqh file in MQL5\Include\Includes

Change the line

#include  <Includes\Symbol.mqh>

so as to use your Symbol.mqh.

Bars are formed. Ticks are correctly applied to the history, not only in MarketWatch


Files:
 
Slava :

The attached indicator works in the current build 2177

This is your indicator. It is edited, but the algorithm is the same. I have placed Symbol.mqh file in MQL5\Include\Includes

Change the line

so as to use your Symbol.mqh.

Bars are formed. Ticks are correctly applied to history, not only in MarketWatch


I will check it. Maybe some problems in my code. But the code looks good.

 

Bug 25.

When writing ticks to a custom symbol, they are differently normalised!

sinput datetime inDateFrom = D'2019.12.01';

// Проверка нормализации числа.
bool IsNorm( const double Price )
{
  return(NormalizeDouble(Price, _Digits) == Price);
}

#define  TOSTRING(A) #A + " = " + DoubleToString(A, 16) + " "
#define  PRINT(A) Print(TOSTRING(A) + TOSTRING(NormalizeDouble(A, _Digits)))
#define  ISNORM(A) if (!IsNorm(A)) { PRINT(A); Count++; };

// Распечатка ненормализованных цен тиков.
void CheckNorm( const MqlTick &Ticks[], const int MaxAmount = 10 )
{  
  const int Size = ArraySize(Ticks);
  
  for (int i = 0, Count  = 0; (i < Size) && (Count < MaxAmount); i++)
  {
    ISNORM(Ticks[i].bid)
    ISNORM(Ticks[i].ask)
    ISNORM(Ticks[i].last)
  }
}

// Нормализация цен тика.
void Normalize( MqlTick &Tick, const int digits )
{
  Tick.bid = ::NormalizeDouble(Tick.bid, digits);
  Tick.ask = ::NormalizeDouble(Tick.ask,  digits);
  Tick.last = ::NormalizeDouble(Tick.last, digits);
}

// Нормализация цен тиков.
void Normalize( MqlTick &Ticks[], const int digits )
{
  for (int i = ArraySize(Ticks) - 1; i >= 0; i--)
    Normalize(Ticks[i], digits);
}

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

  MqlTick Ticks[];
  
  const int Size = CopyTicksRange(SymbOrig, Ticks, COPY_TICKS_ALL, (long)inDateFrom * 1000); // Считали EURUSD-тики.
    
  if ((Size > 0) && CustomSymbolCreate(Name, NULL, SymbOrig) && SymbolSelect(Name, true))    // Создали символ на основе EURUSD.
  {
    const int digits = (int)SymbolInfoInteger(Name, SYMBOL_DIGITS);
    
    Normalize(Ticks, digits);                                                                // Нормализовали цены тиков.
    
    Print("Check1");
    CheckNorm(Ticks);                                                                        // Проверили, что цены тиков нормализованы.
    
    CustomTicksReplace(Name, 0, LONG_MAX, Ticks);                                            // Поместили в него историю EURUSD.        

    MqlTick NewTicks[];
    
    CopyTicksRange(Name, NewTicks, COPY_TICKS_ALL, (long)inDateFrom * 1000);                 // Считали тики из кастомного символа
    
    Print("Check2");
    CheckNorm(NewTicks);                                                                     // Проверили, что цены тиков нормализованы.
  }
}


Result

Check1
Check2
Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 


There seems to be some kind of NormalizeDouble inside the Terminal that differs from the standard one. This bug may invisibly affect many algorithms.


Please fix it. The natural need to write normalized prices cannot be implemented.

 
fxsaber:

Bug 25.

When writing ticks to a custom symbol, they are mixed!

Result

The Terminal seems to have its own NormalizeDouble, different from the standard one. This bug may invisibly affect many algorithms.

Please fix it. The natural need to write normalized prices cannot be implemented.

You have an overloaded Normalize function
Try changing the function name.
This might cause the normalisation to fail.

 
fxsaber:

Bug 25.

When writing ticks to a custom symbol, they are mixed!


Result


The Terminal seems to have its own NormalizeDouble, different from the standard one. This bug may invisibly affect many algorithms.


Please fix it. The natural need to write normalized prices cannot be implemented.

Both cases are the results of decimal point normalisation.

Are you still comparing real numbers for absolute equality?

Which server is the source of the original ticks?

 
Roman:

You have an overloaded Normalize function
Try changing the function name.
Maybe that's why the normalisation is not correct.

There is a test for correct normalization in the code. Prior to writing ticks into a custom symbol, this test is successful. I checked the code.

 
Slava:

Both cases are normalization results by the number of decimal places.

Do you still compare real numbers for absolute equality?

Which server is the source of the original ticks?

MQ-Beta server. But the server has nothing to do with this situation at all. What I do.

  1. I normalize the array of ticks and check that it is so.
  2. I write it to a custom symbol.
  3. Read written ticks from the custom symbol.
  4. Check them for normalization - they are not normalized.
That is, I sent to write one ticks, but they were written by someone else.
 
Probably because of the Terminal's emergency closures, there are still tails in the bases\Custom folder.
 
fxsaber:

Bug 25.

2280 - fixed, Thank you.