MT5, Multi-core support

 

I wonder if in the near future we will get support for using all processor cores, or if we will continue with the single‑threaded version.

For heavy computations, such as fractals for many candles and timeframes, this takes an extremely long time.
For example, when I scan 100 companies on the stock market, on all timeframes, it takes about 20–25 minutes.
If all processor cores were used, it would be much better.

 
Ivan Stefanov:

I wonder if in the near future we will get support for using all processor cores, or if we will continue with the single‑threaded version.

For heavy computations, such as fractals for many candles and timeframes, this takes an extremely long time.
For example, when I scan 100 companies on the stock market, on all timeframes, it takes about 20–25 minutes.
If all processor cores were used, it would be much better.

MT5 is multi-core by design (make sure all local agents are enabled in Tester tab "Agents").

If your "scanner" is taking 25 minutes, the bottleneck is likely your code architecture, not the platform.

 
Oleksandr Medviediev #:

MT5 is multi-core by design (make sure all local agents are enabled in Tester tab "Agents").

If your "scanner" is taking 25 minutes, the bottleneck is likely your code architecture, not the platform.

Hi,

Thank you for the clarification. I understand that MT5 uses agents for optimization and backtesting, but when using a custom indicator for real-time scanning, the process remains single-threaded within the indicator itself. Could you point me toward best practices for architectural optimization in MQL5? Are there specific approaches for parallelizing heavy computations (such as fractals across multiple timeframes) within a single indicator, or is it better to split the tasks across separate indicators?
 
Ivan Stefanov #:

i remember a similar thread, using an ea is better for multi symbol scanner.
 
Michael Charles Schefe #:
i remember a similar thread, using an ea is better for multi symbol scanner.

"The following is about the full code to create a trading system of the Fractals' highs and lows."

//+------------------------------------------------------------------+
//|                                      Fractals highs and lows.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
void OnTick()
  {
//creating arrays
   double fracUpArray[];
   double fracDownArray[];
//Sorting data
   ArraySetAsSeries(fracUpArray,true);
   ArraySetAsSeries(fracDownArray,true);
//define frac
   int fracDef = iFractals(_Symbol,_Period);
//define data and store result
   CopyBuffer(fracDef,UPPER_LINE,2,1,fracUpArray);
   CopyBuffer(fracDef,LOWER_LINE,2,1,fracDownArray);
//define values
   double fracUpValue = NormalizeDouble(fracUpArray[0],5);
   double fracDownValue = NormalizeDouble(fracDownArray[0],5);
//returning zero in case of empty values
   if(fracUpValue ==EMPTY_VALUE)
      fracUpValue = 0;
   if(fracDownValue ==EMPTY_VALUE)
      fracDownValue = 0;
//conditions of the strategy and comment on the chart with highs and lows
//in case of high
   if(fracUpValue>0)
     {
      Comment("Fractals High around: ",fracUpValue);
     }
//in case of low
   if(fracDownValue>0)
     {
      Comment("Fractals Low around: ",fracDownValue);
     }
  }
//+------------------------------------------------------------------+
Learn how to design a trading system by Fractals
Learn how to design a trading system by Fractals
  • 2022.10.24
  • www.mql5.com
This article is a new one from our series about how to design a trading system based on the most popular technical indicators. We will learn a new indicator which Fractals indicator and we will learn how to design a trading system based on it to be executed in the MetaTrader 5 terminal.
 

Forum on trading, automated trading systems and testing trading strategies

Need Help: EA with multiple Timeframe

Marco vd Heijden, 2018.09.17 12:56

yes you can define two timefames like this :

static input ENUM_TIMEFRAMES timeframe_1=PERIOD_D1;// Timeframe 1
static input ENUM_TIMEFRAMES timeframe_2=PERIOD_W1;// Timeframe 2

 
Ryan L Johnson #:

"The following is about the full code to create a trading system of the Fractals' highs and lows."

the above will obviously need to be modified to include multi symbols.
 
Michael Charles Schefe #:
[T]he above will obviously need to be modified to include multi symbols.

Yeah. 100 symbols is rather heavy. I recall Fernando having posted elsewhere that an EA can only receive a tick from the current chart to which the EA is attached in MT5 at any given time (all rates arrive based on that)─and opening 100 charts running EA's doesn't seem to be much of a solution.

Based on what some full stack developers have posted elsewhere, a Python API handles multi-symbol EA's efficiently.

 

article related to similar topic, turns oscilator indicators into eas. but like the above, they will need to be modified for multi-symbol support.

https://www.mql5.com/en/articles/13244#node37

Ready-made templates for including indicators to Expert Advisors (Part 1): Oscillators
Ready-made templates for including indicators to Expert Advisors (Part 1): Oscillators
  • 2024.01.16
  • www.mql5.com
The article considers standard indicators from the oscillator category. We will create ready-to-use templates for their use in EAs - declaring and setting parameters, indicator initialization and deinitialization, as well as receiving data and signals from indicator buffers in EAs.