string symbols[] = {"AUDCAD", "AUDCHF", "AUDJPY", "AUDNZD", "AUDUSD", "EURAUD", "GBPAUD"}; int arraySize = ArraySize(symbols); for(int i=0; i < arraySize; i++) { string pair = arr[i]; double bidPrice = getMarketBidPrice(pair); // More code ... }
What's the arr[ i ]?
I think that in this case you should use symbols[ i ].
Oh! that was a typo here.. but still result is same.. as you can see in the Print(..) output above.
Oh! that was a typo here.. but still result is same.. as you can see in the Print(..) output above.
Have you ever opened charts of these pairs? Because if not, there is no historical data in your MT4 and it seems there is no problem in your program.
Hello everyone,
I have an array of symbols and I am trying to use current bid price using MarketInfo() for each elements of this array.
For the Print(...), I always get as follows:
I can't get it to work. I would appreciate some help.
Thanks for looking at it.
The code works OK on my terminal
2018.01.02 08:23:08.550 _test BTCEUR,H4: Currency: GBPAUD MarketInfo: 1.72593 2018.01.02 08:23:08.550 _test BTCEUR,H4: Currency: EURAUD MarketInfo: 1.5345 2018.01.02 08:23:08.550 _test BTCEUR,H4: Currency: AUDUSD MarketInfo: 0.78373 2018.01.02 08:23:08.550 _test BTCEUR,H4: Currency: AUDNZD MarketInfo: 1.10042 2018.01.02 08:23:08.550 _test BTCEUR,H4: Currency: AUDJPY MarketInfo: 88.286 2018.01.02 08:23:08.550 _test BTCEUR,H4: Currency: AUDCHF MarketInfo: 0.76263 2018.01.02 08:23:08.550 _test BTCEUR,H4: Currency: AUDCAD MarketInfo: 0.98185 2018.01.02 08:23:08.199 _test BTCEUR,H4: Currency: GBPAUD MarketInfo: 1.72595 2018.01.02 08:23:08.199 _test BTCEUR,H4: Currency: EURAUD MarketInfo: 1.5345 2018.01.02 08:23:08.199 _test BTCEUR,H4: Currency: AUDUSD MarketInfo: 0.78373
Check if the symbols are correct (ie: do you have symbols prefixes or suffixes and are those symbols enabled in the market watch)
Code used for test was the following :
#property strict int OnInit() {return(INIT_SUCCEEDED);} void OnDeinit(const int reason) {} void OnTick() { string symbols[] = {"AUDCAD", "AUDCHF", "AUDJPY", "AUDNZD", "AUDUSD", "EURAUD", "GBPAUD"}; int arraySize = ArraySize(symbols); for(int i=0; i < arraySize; i++) { string pair = symbols[i]; double bidPrice = getMarketBidPrice(pair); // More code ... } } double getMarketBidPrice(string currencyPair) { double currencyValue = MarketInfo(currencyPair, MODE_BID); Print("Currency: ", currencyPair ," MarketInfo: ", currencyValue); return currencyValue; }
Thanks everyone.
Code worked fine on live demo account. Looks like there are some issues with Strategy Tester.
Thanks again 'n appreciate your inputs.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
I have an array of symbols and I am trying to use current bid price using MarketInfo() for each elements of this array.