Calculating Spread

 

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);
   }
 
You don't need MathAbs(Ask-Bid) as some brokers proudly presents their occasionally appearing negative spreads.
 
lovromirnik:

Hello fellow Traders,

would this be the correct way to calculate spread?

Or

SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);

or

MarketInfo(_Symbol,MODE_SPREAD);
 
Thank you both for replying and confirming my code.
Reason: