Pairs: Pair Arrows Single Ticker

# Insert bool arrows from pair study: DistFromMeanOpenCloseAve

input Pair = "AU";
input SMA_len = 10;
input R_len = 40;
input Std_Dev_Len = 20;
input Z_Thresh = 1.5;
input R_Thresh = .7;

def price = ((Open + Close) / 2) - ((open(Pair) + close(Pair)) / 2);
def SMAOC = Average(price, SMA_len);
def DistFromSMAOCave = price - SMAOC;
def sigma = stdev(price, Std_Dev_Len);
def zscore = DistFromSMAOCave/sigma;

plot ArrowDn = zscore > Z_Thresh and correlation(close, close(Pair), R_len) > R_Thresh;
#Mean_Dist < DistFromSMAOCave and correlation(close, close(Pair), R) > Mean_Dist;

plot ArrowUp = zscore < -Z_Thresh and correlation(close, close(Pair), R_len) > R_Thresh;
#-Mean_Dist > DistFromSMAOCave and correlation(close, close(Pair), R) > Mean_Dist;

ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: