Download MetaTrader 5

Calculating Spread

To add comments, please log in or register
Lovro Mirnik
54
Lovro Mirnik  

Hello fellow Traders,

would this be the correct way to calculate spread?

double BidPN; //Bid Price New
double AskPN; //Ask Price New
double SpreadC;

void OnTick()
   {
      BidPN = Bid;
      AskPN = Ask;
      SpreadC = MathAbs(AskPN - BidPN);
   }
Carl Schreiber
6995
Carl Schreiber  
You don't need MathAbs(Ask-Bid) as some brokers proudly presents their occasionally appearing negative spreads.
Alain Verleyen
Moderator
32027
Alain Verleyen  
lovromirnik:

Hello fellow Traders,

would this be the correct way to calculate spread?

Or

SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);

or

MarketInfo(_Symbol,MODE_SPREAD);
Lovro Mirnik
54
Lovro Mirnik  
Thank you both for replying and confirming my code.
To add comments, please log in or register