This library allow an easy control over multiple currencies, on every update it will check for errors, this way you can use it in your indicator or expert to avoid common error and rewrite not needed parts, focusing more on your business and leave hassle away.
How to use it , just include the library and define the CSymbolCollection, add symbols and Update before calculations :Â
CSymbolCollection *SCollection = new CSymbolCollection(TotalBarsToCalculate); SCollection.Add("EURUSD"); SCollection.Update();
Update() method return a boolean, if false it will print in journal which currency need more history to be processed. After this you can loop for every currencies to get the MqlRates or get the specific price directly ::Â
int collection_length = SCollection.GetCollectionLength(); // get the total number of currency added for(int s=0;s<collection_length;s++) { Â Â Â Â MqlRates rate_prev = SCollection.GetRateAtPos(s,bar-VariationPeriod); Â Â Â Â MqlRates rate_actual = SCollection.GetRateAtPos(s,bar); Â Â Â Â momentum=(rate_actual.close*100/rate_prev.close); }
int collection_length = SCollection.GetCollectionLength(); // get the total number of currency added for(int s=0;s<collection_length;s++) { Â Â Â Â double close_prev = SCollection.GetCloseAtPos(s,bar-VariationPeriod); Â Â Â Â double close_actual = SCollection.GetCloseAtPos(s,bar); Â Â Â Â momentum=(close_actual*100/close_prev); }
This library is used by my indicator Multi Momentum downloadable from the codebase.