Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Views:
55
Rating:
(6)
Published:
\MQL5\Indicators\fxsaber\
Spy.mq5 (0.83 KB) view
\MQL5\Include\fxsaber\OnTickMulti\
OnTickMulti.mqh (11.77 KB) view
\MQL5\Experts\
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

In MT5, the NewTick event only occurs on the symbol on which the EA is running. Therefore, various tricks are used for multisymbol trading.

This library creates a multisymbol OnTick on all specified trading symbols. A convenient wrapper of the old implementation.


Example.

Let's show the work of the library on the example of a multisymbol Expert Advisor that counts the number of incoming ticks for each specified symbol.

#include <fxsaber\OnTickMulti\OnTickMulti.mqh> // Multisymbol OnTick.

int TicksCounter[]; // The counter of incoming ticks of each given character.

void OnInit()
{
  // Initialise the counter of incoming ticks.
  ArrayResize(TicksCounter, ArraySize(OnTickMultiObject.Symbols));
  ArrayInitialize(TicksCounter, 0);
}

double OnTester()
{
  // Print the number of arrived ticks for each given character.
  for (uint i = ArraySize(TicksCounter); (bool)i--;)
    Print(OnTickMultiObject.Symbols[i] + " - " + (string)TicksCounter[i] + " ticks.");

  ArrayPrint(OnTickMultiObject.Symbols); // List of symbols OnTickMulti.

  return(0);
}

// Multisymbol OnTick.
void OnTickMulti( const string &Symb, const uint &Index )
{
  TicksCounter[Index]++; // Increased the counter of incoming ticks by the given symbol.
}


Result.

To check the correctness of the Expert Advisor, let's run it in MT5-tester.

After comma in the input we set the symbols to which the multisymbol OnTick will react.


The tester generated the following (see the Log).

2023.01.12 23:59:59   AUDJPY - 1618389 ticks.
2023.01.12 23:59:59   GBPUSD - 1116822 ticks.
2023.01.12 23:59:59   EURUSD - 906489 ticks.
2023.01.12 23:59:59   "EURUSD" "GBPUSD" "AUDJPY"
final balance 10000.00 pips
OnTester result 0
EURUSD,M1: 906489 ticks, 12897 bars generated. Environment synchronized in 0:00:00.020. Test passed in 0:00:01.723 (including ticks preprocessing 0:00:00.188).
EURUSD,M1: total time from login to stop testing 0:00:01.743 (including 0:00:00.248 for history data synchronization)
3641700 total ticks for all symbols
AUDJPY: generate 1618389 ticks in 0:00:00.078, passed to tester 1618389 ticks
EURUSD: generate 906489 ticks in 0:00:00.047, passed to tester 906489 ticks
GBPUSD: generate 1116822 ticks in 0:00:00.063, passed to tester 1116822 ticks

The highlighted part shows that absolutely all the ticks generated by the Tester for the specified symbols were processed by the multisymbol OnTick.


What for?

  • With this library, the result of the Expert Advisor's work in the Tester can be independent of the selected basic symbol.
  • Ticks on the required symbols are not skipped.

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/47647

iMy iMy

In the graphical representation, techanalysis represents the trend line to the right of the candles on the breakdown (in green). After the breakdown, the movement along the red line is assumed.

Professional Order Manager Professional Order Manager

Fox Wave Clean - Professional Order Manager Professional EA for efficient trade management with one-click position control. Clean design, powerful functionality.

RSA Library for asymmetric encryption in MQL5 RSA Library for asymmetric encryption in MQL5

Securing data transfer between client and Server could be a big challenge for you as MQL5 programmer. You may have experience in using built in MQL5 encryption systems like AES.AES can securely encrypt your data but on the other hand is not secure when it comes to sending the AES key through insecure channels. You can only rely on asymmetric encryption systems Like RSA in such cases. you keep the private key at your server side and only share the public key with your clients. Even more you can use hybrid RSA_AES approach to archive more performance

BBMA Oma Ally OmniView BBMA Oma Ally OmniView

It's like a bird's-eye view for BBMA Oma Ally fans. ust drag it onto the chart and you'll get all the BBMA signals running on the chart.