Spread confusion

 

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! 

 
tenlau:

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;
 
tenlau:

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

 

Thank you both!

@angevoyageur From now on I'll provide links 

Reason: