Pairs: Pair Arrows Double

input Mean_Dist_Pos = .7;
input Mean_Dist_Neg = -.7;
input SMA_len = 10;
input R = 40;

def price = ((open(getSymbolPart(1)) + close(getSymbolPart(1))) / 2) - ((open(getSymbolPart(2)) + close(getSymbolPart(2))) / 2);
def SMAOC = Average(price, SMA_len);
def DistFromSMAOCave = price - SMAOC;

plot ArrowDn = Mean_Dist_Pos < DistFromSMAOCave and correlation(close(getSymbolPart(1)), close(getSymbolPart(2)),R) > Mean_Dist_Pos;

plot ArrowUp = Mean_Dist_Neg > DistFromSMAOCave and correlation(close(getSymbolPart(1)), close(getSymbolPart(2)),R) > Mean_Dist_Pos;

#  and correlation(((open(getSymbolPart(1)) + close(getSymbolPart(1))) / 2) , ((open(getSymbolPart(2)) + close(getSymbolPart(2))) / 2)) > Mean_Dist_Pos;

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

Pairs: Distance From Mean OCave

declare lower;
input Mean_Dist_Pos = .7;
input Mean_Dist_Neg = -.7;
input SMA_len = 10;
input Std_Dev_Len = 20;

def Length = 1;
def price = ((Open(getSymbolPart(1))+Close(getSymbolPart(1)))/2)-((Open(getSymbolPart(2))+Close(getSymbolPart(2)))/2);
def SMAOC = Average(price, SMA_len);

plot DistFromSMAOCave = price - SMAOC;
DistFromSMAOCave.SetDefaultColor(GetColor(6));

plot sigma = stdev(price, Std_Dev_Len);
sigma.SetDefaultColor(GetColor(8));

Plot zeroline = 0;
ZeroLine.SetDefaultColor(GetColor(1));

Pairs: Distance From Mean OCave Single Ticker

declare lower;
input Pair = "AU";
input SMA_len = 10;
input Std_Dev_Len = 20;

def Length = 1;
def price = ((Open+Close)/2)-((Open(Pair)+Close(Pair))/2);
def SMAOC = Average(price, SMA_len);

plot DistFromSMAOCave = price - SMAOC;
DistFromSMAOCave.SetDefaultColor(GetColor(6));

plot sigma = stdev(price, Std_Dev_Len);
sigma.SetDefaultColor(GetColor(8));

plot zscore = DistFromSMAOCave/sigma;

Plot zeroline = 0;
ZeroLine.SetDefaultColor(GetColor(1));

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);

Pairs: SMA OCave

#better to exclude tails/shadows and to use the midpoint of the
#body size when finding the usable distance from the mean

def price = ((Close + Open)/2);
input length = 10;
plot SMA = Average(price, length);
SMA.SetDefaultColor(GetColor(1));