Ask/Bid on the main fuction OnCalculate

 

Hello,

I would like to ask if it is possible to use the Bid/Ask price in OnCalculate ... if not, how do we get the current price and not only the high and the low of the previous candle?

Thanks in advance

 
ochan chin:

Hello,

I would like to ask if it is possible to use the Bid/Ask price in OnCalculate ... if not, how do we get the current price and not only the high and the low of the previous candle?

Thanks in advance

Yes

double m_Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),(int)SymbolInfoInteger(_Symbol,SYMBOL_DIGITS)); // Get the Bid Price
double m_Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),(int)SymbolInfoInteger(_Symbol,SYMBOL_DIGITS)); // Get the Bid Price
 
ochan chin: I would like to ask if it is possible to use the Bid/Ask price in OnCalculate ... if not, how do we get the current price and not only the high and the low of the previous candle?

 

Rajesh Kumar Nait #: Yes

Prices returned by the terminal are already normalised. No need to redo it.
double
   m_Bid = SymbolInfoDouble( _Symbol, SYMBOL_BID ), // Get the Bid Price
   m_Ask = SymbolInfoDouble( _Symbol, SYMBOL_ASK ); // Get the Ask Price
 
Fernando Carreiro #:
Prices returned by the terminal are already normalised. No need to redo it.

Right. But it's recommended to use SymbolInfoTick() which is slightly faster (1 function call against 2).

 
thanks everyone , it worked ))