calculate spead

1 June 2017, 08:09
Jatin Patel
0
33

//--- obtain spread from the symbol properties 
   bool spreadfloat=SymbolInfoInteger(Symbol(),SYMBOL_SPREAD_FLOAT); 
   string comm=StringFormat("Spread %s = %I64d points\r\n", 
                            spreadfloat?"floating":"fixed", 
                            SymbolInfoInteger(Symbol(),SYMBOL_SPREAD)); 
//--- now let's calculate the spread by ourselves 
   double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK); 
   double bid=SymbolInfoDouble(Symbol(),SYMBOL_BID); 
   double spread=ask-bid; 
   int spread_points=(int)MathRound(spread/SymbolInfoDouble(Symbol(),SYMBOL_POINT)); 
   comm=comm+"Calculated spread = "+(string)spread_points+" points"; 
   Comment(comm); 



 double myspread=(SymbolInfoDouble(_Symbol,SYMBOL_ASK)-SymbolInfoDouble(_Symbol,SYMBOL_BID))/_Point;

Share it with friends: