Multi symbol tick event

 

Hi,


I'm working on an indicator which makes the same calculation process for each symbol of an internal list selected by the user (for exemple : EURUSD, USDJPY, etc...).

The event which initiate a new calculation process for a given symbol shall be a new tick of this symbol.

Important : This indicator is affected to one chart only but shall make the calculation process for all the symbol of the internal list. That means I can't use the basic OnCalculate event function for scan the new ticks of all symbols because OnCalculate event will occurs only when a new tick of the actual selected symbol of the chart occurs.

So finally, I must detect when a new tick of a specific symbol occurs.


My question is :

- how can I create an event of new tick for a list of known symbols ?

- where shall I write this event in my code ?


Thank for your help !

Erwann.

 

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Анализ результатов тестов и оптимизации в тестере стратегий MetaTrader 5

fxsaber, 2018.01.28 12:25

Индикатор

#property indicator_chart_window
#property indicator_plots 0

input long Chart = 0; // идентификатор графика-получателя события
input int Index = 0;

int OnCalculate( const int rates_total, const int prev_calculated, const int, const double &[] )
{
  if (prev_calculated)
    EventChartCustom(Chart, 0, Index, 0, NULL);
  
  return(rates_total);
}


Советник

input int AmountSymbols = 1;

const string Symbols[] = {"EURUSD", "GBPUSD", "AUDUSD", "USDJPY", "USDCAD"};

void OnInit()
{
  for (int i = 0; i < AmountSymbols; i++)
    if (Symbols[i] != _Symbol)
      iCustom(Symbols[i], PERIOD_W1, "Spy.ex5", ChartID(), i); // MQL5\Indicators\Spy.ex5
}

void OnTick()
{
  OnTick(_Symbol); 
}

void OnChartEvent( const int id, const long &lparam, const double&, const string& )
{
  if (id == CHARTEVENT_CUSTOM)
    OnTick(Symbols[(int)lparam]);
}

// Мультисимвольный OnTick
void OnTick( const string &Symb )
{
}
 
Erwann Pannerec:
...

fxsaber post is one method well described in this article a long time ago.

In summary, you launch an indicator on all symbols to monitor, and these indicators send back an event to the EA when there is a new tick on any of the symbols.

The Implementation of a Multi-currency Mode in MetaTrader 5
The Implementation of a Multi-currency Mode in MetaTrader 5
  • 2011.02.18
  • Konstantin Gruzdev
  • www.mql5.com
Currently, there are a large number of developed multi-currency trading systems, indicators, and Expert Advisors. Nevertheless, the developers continue to face the specific problems of multi-currency systems development. With the release of the MetaTrader 5 client terminal and the MQL5 programming language, we gained a new opportunity to...
 
Alain Verleyen:

fxsaber post is one method well described in this article a long time ago.

In summary, you launch an indicator on all symbols to monitor, and these indicators send back an event to the EA when there is a new tick on any of the symbols.

It's clear.

The article is very interesting.

Many thanks for your help, I think I can work on this solution :)


Regards,

Erwann.

 
Found this post interesting, but i don't think that solution can be implemented for backtest :(
 
Jose Ma Gassin Perez Traverso #:
Found this post interesting, but i don't think that solution can be implemented for backtest :(
Why not?
 
Dominik Christian Egert #:
Why not?
You pick ONE symbol for the strategy tester, how do you add the spy into the other's symbol/s?
 
Jose Ma Gassin Perez Traverso #:
You pick ONE symbol for the strategy tester, how do you add the spy into the other's symbol/s?
You load an indicator using iCustom from your EA, it will make the strategy tester also load that symbol you specified on iCustom function call.

That's why you need to use an indicator to get the tick events.
 
Dominik Christian Egert #:
You load an indicator using iCustom from your EA, it will make the strategy tester also load that symbol you specified on iCustom function call.

That's why you need to use an indicator to get the tick events.

OH! Dear so you can force a symbol to implement a custom indicator for that reason, thank you sir, really pleased :)