mysymbol.Ask()=0 on tester...????

 

I have this simple piece, but I found this difference on the tester. Can I use symbolinfo object during tester? Or is it this object only applies to current?

#include <Trade\SymbolInfo.mqh>

CSymbolInfo mysymbol;

Print("Obj Price = ",mysymbol.Ask(), " Price= ", SymbolInfoDouble(Symbol(),SYMBOL_ASK));

The result is:

2011.10.26 15:17:13    Core 1    2011.10.24 00:59:59   Obj Price = 0 Price= 1.38467
2011.10.26 15:17:13    Core 1    2011.10.24 00:59:40   Obj Price = 0 Price= 1.38467
2011.10.26 15:17:13    Core 1    2011.10.24 00:59:20   Obj Price = 0 Price= 1.38481
2011.10.26 15:17:13    Core 1    2011.10.24 00:59:00   Obj Price = 0 Price= 1.3848
2011.10.26 15:17:13    Core 1    2011.10.24 00:58:59   Obj Price = 0 Price= 1.38476
2011.10.26 15:17:13    Core 1    2011.10.24 00:58:40   Obj Price = 0 Price= 1.38469

 
stargazer:

I have this simple piece, but I found this difference on the tester. Can I use symbolinfo object during tester? Or is it this object only applies to current?

The result is:

2011.10.26 15:17:13    Core 1    2011.10.24 00:59:59   Obj Price = 0 Price= 1.38467
2011.10.26 15:17:13    Core 1    2011.10.24 00:59:40   Obj Price = 0 Price= 1.38467
2011.10.26 15:17:13    Core 1    2011.10.24 00:59:20   Obj Price = 0 Price= 1.38481
2011.10.26 15:17:13    Core 1    2011.10.24 00:59:00   Obj Price = 0 Price= 1.3848
2011.10.26 15:17:13    Core 1    2011.10.24 00:58:59   Obj Price = 0 Price= 1.38476
2011.10.26 15:17:13    Core 1    2011.10.24 00:58:40   Obj Price = 0 Price= 1.38469

I think you have to refresh the object first:

mysymbol.RefreshRates()

 
willgart:

tried that in this simpler script. doesnt work.... thx anyway for your response.

#include <Trade\SymbolInfo.mqh>


//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   CSymbolInfo *mysymbol=new CSymbolInfo;
   mysymbol.RefreshRates();
   Alert("tst ",mysymbol.Name());
   
   return;
  }