How to get current bid/ask price

 

Hi all,

I am developing an EA. I want to get the current price, please tell me how to get it.

I have read that Bid is the current market price, is that true,

Thanks.

 

Hi

Use this to get the current BID, ASK price.

For STP brokers the BID price is used for the current market price as a reference punt.


// Info of the last tick.
//-----------------------
   
// To be used for getting recent/latest price quotes
   MqlTick Latest_Price; // Structure to get the latest prices      
   SymbolInfoTick(Symbol() ,Latest_Price); // Assign current prices to structure 

// The BID price.
   static double dBid_Price; 

// The ASK price.
   static double dAsk_Price; 

   dBid_Price = Latest_Price.bid;  // Current Bid price.
   dAsk_Price = Latest_Price.ask;  // Current Ask price.
 

You can also use this method:


// Info of the last BAR
//---------------------------------

// Rates Structure for the data of the Last incomplete BAR
   MqlRates BarData[1]; 
   CopyRates(Symbol(), Period(), 0, 1, BarData); // Copy the data of last incomplete BAR

// Copy latest close prijs.
   double Latest_Close_Price = BarData[0].close;
 
metatraderpk:

Hi all,

I am developing an EA. I want to get the current price, please tell me how to get it.

I have read that Bid is the current market price, is that true,

Thanks.

double current_bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

double current_ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 

 

hi metatraderpk


can u pl share the code for current markert price and not of bid/ask  price

 
kubervivek: can u pl share the code for current markert price and not of bid/ask  price

The "current market price" is the bid/ask.

 
metatraderpk:

Hi all,

I am developing an EA. I want to get the current price, please tell me how to get it.

I have read that Bid is the current market price, is that true,

Thanks.

this can also help you 


    double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits); // Get the Ask Price

    double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits); // Get the Bid Price


 
metatraderpk:

Hi all,

I am developing an EA. I want to get the current price, please tell me how to get it.

I have read that Bid is the current market price, is that true,

Thanks.

I find it weird that most comments here gave only bid/ask possibility.
Though the closest thing to currentPrice will generally be

double price =SymbolInfoDouble(_Symbol,SYMBOL_LAST);

or

SymbolInfoTick(Symbol(),last_tick)

as the last price is the price shown in most of the charts.

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: