Kaufman Stress Indicator

Stress Indicator, first proposed by Mr. Perry Kaufman, provides an easy way for trading pairs / arbs.

Kaufman's trading rules for Stress Indicator:
- Decide on a pair to trade: For ex., AAPL             v QQQ            
- Calculate the Stress Indicator (SI) for that pair
- Buy the stock when SI 50
- Calculate the 60-day moving average of QQQ            
- If the trend of QQQ             is down, hedge the stock position with QQQ             equal to the risk of the stock using the 20-day ATR of each
- Exit the hedge when the stock position exits, or exit the hedge when the trend of QQQ             turns up
- Do not trade stocks under $3

Explanation of all potential SI applications is beyond this post. For more info:
- TASC 2014 March issue.

Though Kaufman's Stress stategy is built on top of this Stress Indicator, I suggest reading up his full strategy guidelines before applying this.

Kaufman suggests using 60SMA on the index to track the slope. I have included a custom SMA (find it in the middle pane) that can show SMA for any selected symbol. Use the guide below to import that in to your charts:
Remove from Favorite Scripts Add to Favorite Scripts
// @author LazyBear
// If you use this code in its orignal/modified form, do drop me a note. 
study("Kaufman Stress Indicator [LazyBear]", shorttitle="KSI_LB")
oblvl=input(90,title="Overbought Level")
oslvl=input(10,title="Oversold Level")
normlvl=input(50,title="Normal Level")
d2sym=input("SPY", type=symbol)	

calc_range(hi, lo, len) => 
    highest( hi, len ) - lowest( lo, len ) 

d2low=security(d2sym, period, low)
d2high=security(d2sym, period, high)
d2close=security(d2sym, period, close)
r1 = calc_range(high, low, length) 
r2 = calc_range(d2high, d2low, length) 
s1 = (r1 != 0 and r2 != 0) ? ( close - lowest( low, length ) ) / r1 : 50
s2 = (r1 != 0 and r2 != 0) ? ( d2close - lowest( d2low, length ) ) / r2 : 50
d = s1 - s2
r11 = calc_range(d, d, length) 
sv = r11 != 0 ? 100 * ( d - lowest( d, length ) ) / r11 : 50

plot( sv, title="Stress", color=red, linewidth=2 ) 
plot( s1 * 100, title="D1 Stoch", color=green ) 
plot( s2 * 100, title="D2 Stoch", color=blue ) 
plot( oblvl, title="OverBought", style=3, color=red ) 
plot( oslvl, title="OverSold", color=green, style=3 ) 
plot( normlvl, title="Normal", color=gray, style=3 ) 
Ideas Scripts Chart
United States
United Kingdom
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out