TradingView
taylor_o
10 set 2022 22:58

two_leg_spread_returns_zscore 

NY Harbor ULSD Futures (Oct 2022)NYMEX

Descrizione

This script helps assess the relative returns of each leg in a two-legged spread. It shows the z-score of each period's returns, along with a moving average of the difference between the two returns. A negative moving average implies that the second leg is strengthening, on a relative return basis, against the first leg, and vice versa. The inputs are:

- timeframe: the timeframe for the calculations. the default is five minutes.
- leg1_sym: the symbol for the first leg
- leg2_sym: the symbol for the second leg
- ma_length: the length of the moving average. by default it is 48, or the previous four hours, given the default timeframe.

The default symbols are RB and HO, simply as an example of an intercommodity spread.

Note di rilascio

- made lines transparent so they don't block each other
- added 0 line

Note di rilascio

- set background faint pink if returns have different signs

Note di rilascio

- colored background faint blue if leg1 advances while leg 2 declines, and orange if leg 2 advances and leg 1 declines

Note di rilascio

- moving average line is blue if above 0 (leg1 returns strengthening relative to leg 2), orange if below (opposite).
Commenti
NEKSUS_
Thanks for the script. Could you make the leg selection like in TASC 2022.07 Pairs Rotation With Ehlers Loops and add 3 horizontal levels with a value setting?
taylor_o
@NEKSUS_, hey neksus, thanks for the comment. i'm not sure i understand what he's doing in that script. i'll look into it more when i get some time.
FaisalMahboobe3
Thanks for a great indicator. Just a suggestion that would be really nice to have. It would be awesome if we didn't have to input the stocks manually and it would update automatically whenever we change the spread in the "Symbol Search" section.
taylor_o
@FaisalMahboobe3, hey faisal, thanks for the suggestion. unfortunately, i'm not sure how to do that given that spreads can be created a variety of different ways.
Altro