Another nifty way of doing this is to use the CSymbolInfo library and its functions. You would use something like this (not tested):
CSymbolInfo symbol; //declare the symbol object symbol.Name("Symbol1"); //select Symbol1 double Ask1 = symbol.Ask(); //get Ask Price symbol.Name("Symbol2"); //select Symbol2 double Ask2 = symbol.Ask(); //get Ask Price
It's a bit easier to read and you can continue working on the symbol this way.
Also, I recommend not to call your variable Ask2 but then fill it with a bid price. Might hunt you further down the line.
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
- www.mql5.com
//| Expert initialization function | //| Expert deinitialization function | //| Expert tick function | //| test1 |...
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
i have a very simple question but i just can't figure it out. the syntax just doesn't work and i've already tried a lot of cominations.
i have two symbols in the market watch, the ws30m and the @YM.
so i want to calculate the spread:
double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // i'm on the @YM - it's ok i get the ASK
double Ask2 = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // here i want to go with the WS30M
how to change the _Symbol or Symbol() with the WS30m - i tried so many combinations
difference = Ask - Ask2 ;