выложу индюк
тестите марти с 3 колена
#KIKOS#
# WilliamsPersentR 5 PC HO
#26.09.2015
declare upper;
################# PC ##########
input displace = 0;
input length = 20;
def LowerBand = Lowest(low[-displace + 1], length);
def UpperBand = Highest(high[-displace + 1], length);
def upPC = if close < LowerBand and close[1] > LowerBand[1]
then 1 else 0;
def downPC = if close > UpperBand and close[1] < UpperBand[1]
then 1 else 0;
############### WilliamsPersentR 3 ############
input length1 = 55;
input length2 = 25;
input length3 = 35;
input overBought = -5;
input overSold = -95;
def Over_Sold = overSold;
def Over_Bought = overBought;
############ 1 ################
input mode1 = {default Predictive, Conventional};
def hh1 = Highest(high, length1);
def ll1 = Lowest(low, length1);
def result1 = if hh1 == ll1 then -100 else (hh1 - close) / (hh1 - ll1) * (-100);
def WR1 = if result1 > 0 then 0 else result1;
def Buy1;
def Sell1;
switch (mode1) {
case Predictive:
Buy1 = if WR1 < overSold and WR1[1] > overSold then 1 else 0;
Sell1 = if WR1 > overBought and WR1[1] < overBought then 1 else 0;
case Conventional:
Buy1 = if WR1 > overSold and WR1[1] < overSold then 1 else 0;
Sell1 = if WR1 < overBought and WR1[1] > overBought then 1 else 0;
}
############ 2 ################
input mode2 = {default Predictive, Conventional};
def hh2 = Highest(high, length2);
def ll2 = Lowest(low, length2);
def result2 = if hh2 == ll2 then -100 else (hh2 - close) / (hh2 - ll2) * (-100);
def WR2 = if result2 > 0 then 0 else result2;
def Buy2;
def Sell2;
switch (mode2) {
case Predictive:
Buy2 = if WR2 < overSold and WR2[1] > overSold then 1 else 0;
Sell2 = if WR2 > overBought and WR2[1] < overBought then 1 else 0;
case Conventional:
Buy2 = if WR2 > overSold and WR2[1] < overSold then 1 else 0;
Sell2 = if WR2 < overBought and WR2[1] > overBought then 1 else 0;
}
############ 3 ################
input mode3 = {default Predictive, Conventional};
def hh3 = Highest(high, length3);
def ll3 = Lowest(low, length3);
def result3 = if hh3 == ll3 then -100 else (hh3 - close) / (hh3 - ll3) * (-100);
def WR3 = if result3 > 0 then 0 else result3;
def Buy3;
def Sell3;
switch (mode3) {
case Predictive:
Buy3 = if WR3 < overSold and WR3[1] > overSold then 1 else 0;
Sell3 = if WR3 > overBought and WR3[1] < overBought then 1 else 0;
case Conventional:
Buy3 = if WR3 > overSold and WR3[1] < overSold then 1 else 0;
Sell3 = if WR3 < overBought and WR3[1] > overBought then 1 else 0;
}
################# HO ##############
def price3 = hl2;
def lengthH = 10;
def OuterValue = 0.04;
def displacement = 0;
def dPrice = price3[displacement];
rec CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(lengthH)) else CMA[1] + (CMA[1] - CMA[2]);
#Rev 2: July 29, 2012: improved FlowPrice for better extremes
#def OscValue = if close > close[1] then high else if close < close[1] then low else (high + low)/2;
def OscValue =
if high >= high[1] and low <= low[1]
then
if close >= close[1] # high >= high[2]
then high
else low
else
if high > high[1]
then high
else
if low < low[1]
then low
else
if close > close[1]
then high
else
if close < close[1]
then low
else (high + low) / 2;
def HurstOsc = (100 * OscValue / CMA) - 100;
def CenterLine = 0;
def UpperOuterBand = OuterValue;
def LowerOuterBand = - OuterValue;
def upH = HurstOsc < - OuterValue;
def downH = HurstOsc > OuterValue;
###### plot ############
plot up = if Buy1 and Buy2 and Buy3 and upH
and upPC then 1 else 0;
plot down = if Sell1 and Sell2 and Sell3 and downH
and downPC then 1 else 0;
up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
up.SetLineWeight(5);
up.SetDefaultColor(Color.WHITE);
Alert (up, "UP", Alert.BAR, Sound.Ring);
down.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
down.SetLineWeight(5);
down.SetDefaultColor(Color.WHITE);
Alert(down, "DOWN", Alert.BAR, Sound.Ring);
AddLabel(down, "Profit$", Color.RED);
AddLabel(up, "profit$", Color.GREEN);
Вот другая вариация его!
#KIKOS#
# WilliamsPersentR 5 PC HO
#26.09.2015
declare upper;
################# PC ##########
input displace = 0;
input length = 20;
def LowerBand = Lowest(low[-displace + 1], length);
def UpperBand = Highest(high[-displace + 1], length);
def upPC = if close < LowerBand and close[1] > LowerBand[1]
then 1 else 0;
def downPC = if close > UpperBand and close[1] < UpperBand[1]
then 1 else 0;
############### WilliamsPersentR 3 ############
input length1 = 55;
input length2 = 25;
input length3 = 35;
input overBought = -5;
input overSold = -95;
def Over_Sold = overSold;
def Over_Bought = overBought;
############ 1 ################
input mode1 = {default Predictive, Conventional};
def hh1 = Highest(high, length1);
def ll1 = Lowest(low, length1);
def result1 = if hh1 == ll1 then -100 else (hh1 - close) / (hh1 - ll1) * (-100);
def WR1 = if result1 > 0 then 0 else result1;
def Buy1;
def Sell1;
switch (mode1) {
case Predictive:
Buy1 = if WR1 < overSold and WR1[1] > overSold then 1 else 0;
Sell1 = if WR1 > overBought and WR1[1] < overBought then 1 else 0;
case Conventional:
Buy1 = if WR1 > overSold and WR1[1] < overSold then 1 else 0;
Sell1 = if WR1 < overBought and WR1[1] > overBought then 1 else 0;
}
############ 2 ################
input mode2 = {default Predictive, Conventional};
def hh2 = Highest(high, length2);
def ll2 = Lowest(low, length2);
def result2 = if hh2 == ll2 then -100 else (hh2 - close) / (hh2 - ll2) * (-100);
def WR2 = if result2 > 0 then 0 else result2;
def Buy2;
def Sell2;
switch (mode2) {
case Predictive:
Buy2 = if WR2 < overSold and WR2[1] > overSold then 1 else 0;
Sell2 = if WR2 > overBought and WR2[1] < overBought then 1 else 0;
case Conventional:
Buy2 = if WR2 > overSold and WR2[1] < overSold then 1 else 0;
Sell2 = if WR2 < overBought and WR2[1] > overBought then 1 else 0;
}
############ 3 ################
input mode3 = {default Predictive, Conventional};
def hh3 = Highest(high, length3);
def ll3 = Lowest(low, length3);
def result3 = if hh3 == ll3 then -100 else (hh3 - close) / (hh3 - ll3) * (-100);
def WR3 = if result3 > 0 then 0 else result3;
def Buy3;
def Sell3;
switch (mode3) {
case Predictive:
Buy3 = if WR3 < overSold and WR3[1] > overSold then 1 else 0;
Sell3 = if WR3 > overBought and WR3[1] < overBought then 1 else 0;
case Conventional:
Buy3 = if WR3 > overSold and WR3[1] < overSold then 1 else 0;
Sell3 = if WR3 < overBought and WR3[1] > overBought then 1 else 0;
}
########### HO ##############
input priceH = hl2;
input lengthH = 10;
input OuterValue = 0.04;
def displacement = (-lengthH / 2) + 1;
def dPrice = priceH[displacement];
#add extrapolation
def MA=Average(PriceH, AbsValue(lengthH));
input paint=no;
def CMA;
if paint then {
CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(lengthH)) else CMA[1] + (CMA[1] - CMA[2]);
} else {
CMA=MA+(MA-MA[1])*max(0,floor(lengthH/2-1));
}
##
def OscValue =
if high >= high[1] and low <= low[1]
then
if close >= close[1] # high >= high[2]
then high
else low
else
if high > high[1]
then high
else
if low < low[1]
then low
else
if close > close[1]
then high
else
if close < close[1]
then low
else (high + low) / 2;
def HurstOsc = (100 * OscValue / CMA) - 100;
def CenterLine = 0;
def UpperOuterBand = OuterValue;
def LowerOuterBand = - OuterValue;
def upH = HurstOsc < - OuterValue;
def downH = HurstOsc > OuterValue;
###### plot ############
plot up = if Buy1 and Buy2 and Buy3 and upH
and upPC then 1 else 0;
plot down = if Sell1 and Sell2 and Sell3 and downH
and downPC then 1 else 0;
up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
up.SetLineWeight(5);
up.SetDefaultColor(Color.WHITE);
Alert (up, "UP", Alert.BAR, Sound.Ring);
down.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
down.SetLineWeight(5);
down.SetDefaultColor(Color.WHITE);
Alert(down, "DOWN", Alert.BAR, Sound.Ring);
AddLabel(down, "Profit$", Color.RED);
AddLabel(up, "profit$", Color.GREEN);