for (int i=0;i<SymbolsTotal(false);i++) { crtsymbol=SymbolName(i,false); Print("Symbol ",i," is ",crtsymbol); if (SymbolInfoInteger(crtsymbol,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX&&StringLen(crtsymbol)>=6) //if symbol is forex { Pairs[pairscount]=crtsymbol; pairscount++; } } for (int i=0;i<SymbolsTotal(false);i++) { crtsymbol=SymbolName(i,false);// we get the symbol name if (SymbolInfoInteger(crtsymbol,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX&&StringLen(crtsymbol)>=6) //if symbol is forex { SymbolName(i,true); //we reactivate it back } }
and the log:
GH 0 Tester 21:22:40 GenerateError=false QF 0 Symbols 21:22:40 #AA: symbol synchronized, 2904 bytes of symbol info received DI 0 NoPricesErrorDirectly (EURUSD,M1) 21:22:40 2010.01.04 00:00:00 Symbol 0 is #AA IQ 0 Symbols 21:22:41 #AIG: symbol synchronized, 2904 bytes of symbol info received IK 0 NoPricesErrorDirectly (EURUSD,M1) 21:22:41 2010.01.04 00:00:00 Symbol 1 is #AIG HG 0 Symbols 21:22:42 #AXP: symbol synchronized, 2904 bytes of symbol info received ... FS 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 Symbol 58 is USDSEK DE 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 Pairs array: HH 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 AUDCAD MR 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 AUDCHF KE 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 AUDJPY RN 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 AUDNZD DQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 AUDUSD OJ 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 CADCHF HS 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 CHFJPY PD 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURAUD JO 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURCAD KQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURCHF OK 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURGBP QL 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURJPY DG 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURNZD CI 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURRUR NQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 EURUSD JJ 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 GBPCHF HL 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 GBPJPY CF 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 GBPUSD LI 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 NZDUSD NR 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 USDCAD OD 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 USDCHF IN 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 USDJPY OF 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 USDRUR CH 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 USDSEK MQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:00 finished OnInit KE 2 Symbols 21:23:35 no prices for symbol USDCAD IO 2 Symbols 21:23:35 no prices for symbol USDCAD OE 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:02 Tickvalue of AUDCAD is 0 JL 2 Symbols 21:23:35 no prices for symbol USDCHF DF 2 Symbols 21:23:35 no prices for symbol USDCHF NM 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:02 Tickvalue of AUDCHF is 0 HD 2 Symbols 21:23:35 no prices for symbol USDJPY NM 2 Symbols 21:23:35 no prices for symbol USDJPY DJ 0 NoPricesErrorDirectly (EURUSD,M1) 21:23:35 2010.01.04 00:00:02 Tickvalue of AUDJPY is 0
I don't see any difference versus first log. So either the function knows to deactivate, but not how to activate or it doesn't know any of them, symbols were already deactivated from the beginning and function's deactivation procedure didn't change anything.
Now let's replace SymbolName in the second call with SymbolSelect:
for (int i=0;i<SymbolsTotal(false);i++) { crtsymbol=SymbolName(i,false); Print("Symbol ",i," is ",crtsymbol); if (SymbolInfoInteger(crtsymbol,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX&&StringLen(crtsymbol)>=6) //if symbol is forex { Pairs[pairscount]=crtsymbol; pairscount++; } } for (int i=0;i<pairscount;i++) { SymbolSelect(Pairs[i],true); }
and the log is:
PF 0 Symbols 21:25:33 #AA: symbol synchronized, 2904 bytes of symbol info received EI 0 NoPricesErrorDirectly (EURUSD,M1) 21:25:33 2010.01.04 00:00:00 Symbol 0 is #AA FQ 0 Symbols 21:25:34 #AIG: symbol synchronized, 2904 bytes of symbol info received FK 0 NoPricesErrorDirectly (EURUSD,M1) 21:25:34 2010.01.04 00:00:00 Symbol 1 is #AIG EG 0 Symbols 21:25:35 #AXP: symbol synchronized, 2904 bytes of symbol info received ... OJ 0 Symbols 21:26:26 USDSEK: symbol synchronized, 2904 bytes of symbol info received GS 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 Symbol 58 is USDSEK IE 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 Pairs array: EH 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 AUDCAD PR 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 AUDCHF RE 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 AUDJPY KN 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 AUDNZD IQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 AUDUSD NJ 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 CADCHF ES 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 CHFJPY MD 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURAUD CO 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURCAD RQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURCHF NK 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURGBP LL 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURJPY IG 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURNZD JI 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURRUR OQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 EURUSD CJ 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 GBPCHF EL 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 GBPJPY JF 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 GBPUSD QI 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 NZDUSD OR 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 USDCAD ND 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 USDCHF DN 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 USDJPY NF 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 USDRUR JH 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 USDSEK PQ 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:00 finished OnInit RE 2 Symbols 21:26:26 no prices for symbol USDCAD DO 2 Symbols 21:26:26 no prices for symbol USDCAD NE 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:02 Tickvalue of AUDCAD is 0 CL 2 Symbols 21:26:26 no prices for symbol USDCHF IF 2 Symbols 21:26:26 no prices for symbol USDCHF OM 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:02 Tickvalue of AUDCHF is 0 ED 2 Symbols 21:26:26 no prices for symbol USDJPY OM 2 Symbols 21:26:26 no prices for symbol USDJPY IJ 0 NoPricesErrorDirectly (EURUSD,M1) 21:26:26 2010.01.04 00:00:02 Tickvalue of AUDJPY is 0As you can see, SymbolSelect did not reactivate back the forex symbols.
Original code,
int pairscount=0; string Pairs[100]; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { string crtsymbol; for (int i=0;i<SymbolsTotal(false);i++) { crtsymbol=SymbolName(i,false); Print("Symbol ",i," is ",crtsymbol); if (SymbolInfoInteger(crtsymbol,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX&&StringLen(crtsymbol)>=6) //if symbol is forex { Pairs[pairscount]=crtsymbol; pairscount++; } } Print("Pairs array:"); for (int i=0;i<pairscount;i++) Print(Pairs[i]); Print("finished OnInit"); return(0); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { for (int i=0;i<pairscount;i++) { SymbolSelect(Pairs[i],true); Print("Tickvalue of ",Pairs[i]," is ",SymbolInfoDouble(Pairs[i],SYMBOL_TRADE_TICK_VALUE)); } } //+------------------------------------------------------------------+
running on forward testing:
FJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 0 is EURUSD PR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 1 is GBPUSD QK 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 2 is USDCHF LP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 3 is USDJPY FH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 4 is USDCAD OP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 5 is AUDUSD HI 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 6 is AUDNZD MO 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 7 is AUDCAD IG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 8 is AUDCHF DN 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 9 is AUDJPY OD 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 10 is CHFJPY MN 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 11 is EURGBP IF 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 12 is EURAUD ON 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 13 is EURCHF RQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 14 is EURJPY FH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 15 is EURNZD OP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 16 is EURCAD JJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 17 is GBPCHF OR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 18 is GBPJPY QJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 19 is CADCHF IP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 20 is #AA GK 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 21 is #AIG NS 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 22 is #AXP IG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 23 is #BA QR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 24 is #BAC IJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 25 is #C ES 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 26 is #CAT EI 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 27 is #CVX IM 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 28 is #DD HH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 29 is #DIS JL 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 30 is #EK QD 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 31 is #GE RL 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 32 is #HD RH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 33 is #HON IG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 34 is #HPQ EO 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 35 is #IBM DJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 36 is #INTC DS 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 37 is #IP HF 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 38 is #JNJ JL 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 39 is #JPM DD 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 40 is #KFT JQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 41 is #KO ID 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 42 is #MCD IL 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 43 is #MMM GH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 44 is #MO RR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 45 is #MRK EG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 46 is #MSFT GR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 47 is #PFE HG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 48 is #PG NS 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 49 is #T HK 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 50 is #TRV JP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 51 is #UTX JE 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 52 is #VZ KQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 53 is #WMT DI 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 54 is #XOM PO 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 55 is NZDUSD PP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 56 is USDRUR IH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 57 is EURRUR RQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Symbol 58 is USDSEK DJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 Pairs array: RQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURUSD KI 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 GBPUSD CG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 USDCHF QN 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 USDJPY NE 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 USDCAD PM 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 AUDUSD RK 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 AUDNZD LS 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 AUDCAD EH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 AUDCHF OQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 AUDJPY DO 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 CHFJPY KG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURGBP PL 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURAUD CD 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURCHF QS 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURJPY PK 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURNZD NQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURCAD JI 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 GBPCHF LF 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 GBPJPY GN 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 CADCHF PD 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 NZDUSD KM 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 USDRUR KJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 EURRUR CS 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 USDSEK IK 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:30 finished OnInit JN 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURUSD is 1 OE 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of GBPUSD is 1 JR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of USDCHF is 1.014239928597509 PI 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of USDJPY is 1.185508345978756 LG 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of USDCAD is 0.9672115291614276 NP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of AUDUSD is 1 QJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of AUDNZD is 0.7295700000000002 NF 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of AUDCAD is 0.9672115291614276 FQ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of AUDCHF is 1.014239928597509 DN 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of AUDJPY is 1.185508345978756 CJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of CHFJPY is 1.185508345978756 JP 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURGBP is 1.56778 EM 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURAUD is 0.9495900000000002 JK 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURCHF is 1.014239928597509 PF 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURJPY is 1.185508345978756 IO 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURNZD is 0.7295700000000002 JJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURCAD is 0.9672115291614276 OE 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of GBPCHF is 1.014239928597509 QR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of GBPJPY is 1.185508345978756 JO 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of CADCHF is 1.014239928597509 PJ 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of NZDUSD is 1 NR 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of USDRUR is 0.03224246332419797 FN 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of EURRUR is 0.03224246332419797 GH 0 NoPricesErrorDirectly (USDJPY,M5) 21:34:32 Tickvalue of USDSEK is 0.1445728090352223
So, MQ gentlemen, what is wrong with these goddamn functions ?
It seems that on forward testing SymbolName didn't touch the activation status - they are still in MarketWatch. And it works goddamn well!
Ok. I'll set symbols manually:
int pairscount=0; string Pairs[100]; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { Pairs[0]="EURUSD"; Pairs[1]="GBPUSD"; Pairs[2]="USDCHF"; Pairs[3]="USDJPY"; Pairs[4]="USDCAD"; Pairs[5]="AUDUSD"; Pairs[6]="AUDNZD"; Pairs[7]="AUDCAD"; Pairs[8]="AUDCHF"; Pairs[9]="AUDJPY"; Pairs[10]="CHFJPY"; Pairs[11]="EURGBP"; Pairs[12]="EURAUD"; Pairs[13]="EURCHF"; Pairs[14]="EURJPY"; pairscount=15; Print("Pairs array:"); for (int i=0;i<pairscount;i++) { Print(Pairs[i]); SymbolSelect(Pairs[i],true); } Print("finished OnInit"); return(0); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { for (int i=0;i<pairscount;i++) { SymbolSelect(Pairs[i],true); Print("Tickvalue of ",Pairs[i]," is ",SymbolInfoDouble(Pairs[i],SYMBOL_TRADE_TICK_VALUE)); } } //+------------------------------------------------------------------+
which yields:
OF 0 Symbols 21:45:10 EURCHF: symbol to be synchronized FS 0 Symbols 21:45:11 EURCHF: symbol synchronized, 2904 bytes of symbol info received PK 0 History 21:45:12 EURCHF: load 27 bytes of history data to synchronize EM 0 History 21:45:12 EURCHF: history synchronized from 1993.04.28 to 2010.09.22 HK 0 NoPricesManual (EURUSD,M1) 21:45:12 2010.01.04 00:00:00 EURJPY QP 0 Symbols 21:45:12 EURJPY: symbol to be synchronized HE 0 Symbols 21:45:13 EURJPY: symbol synchronized, 2904 bytes of symbol info received NI 0 History 21:45:14 EURJPY: load 27 bytes of history data to synchronize NR 0 History 21:45:14 EURJPY: history synchronized from 1993.04.27 to 2010.09.22 PJ 0 NoPricesManual (EURUSD,M1) 21:45:14 2010.01.04 00:00:00 finished OnInit MM 0 NoPricesManual (EURUSD,M1) 21:45:14 2010.01.04 00:00:02 Tickvalue of EURUSD is 1 RQ 0 NoPricesManual (EURUSD,M1) 21:45:14 2010.01.04 00:00:02 Tickvalue of GBPUSD is 1 IE 0 NoPricesManual (EURUSD,M1) 21:45:14 2010.01.04 00:00:02 Tickvalue of USDCHF is 0.9661555703699412 CH 0 NoPricesManual (EURUSD,M1) 21:45:14 2010.01.04 00:00:02 Tickvalue of USDJPY is 1.075928257103817 RH 0 NoPricesManual (EURUSD,M1) 21:45:14 2010.01.04 00:00:02 Tickvalue of USDCAD is 0.9549091881362083 IN 0 NoPricesManual (EURUSD,M1) 21:45:14 2010.01.04 00:00:02 Tickvalue of AUDUSD is 1 RN 0 Symbols 21:45:14 NZDUSD: symbol to be synchronized GM 0 Symbols 21:45:15 NZDUSD: symbol synchronized, 2904 bytes of symbol info received QS 0 History 21:45:16 NZDUSD: load 27 bytes of history data to synchronize ND 0 History 21:45:16 NZDUSD: history synchronized from 1994.02.01 to 2010.09.22 QN 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of AUDNZD is 0.7250400000000001 HR 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of AUDCAD is 0.9549091881362083 IQ 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of AUDCHF is 0.9661555703699412 CD 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of AUDJPY is 1.075928257103817 RH 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of CHFJPY is 1.075928257103817 LI 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of EURGBP is 1.6121 RM 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of EURAUD is 0.8993800000000001 OQ 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of EURCHF is 0.9661555703699412 ME 0 NoPricesManual (EURUSD,M1) 21:45:16 2010.01.04 00:00:02 Tickvalue of EURJPY is 1.075928257103
This demonstrates, black on white, that the symbol functions are blasted on the tester! I don't know if it's SymbolsTotal or SymbolName. But we need them to work on tester as they work for real,
and I don't want to see us going back to the way we were discovering currencies in MT4, by making pairs and testing if there is a quote or not for them. I hope this is conclusive.
In the end I added USDRUR and EURRUR and the EA worked same way.
(logs were cut because the site didn't let me add - some red text "Enter the text of your post" - and then I had to repost, using multiple posts)
Lets go step by step.
First. Code below works correctly,
//+------------------------------------------------------------------+ //| CheckSymbolName_All.mq5 | //| Copyright 2010, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2010, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" int pairscount=0; string Pairs[100]; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { string crtsymbol; for(int i=0;i<SymbolsTotal(false);i++)// All symbols { crtsymbol=SymbolName(i,false); // get symbol name from global list Print("Symbol ",i," is ",crtsymbol); if(SymbolInfoInteger(crtsymbol,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX && StringLen(crtsymbol)>=6) { Pairs[pairscount]=crtsymbol; pairscount++; } } Print("Pairs array:"); for(int i=0;i<pairscount;i++) Print(Pairs[i]); Print("finished OnInit"); return(0); }
Result:
NP 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 0 is EURUSD LI 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 1 is GBPUSD QP 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 2 is USDCHF HH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 3 is USDJPY NQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 4 is USDCAD KH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 5 is AUDUSD HQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 6 is AUDNZD IH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 7 is AUDCAD QS 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 8 is AUDCHF HK 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 9 is AUDJPY OQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 10 is CHFJPY QI 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 11 is EURGBP QQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 12 is EURAUD KH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 13 is EURCHF RO 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 14 is EURJPY JF 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 15 is EURNZD GO 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 16 is EURCAD FG 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 17 is GBPCHF OO 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 18 is GBPJPY ME 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 19 is CADCHF RL 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 20 is NZDUSD LD 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 21 is USDSEK OM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 22 is USDRUR JE 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 23 is EURRUR // 24 forex symbols EN 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 24 is #AA OJ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 25 is #AIG JE 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 26 is #AXP QQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 27 is #BA EE 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 28 is #BAC IM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 29 is #C PD 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 30 is #CAT DM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 31 is #CVX PI 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 32 is #DD EL 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 33 is #DIS NI 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 34 is #EK IQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 35 is #GE NI 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 36 is #HD RM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 37 is #HON EE 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 38 is #HPQ MM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 39 is #IBM CH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 40 is #INTC GQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 41 is #IP CD 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 42 is #JNJ QM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 43 is #JPM HE 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 44 is #KFT JP 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 45 is #KO MD 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 46 is #MCD QL 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 47 is #MMM KH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 48 is #MO RM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 49 is #MRK PH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 50 is #MSFT RN 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 51 is #PFE QJ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 52 is #PG ON 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 53 is #T LF 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 54 is #TRV JN 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 55 is #UTX FK 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 56 is #VZ CO 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 57 is #WMT HF 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 58 is #XOM HR 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 59 is ED-9.10 EH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 60 is GAZR-12.10 NL 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 61 is GAZR-9.10 CG 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 62 is LKOH-12.10 PM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 63 is LKOH-9.10 LH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 64 is RTS-12.10 IR 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 65 is RTS-9.10 NG 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 66 is SBRF-9.10 DK 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 67 is Si-9.10 OQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Symbol 68 is SILV-9.10 FH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 Pairs array: DS 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURUSD EK 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 GBPUSD ID 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 USDCHF OO 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 USDJPY HF 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 USDCAD JP 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 AUDUSD LK 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 AUDNZD NS 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 AUDCAD OL 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 AUDCHF IE 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 AUDJPY JN 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 CHFJPY MH 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURGBP FQ 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURAUD MK 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURCHF KE 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURJPY RM 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURNZD HG 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURCAD PO 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 GBPCHF RI 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 GBPJPY IS 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 CADCHF FK 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 NZDUSD MD 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 USDSEK QN 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 USDRUR MG 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 EURRUR // 24 forex symbols KS 0 CheckSymbolName_All (EURJPY,M1) 16:40:42 finished OnInit
As you can see, SymbolSelect did not reactivate back the forex symbols.
Second. It isn't true, all symbol appeared in Market Watch. See video.
Original code,
running on forward testing:
So, MQ gentlemen, what is wrong with these goddamn functions ?
It seems that on forward testing SymbolName didn't touch the activation status - they are still in MarketWatch. And it works goddamn well!
Third. You are right, thank you. EA in Strategy Tester sees all symbols though it does not have to. We will investigate this situation.
Second. It isn't true, all symbol appeared in Market Watch. See video.
Third. You are right, thank you. EA in Strategy Tester sees all symbols though it does not have to. We will investigate this situation.
Am I right?
Was the bug addressed by build 338 ? Because I see that the original code:
int pairscount=0; string Pairs[100]; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { string crtsymbol; for (int i=0;i<SymbolsTotal(false);i++) { crtsymbol=SymbolName(i,false); Print("Symbol ",i," is ",crtsymbol); if (SymbolInfoInteger(crtsymbol,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX&&StringLen(crtsymbol)>=6) //if symbol is forex { Pairs[pairscount]=crtsymbol; pairscount++; } } Print("Pairs array:"); for (int i=0;i<pairscount;i++) { Print(Pairs[i]); SymbolSelect(Pairs[i],true); } Print("finished OnInit"); return(0); }
gives same results.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
And I say in backtester, because only there it happens. I am returning with this bug here on forum, because I have a huge function that needs to work in the tester, yet it's impossible because of this.
SymbolName(...,true) returns blank string outside previously activated symbols.
There is absolutely no way to make a decent enumeration of the symbols.
SymbolsTotal(true) returns the number of the symbols from the MarketWatch window, or the ones activated in the tester.
That is, for the tester, it returns always 1.
If you want to enumerate all symbols, you have to use SymbolsTotal(false).
Now regarding SymbolName, there is a slight difference between Help and what it actually does:
SymbolsTotal(true) returns the number of the symbols from the MarketWatch window, or the ones activated in the tester.
That is, for the tester, it returns always 1.
If you want to enumerate all symbols, you have to use SymbolsTotal(false).
Now regarding SymbolName, there is a slight difference between Help and what it actually does:
At that time it didn't strike me that Rosh showed me the SymbolSelect function instead of SymbolName.
SymbolName reads like this:
So, my code was actually correct, given SymbolName() help. If the value is false, the symbol is taken from the general list. So, I am enumerating symbols from 0 to the last one - SymbolsName(false) , and I am retrieving their names with SymbolName(i, false), since the symbol is taken from the general list. SymbolName() help for Request Mode is not the same as SymbolSelect() help for the Switch.Does anyone agree with me up to this point?
So this tiny piece of code:
does this:
So, the code doesn't do what the SymbolName says, it does actually what SymbolSelect says, though I didn't use it, right?
But ok, Mr. Rosh said to correct my code, and put a true instead of false in the SymbolName function. All right:
The function works with half truths: on one hand, it takes the symbol from the activated symbol lists, as it says in the help, but for the ones already inactive it returns a blank string. And if does that, I don't give a damn that symbols are activated after, because the function doesn't retrieve them. Oh boy!
Now let's do something different. We use both blocks: we use my version, that gives symbol names, and then we activate the ones we want, with SymbolName - because it really activates, right? That's what I got from the message. If false deactivates, true activates.