How to Determine tight Spread in Code?

 

Hi,

How do I know in code if a symbol has a tight spread or not?

I was thinking say less than 5 points.

I checked

      double rawSpread=MarketInfo(NULL,MODE_SPREAD);


But it is not right to compare it with a size, like 5 points, for example.


See images attached for Bitcoin and SEKJPY.

It returns "3500" for Bitcoin. Its a big number. But when you look at the chart in Image - the Spread is super-TIGHT.  The Bid and Ask lines are so close.

Ironically - it returns only " 63" for SEKJPY. When in the chart in image, the Spread is super-WIDE. See how wide apart the Bid and Ask lines are.


So, how can I determines if a Symbol has a "tight" spread in the code. Jut like i see it visually?


Thank you.

Files:
bitcoin.PNG  25 kb
sekjpy.PNG  36 kb
 
Maybe you could calculate it as a percentage and see what is acceptable to you.
 
Keith Watford:
Maybe you could calculate it as a percentage and see what is acceptable to you.
Right. That’s what I am thinking too.

But see the problem with percentage -

Spread/ Price


Assume two symbols with same tight width spread of 1 or 2 points. But one instrument costs twice the other.

This percentage will show one as tight and other as wide. When both have very tight spread. 
 
Try keeping track of the spread and feed that data into a bollinger (iBandsOnArray) command. When the spread is greater and less than the upper and lower bollinger bands don't trade.
 
JForex:
Right. That’s what I am thinking too.

But see the problem with percentage -

Spread/ Price


Assume two symbols with same tight width spread of 1 or 2 points. But one instrument costs twice the other.

This percentage will show one as tight and other as wide. When both have very tight spread. 

When you are calculating the spread as a percentage points don't figure in the equation.

Spread is Ask minus Bid.

Take Gold

Broker A quotes Gold to 2 Digits with a spread of 50 points

Broker B quotes Gold to 3 Digits with a spread of 300 points

Which has the tighter spread?

 
Keith Watford:

When you are calculating the spread as a percentage points don't figure in the equation.

Spread is Ask minus Bid.

Take Gold

Broker A quotes Gold to 2 Digits with a spread of 50 points

Broker B quotes Gold to 3 Digits with a spread of 300 points

Which has the tighter spread?


Problem is not between Broker A and B.

In your example youre simply adding a another 0 where another broker has an extra point in rate - but thats not the question.


The question is how do I compare one instrument's spread width with another instrument, within the same broker.


How do I know Bitcoins spread is more or less as tight as EURUSD, with some cushion.


MODE_SPREAD returns so much different values - 1 for EURUSD, 3500 for Bitcoin. When both are actually very tight spreads on their own charts.

And returns 63 for an exotic like SEKJPY - when its such a wide spread on the chart.

 

You are missing the point. It doesn't matter whether they are different or the same broker.

Calculate the percentages in your examples.

The spread with Bitcoin is 35 on a bid price of 30985. The spread is approximately 0.113% of the bid.
The spread with SEKJPY is 0.063 on a bid price of 12.426  The spread is approximately 0.507% of the bid.

So SEKJPY spread is nearly 5 times as large as BC spread. A huge difference.

 
Keith Watford:

You are missing the point. It doesn't matter whether they are different or the same broker.

Calculate the percentages in your examples.

The spread with Bitcoin is 35 on a bid price of 30985. The spread is approximately 0.113% of the bid.
The spread with SEKJPY is 0.063 on a bid price of 12.426  The spread is approximately 0.507% of the bid.

So SEKJPY spread is nearly 5 times as large as BC spread. A huge difference.


      Print(Symbol(),":- Spread=",DoubleToStr(rawSpread,digits)," Pts, Price=,",DoubleToStr(Bid,digits)," Ratio=", DoubleToStr(100*rawSpread/Bid,digits),"%");
Output:

USDJPY:- Spread=1.000 Pts, Price=,104.238 Ratio=0.959%
EURUSD:- Spread=2.00000 Pts, Price=,1.20981 Ratio=165.31521%
Bitcoin:- Spread=3500.00 Pts, Price=,31680.52 Ratio=11.05%


See the problem with percentage above.


Both EURUSD & USDJPY have very tight spreads. In this case 1 and 2 points.

But their percentage is 165 times different. When both spreads are very tight. They are not 165 times different in reality.


The problem is youre basing the spread as percentage of its own price. So its useless for the purpose of relative comparison between two separate instruments.

 
JForex:

The problem is youre basing the percentage on price of the instrument. So its useless for the purpose of understanding if its a tight spread.

No, I am basing the percentage on the actual spread as a percentage of price. Points have nothing to do with the calculation.

I give up!

 
Keith Watford:

No, I am basing the percentage on the actual spread as a percentage of price. Points have nothing to do with the calculation.

I give up!

Right. So see the calculations above.

USDJPY %age shows 165 times as of EURUSD.

How does that help me determine, USDJPY spread is pretty tight?

 
JForex:

Right. So see the calculations above.

USDJPY %age shows 165 times as of EURUSD.

How does that help me determine, USDJPY spread is pretty tight?

Common sense should tell you that it is impossible for the spread to be 165% of the bid price.

If an orange has a diameter of 5cm, how many oranges of equal size are there in a kilogram?

Impossible to answer because you cannot calculate using a linear measurement and a weight.

Likewise you can't calculate a percentage of price by using points.

I won't continue with this because you are not taking any notice of my replies and I am wasting my time.