Discussion of article "Custom symbols: Practical basics" - page 6

 
Mr David Frederick Roberts #: Thank you Fernando, I suspected it was something stupid I was doing but I just couldn't see it!  As I said I'm far more familiar with MT4 (around 8 years) and I hadn't spotted there were two "£Every Tick" options in MT5.  I just started her up, saw it was set to "Every Tick" and assumed that if it had real ticks it would use them. It had to be something simple and I thank you again for spotting it.
You are welcome!
 

Maybe there is a new version of EqualVolumeBars somewhere? I found 2 problems when using this EA:

1. When compiling EqualVolumeBars, 1 warning appears (easily fixed in Symbol.mqh by replacing time with _time for example):

declaration of 'time' hides global variable	Symbol.mqh	28	47

2. Bars disappear. As I understand it, it happens when a new day has come in the terminal. For example, the date in TimeCurrent() is 2023.06.03 (BTCUSD ticks on weekends), and the last range bar was opened on 2023. 06.02. All bars for 2023.06.02 will disappear.

You can reproduce this problem in just a few steps:

  • Commute line 360 in EqualVolumeBars (so that the chart does not update itself):
//ChartSetSymbolPeriod(id,symbolName,PERIOD_M1);
  • Add EqualVolumeBars to the EURAUD chart with the following parameters:

Get a chart like this:

  • Right click on the chart and click Refresh. Result:


 
Andrei Iakovlev #:

Maybe there is a new version of EqualVolumeBars somewhere? I found 2 problems while using this Expert Advisor:

1. When compiling EqualVolumeBars 1 warning appears (easily fixed in Symbol.mqh by replacing time with _time for example):

2. Bars disappear. As I understood, it happens when a new day has come in the terminal. For example, the date in TimeCurrent() is 2023.06.03 (BTCUSD ticks on weekends), and the last range bar was opened on 2023. 06.02. All bars for 2023.06.02 will disappear.

You can reproduce this problem in just a few steps:

  • Commute line 360 in EqualVolumeBars (so that the chart does not update itself):
  • Add EqualVolumeBars to the EURAUD chart with the following parameters:

Get a chart like this:

  • Right click on the chart and click Refresh. Result:


There is no new version.

There are bugs in the implementation of custom characters in the terminal, which I wrote about somewhere, but they are not really fixed.

In this case, you can look at the code - the existing symbol is refilled completely when starting the Expert Advisor, so if something is left extra or on the contrary, the beginning of the day disappears - this is how the MQL5 API works.

Since the source code is open, you can suggest a fix to cure the problem.

 

Hi  Stanislav Korotky

Thanks for all you did on various ways and types regarding "Custom Symbols" topic

Secondly sorry for writing in english,since i do not know russian - :)

1 issue raised within "RenkoTicks" code (kind of error)

1

Can you kindly manage time,removing this error

regards

Stanislav Korotky
Stanislav Korotky
  • 2023.04.26
  • www.mql5.com
Trader's profile
 
mntiwana #:

Can you kindly manage time,removing this error

Just remove 0 inside the curly braces. Please follow MQL5 syntax changes in the news announces. This one is a bit old - I can't remember exact reference now.

 
Stanislav Korotky #:

This one is a bit old,,,

Once again, it took me 3 years to find this work of art. If this is "old", old has just met... slow. Ha. Thank you.

 

Regarding RenkoTicks.mq5, I experienced a points to pips conversion issue with 3 digit pricing. I previously experienced the same thing with some utilities in MT4, so I implemented the same fix:


//in globals, insert
double _PntsToPips;

//in OnInit, insert
if(_Digits == 3 || _Digits == 5)
{
 PntsToPips = 10;
}
else
{
 _PntsToPips = 1;
}

//in 2 lines containing _Point (not in sendSpread...), insert
* _PntsToPips //2 new lines will be:

double Renko::boxPoints = NormalizeDouble(RenkoBoxSize * _Point * _PntsToPips, _Digits);
Renko::setBoxPoints(NormalizeDouble(RenkoBoxSize * _Point * _PntsToPips, _Digits));


 

Here is a small but important improvement in the custom signal based on 2 MA crossing. The underlying indicator objects maintain internal buffers with indicator's data (not only MA case, but in general), hence calling m_maFast.Main(ind) or m_maSlow.Main(ind) leads to reading somewhat outdated (cached) data from the objects, not from indicators themselves, if your trading system trades by ticks (!). Now it's replaced with the following calls to GetData which is basically is a wrapper for direct CopyBuffer:

class Signal2MACross : public CExpertSignal
{
    ...
    // helper functions to read indicators' data
    double FastMA(int ind) { static double buffer[1]; m_maFast.GetData(ind, 1, 0, buffer); return buffer[0]; }
    double SlowMA(int ind) { static double buffer[1]; m_maSlow.GetData(ind, 1, 0, buffer); return buffer[0]; }
};

The updated header file is attached. It should be placed in /MQL5/Include/Expert/Signal/MySignals/. Without this the signals have been built by completed bars.

Files:
 

It's turned out to be even worse. Some times timeseries are not re-calculated yet when new tick is fired, hence bar index should be adjusted dynamically for trade signal analysis. For example (rough approach):

    double FastMA(int ind)
    {
      MqlTick t;
      SymbolInfoTick(m_symbol.Name(), t);
      bool correction = false;

      if(t.time / 60 * 60 != iTime(m_symbol.Name(), PERIOD_CURRENT, 0) && ind > 0)
      {
        ind--;
        correction = true;
      }
      
      static double buffer[1]; m_maFast.GetData(ind, 1, 0, buffer);
      
      if(correction)
        PrintFormat("F: %s'%03d %s %.5f", TimeToString(t.time, TIME_SECONDS), t.time_msc % 1000, TimeToString(iTime(m_symbol.Name(), PERIOD_CURRENT, 0)), buffer[0]);
        
      return buffer[0]; 
    }

This is critical for EAs trading on bar opening, and for symbols with sparse ticks.

 

And how to make an online chart with average price using the formula (bid+ask)/2?