Download MetaTrader 5

bid/ask price .....

To add comments, please log in or register
Are you accustomed to using the standard library? MQL5 has one!
thriller372
60
thriller372 2016.06.29 18:39 

Is it possible to get the Bid/Ask price in the top left of the chart screen & use those prices as variables in calculations using an indicator, I have searched for days & it's sheer desperation I ask now. I'm not asking for the code just whether it can be done or not OR do I need to do this as an EA. I can do it as a script but then I don't know if I can include scripts in an EA or indicator or if I can use that information in my calculations.

This is what I have found so far (as script)

void OnTick() 

  { 

//--- 

   double Ask,Bid; 

   int Spread; 

   Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK); 

   Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID); 

   Spread=SymbolInfoInteger(Symbol(),SYMBOL_SPREAD); 

//--- Output values in three lines 

   Comment(StringFormat("Show prices\nAsk = %G\nBid = %G\nSpread = %d",Ask,Bid,Spread)); 

  } 

Would I be able to include this in an indicator/EA and use the bid/ask price as variables (hope that's a little more clear) 

Thanks for any advice

Alain Verleyen
Moderator
30727
Alain Verleyen 2016.06.29 19:58  

What you posted is not a script, it's an EA (or a part of).

Everything can be done, but honestly I don't understand your problem.

You don't need to display anything on a chart to afterwards use it in an indicator.

thriller372
60
thriller372 2016.06.30 16:32  
Alain Verleyen:

What you posted is not a script, it's an EA (or a part of).

Everything can be done, but honestly I don't understand your problem.

You don't need to display anything on a chart to afterwards use it in an indicator.

Thank you, that's actually a big help. I'm trying to learn about coding but it's a lot harder than I thought & there are no really basic tutorials out there. Much appreciated :)
To add comments, please log in or register