Minor spread

To add comments, please log in or register
Jhennifher
1156
Jhennifher  

Hi. I´m developing indicator to define top lowest ranking of minor distance between ask and bid lines.

The current version of indicator reads column ! and, based on increasing order, defines the ranking.

In the example following, the increase order is:

1) Eurusd = 37

2) UsaTecJun19 = 125

3) Nzdcad = 269

4) UsaTBJun19 = 9375


This results considers: 37<125<269<9375.



But, the order that I wish is not the ranking for top lowest spread. I wish the ranking for minor distance between ask and bid lines. Take a look on previous image and realize that the ranking I wish would be like this:

1) UsaTecJun19 = 125

2) Eurusd = 37

3) UsaTBJun19 = 9375

4) Nzdcad = 269


This is the result I wish. As you can see, this is not a increase order of spread. It is the minor distance between lines red and blue.

I need some help to find a way to find this minor distance between lines ask and bid considering many different instruments that have many different number of digits.


Thanks for your attention.

lippmaje
601
lippmaje  

An approach to get such an order would be to weight the spread by its price. So that for each symbol you compare the spreads in percent points of the price.

double spread=Ask-Bid;
double spreadRelativeToPrice=spread/Bid;
double spreadInPercent=spreadRelativeToPrice*100.0;

Then, some instruments have a high volatility while others remain flat oftentimes. A spread simply expressed in price percentage wouldn't reflect that.

To consider this I'd take the daily range into account:

double atr=iATR(_Symbol,PERIOD_D1,20,1); // 20-day ATR of last day
double spread=Ask-Bid;
double spreadRelativeToATR=spread/atr;
double spreadInPercentATR=spreadRelativeToATR*100.0;

Edit: Note this is independent of the number of digits or points which makes things somewhat easier to read.

Your ordering would then be based on either comparing spread relative to price, relative to ATR, or even both if you multiply these values.

Jhennifher
1156
Jhennifher  
lippmaje:

An approach to get such an order would be to weight the spread by its price. So that for each symbol you compare the spreads in percent points of the price.

Then, some instruments have a high volatility while others remain flat oftentimes. A spread simply expressed in price percentage wouldn't reflect that.

To consider this I'd take the daily range into account:


tks a lot, I will try this and give you the result.

regards

Jhennifher
1156
Jhennifher  
lippmaje:

An approach to get such an order would be to weight the spread by its price. So that for each symbol you compare the spreads in percent points of the price.

Then, some instruments have a high volatility while others remain flat oftentimes. A spread simply expressed in price percentage wouldn't reflect that.

To consider this I'd take the daily range into account:

Edit: Note this is independent of the number of digits or points which makes things somewhat easier to read.

Your ordering would then be based on either comparing spread relative to price, relative to ATR, or even both if you multiply these values.

It seems a good results, tks
lippmaje
601
lippmaje  
Jhennifher:
It seems a good results, tks
Thanks, great to know it helped.
To add comments, please log in or register