So, I want to use it in an EA like this:
if(bid>last.price+Spread()) .....other statements
If you are able to get the bid price, I suppose you can also get the ask price, right?
So, why don't you define the spread simply as the difference between ask and bid prices?
Something like:
double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK); double bid=SymbolInfoDouble(Symbol(),SYMBOL_BID); double spread=ask-bid;
Hello,
I am confused related how to use Spread. In Docs stated:
...So, I want to use it in an EA like this:
if(bid>last.price+Spread()) .....other statements
But I do not understand who is and how to use index.
Thanks in advance for reply!
Please provide a link when you quote documentation.
About how to get the spread, see https://www.mql5.com/en/forum/17858/page2#comment_731798
![Historical spread during backtesting in the strategy tester is different from the historical spread stored in the Mql rates array. What are they? Why they are different? Historical spread during backtesting in the strategy tester is different from the historical spread stored in the Mql rates array. What are they? Why they are different?](/i/community/logo_mql5_small.png)
- www.mql5.com
Thank you both!
@angevoyageur From now on I'll provide links
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am confused related how to use Spread. In Docs stated:
Spread
Gets the element of the Spread timeseries by index.
double Spread(
int ind // index
)
Parameters
ind
[in] Element index.
Returned value
If successful, it returns the numerical value of the Spread timeseries element with specified index, otherwise it returns EMPTY_VALUE.
Note
The EMPTY_VALUE is returned in two cases:
1.Timeseries is not used (the corresponding bit is not set).
2. Element index is out of range.
So, I want to use it in an EA like this:
if(bid>last.price+Spread()) .....other statements
But I do not understand who is and how to use index.
Thanks in advance for reply!