MarketInfo() gives zero

 

Hi!

My account is in USD and I trade in EURGBP. I would like to calculate for example the margin for an order. That's why I need the Bid or Ask price of the GBPUSD. I tried to use the MarketInfo() function to get it. I used this code: double gbpusd_ask = MarketInfo("GBPUSD",MODE_ASK) ;

But I have a bit problem with it. At the Backtest, the dbpusd_ask variable is always 0. Don't know why. Is there any thing what I should have to do before use MarketInfo()? Or why give it always zero to me?

Have you got any idea?

 
Relative:

. Is there any thing what I should have to do before use MarketInfo()? Or why give it always zero to me?


Yes, it will be very usefull to read article Testing Features and Limits in MetaTrader 4

Using of MarketInfo function generates error ERR_FUNCTION_NOT_ALLOWED_IN_TESTING_MODE(4059), however, correct information about current prices for the symbol under test, about stop level dimensions, about point size, about spread size of any symbol being present in the quotes window is provided.

 

Ok, thank you Rosh. I will read that article...

I have read it. But it wasn't so usefull.

I found another way to calculate the GBPUSD price:

  if ( AccountFreeMargin() - AccountFreeMarginCheck(Symbol(),OP_SELL,0.1) != 0 )

       GBPUSD_rate = 10 * ( AccountFreeMargin() - AccountFreeMarginCheck(Symbol(),OP_SELL,0.1)) / (1000*Ask) ;
  else

       GBPUSD_rate = 10 * ( AccountFreeMargin() - AccountFreeMarginCheck(Symbol(),OP_BUY,0.1)) / (1000*Ask) ;