Discussion of article "Custom symbols: Practical basics"

 

New article Custom symbols: Practical basics has been published:

The article is devoted to the programmatic generation of custom symbols which are used to demonstrate some popular methods for displaying quotes. It describes a suggested variant of minimally invasive adaptation of Expert Advisors for trading a real symbol from a derived custom symbol chart. MQL source codes are attached to this article.

Also, the EA allows using the real volume mode for exchange instruments:

The LKOH original chart with the real volume of 10000 per bar, generated buy the EqualVolumeBars EA in MetaTrader 5

The LKOH equi-volume chart with the real volume of 10000 per bar, generated buy the EqualVolumeBars EA in MetaTrader 5

The original (a) and the equivolume (b) LKOH chart with the real volume of 10000 per bar, generated by the EqualVolumeBars EA in MetaTrader 5

The timeframe of the symbol on which the EA is running is not important, since either M1 bars or tick history are always used for calculations.

The timeframe of the custom symbol charts must be equal to M1 (the smallest available timeframe in the terminal). Thus, the time of bars, usually closely corresponds to their formation moments. However, during strong market movements, when the number of ticks or the size of volumes forms several bars per minute, the time of the bars will be ahead of real ones. When the market calms down, the time marks of the equivolume bars will return to normal. This platform limitation is probably not particularly critical for equal-volume or equal-range bars, since the very idea of such charts is to unbind them from absolute time.

Author: Stanislav Korotky

 
Hello can i use this to test in MQ4?
 
Eustorgio Trentino:
Hello can i use this to test in MQ4?

No, custom symbols are supported by MT5 only.

 

Hi.

Thanks for this article. I try to figure out how can I create a new EURUSD M23 chart . I can create a custom EURUSD.custom but what I ha ve to do ot change the timeframe please?

 
michel picard:

Hi.

Thanks for this article. I try to figure out how can I create a new EURUSD M23 chart . I can create a custom EURUSD.custom but what I ha ve to do ot change the timeframe please?

If you mean you want to form bars/candles every 23 minutes, then you should do it in your code as you think is appropriate. This article does not provide a ready-made mechanism for such a tool. You can use some parts of the code which are suitable for your requirements and extend it.

 
Hi, maybe I missed a part but, how can wicks of renko blocks be bigger than the boddies ?
 
Adren6:
Hi, maybe I missed a part but, how can wicks of renko blocks be bigger than the boddies ?

Wicks displays price movements between the moment when previous box completed and the next box completed. For example, if we have upside box finished, price may go up some points and not form next box, if the distance is less than required box size. Then price begins move down, go side by side with the last upside box, covers all the box in down direction (still not new box), then covers more points and finally hits box size. At this moment new down box is formed, and upsied wick shows all the distance, that is the previous upside box and previous non-finished upside movement which was not sufficient to form next upside box.

Size of a wick is always less than 2 box sizes, because this is the distance which would lead to a reverse. Until the reverse is not occured, a wick is collecting all volatility.

 
Stanislav, I was looking for operate with Renko charts, your development covers all my doubts about. Thanks by aggregate great value to traders. The expert advisor only needs a start an end time to trade.   
 

When using custom symbols is there some kind of scaling applied to the spread?

I have imported some Dukascopy tick data for EURUSD (which I have called EURUSD_TDS).  Comparing the prices on the "Ticks" tab of the custom symbol with the prices shown for the same period using the following code shows the Bid prices to be pretty much the same, but the Ask prices are different such that the spread is significantly lower than on the "Ticks" tab - Ie the EA is seeing a lower spread than the raw data.  Also the timing of the ticks differs which surprised me a little, but it is the spread issue which is of greatest concern.

void OnTick()
{
   double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
   datetime now = TimeCurrent();
   
   if ((now >= StartDate) && (now < EndDate))
   {
      double spread = (Ask - Bid) / _Point;
      writeToLog(StringFormat("%s, %.5f, %.5f, %.i", (string)now, Bid, Ask, (int)spread));
   }
}


Raw data, spread between 11 pts and 67 pts... What the EA is seeing, spread 9 or 26 pts...

       

 
Mr David Frederick Roberts #:

When using custom symbols is there some kind of scaling applied to the spread?

I have imported some Dukascopy tick data for EURUSD (which I have called EURUSD_TDS).  Comparing the prices on the "Ticks" tab of the custom symbol with the prices shown for the same period using the following code shows the Bid prices to be pretty much the same, but the Ask prices are different such that the spread is significantly lower than on the "Ticks" tab - Ie the EA is seeing a lower spread than the raw data.  Also the timing of the ticks differs which surprised me a little, but it is the spread issue which is of greatest concern.


Raw data, spread between 11 pts and 67 pts... What the EA is seeing, spread 9 or 26 pts...

       

Hi, there is no "scaling" of the spread, but there probably can be other nuances to interfere. For example, make sure you're testing in real ticks mode and do not have an option with fixed spread enabled (according to the right-side log it looks like the same spread during every bar).

It would be nice to see exact tick sequences for both UI table and your EA log (including msecs) - your current screenshot does not seem showing the same tick sequence.

 
Stanislav Korotky #:

Hi, there is no "scaling" of the spread, but there probably can be other nuances to interfere. For example, make sure you're testing in real ticks mode and do not have an option with fixed spread enabled (according to the right-side log it looks like the same spread during every bar).

It would be nice to see exact tick sequences for both UI table and your EA log (including msecs) - your current screenshot does not seem showing the same tick sequence.

Thanks for the response.  This is very odd, I am indeed using real ticks mode and I wasn't aware that there is a fixed spread option in MT5 so I'm sure that I'm not (I'm more familiar with MT4).  I hadn't spotted that the spreads were the same for each bar, in fact looking through the full file it seems that they only change on 1 minute boundaries.  I assume I am correct in thinking that the calls to SymbolInfoDouble() should return the prices for the tick being processed as a result of the OnTick() event call - not some kind of M1 value?

I tried printing what I expected to be the actual tick time with milliseconds using the code below, but the milliseconds value is always zero...

void OnTick()
{
   double Ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double Bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   long timeMillis = SymbolInfoInteger(_Symbol, SYMBOL_TIME_MSC);
   datetime now = TimeCurrent();
   
   datetime time = (datetime)(timeMillis / 1000);
   long millis = timeMillis % 1000;
   
   if ((now >= StartDate) && (now < EndDate))
   {
      double spread = (Ask - Bid) / _Point;
      writeToLog(StringFormat("%s.%i, %.5f, %.5f, %.2f", (string)time, millis, Bid, Ask, spread));
   }
}

EDIT:  As I said I'm relatively new to MQL5 - I've just found SymbolInfoTick(), maybe I should be using that instead of what I'm doing!  I'll try that and see what happens...


Ok, that made no difference, exactly the same results, but neither of them tying up with the "Symbol Ticks" dialog in the terminal.  I was wrong in saying that the milliseconds value was always zero - it is non-zero for exactly one minute, namely the one minute before midnight!

This seems to me to be a pretty important issue.  My trading EA is expecting to receive ticks with prices which match the source imported tick-data (as would anyone else's!).  I dare say there is something that I'm doing wrong, but if so I would like to know what it is.  If not then there is a very serious problem here.  I have attached a zip file with the test EA, a spreadsheet of results for the hour either side of midnight, and some screenshots of settings and ticks.

Files:
Reason: