Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Multi-Currency Library - Library for MetaTrader 5 | Forex Indicator Downloads - MT4/MT5 Resources - MetaTrader 5 Resources

author EAcpu | 5 reads | 0 comments |

The library allows easy control of multiple currencies, it checks for errors every time it is updated, so you can use it in indicators or experts to avoid common mistakes and rewrite unnecessary parts, focus more on your business and stay away from trouble.

How to use it, just include the library and define a CSymbolCollection, add symbols and update before calculation:

 CSymbolCollection *SCollection = new CSymbolCollection(TotalBarsToCalculate);
SCollection.Add( “EUR/USD” ); SCollection.Update();

The Update() method returns a boolean value, if false it will print in the log which currency needs more history to process. Afterwards you can loop through each currency to get MqlRates or get the specific prices directly: :

 Integer collection_length = SCollection.GetCollectionLength(); // Get the total number of currencies added
for ( integer s= 0 ;s<set length;s++) {
Mql rate rate_prev = SCollection.GetRateAtPos(s,bar-VariationPeriod);
Mql rate rate_actual = SCollection.GetRateAtPos(s,bar);

    Momentum=(rate_actual.close* 100 /rate_prev.close);
}
 Integer collection_length = SCollection.GetCollectionLength(); // Get the total number of currencies added
for ( integer s= 0 ;s<set length;s++) {

Double close_prev = SCollection.GetCloseAtPos(s,bar-VariationPeriod);
Double close_actual = SCollection.GetCloseAtPos(s,bar);

    Momentum = (close to actual * 100 /close_prev);
}

My multi-momentum indicator uses this library, which can be downloaded from the code repository.


Attachment download

📎 multimomentum.mq5 (4.48 KB)

📎 symbolcollection.mqh (6.26 KB)

Source: MQL5 #33656

Verification code Refresh