viktor8821
Местный
- Регистрация
- 12.12.14
- Сообщения
- 255
- Реакции
- 94
viktor8821 не предоставил никакой дополнительной информации.
Просьба потестить покрутить свои настройки и сказать свое мнение может кто потскажет свой фильтр индюк написал kikos по прозьбе.
сам индюк
сам индюк
#KIKOS
#DYMI MQ PC HO CCI
#10.09.2015
input price = close;
input stdevLength = 5;
input avgOfStdevLength = 23;
input DYMILength = 11;
input DYMILengthLowerLimit = 3;
input DYMILengthUpperLimit = 60;
input Over_Bought = 90;
input Over_sold = 10;
Assert(DYMILengthLowerLimit > 0, "'dymi length lower limit' must be positive: " + DYMILengthLowerLimit);
Assert(DYMILength between DYMILengthLowerLimit and DYMILengthUpperLimit, "'dymi length' must be between lower and upper limit: " + DYMILength);
def std = StDev(price, stdevLength);
def ratio = std / Average(std, avgOfStdevLength);
def dynamicLength = Floor(DYMILength / ratio);
def limitedLength = if dynamicLength between DYMILengthLowerLimit and DYMILengthUpperLimit then dynamicLength else 0;
def sf = 2 / (limitedLength + 1);
def bn = Max(BarNumber(), 0);
# 10^-5 precision for ema multiplier
def expIndex = if limitedLength == 0 then 1 else Max(1, bn - Ceil(-5 / Lg(1 - sf)));
def fromIndex = if IsNaN(expIndex) then 1 else expIndex;
def chg = price - price[1];
def absChg = AbsValue(chg);
def netChgAvg = fold indexN = fromIndex to bn + 1 with accuN do sf * (if IsNaN(GetValue(chg, bn - indexN)) then 0 else GetValue(chg, bn - indexN)) + (1 - sf) * accuN;
def totChgAvg = fold indexT = fromIndex to bn + 1 with accuT do sf * (if IsNaN(GetValue(absChg, bn - indexT)) then 0 else GetValue(absChg, bn - indexT)) + (1 - sf) * accuT;
def RSI = if totChgAvg != 0 and limitedLength != 0 then 50 * (netChgAvg / totChgAvg + 1) else RSI[1];
def DYMI = RSI;
def OverBought = Over_Bought;
def OverSold = Over_sold;
def centr1 = 50;
def centr2 = 50;
#####################################################################
input NumBars = 5;
input scalingMultiplier = 0.2;
input valueLevel = 6.0;
def VarNumBars = if NumBars < 5 then 5 else if NumBars > 1000 then 1000 else NumBars;
def VarP = Round(VarNumBars / 5.0, 0);
def TLow = if close < low[1] then close else low[1];
def THigh = if close > high[1] then close else high[1];
def VarA = if VarP == 1 then THigh - TLow else Highest(high, VarP) - Lowest(low, VarP);
def VarTotal = if VarP == 1 then Sum(VarA, VarNumBars) else Sum(VarA, VarNumBars);
def VarCount = VarNumBars;
def LRange = (VarTotal / VarCount) * scalingMultiplier;
def VLup = Average(hl2, VarNumBars) + ((LRange) * valueLevel);
def VLdown = Average(hl2, VarNumBars) - ((LRange) * valueLevel);
#####################################################################
def UpD = if DYMI crosses below OverSold and price < VLdown then 1 else 0;
def DownD = if DYMI crosses above OverBought and price > VLup then 1 else 0;
################ PC #############
input displace = 0;
input length = 20;
def LowerBand = Lowest(low[-displace + 1], length);
def UpperBand = Highest(high[-displace + 1], length);
def upP = if close < LowerBand and close[1] > LowerBand[1] then 1 else 0;
def downP = if close > UpperBand and close[1] < UpperBand[1] then 1 else 0;
########### HO ##############
input priceH = hl2;
input lengthH = 10;
input OuterValue = 0.03;
def displacement = (-lengthH / 2) + 1;
def dPrice = priceH[displacement];
rec CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(lengthH)) else CMA[1] + (CMA[1] - CMA[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;
########## CCI ###########
input lengthC = 14;
input over_soldC = -200;
input over_boughtC = 200;
def priceC = close + low + high;
def linDev = LinDev(priceC, lengthC);
def CCI = if linDev == 0 then 0 else (priceC - Average(priceC, lengthC)) / linDev / 0.015;
def OverBoughtC = over_boughtC;
def ZeroLine = 0;
def OverSoldC = over_soldC;
def upc = if CCI < OverSoldC then 1 else 0;
def downc = if CCI > OverBoughtC then 1 else 0;
########### PLOT ARROW ############
plot up = if upD and upP and upH and upC then 1 else 0;
plot down = if downD and downP and downH and downC 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, "$", Color.RED);
AddLabel(up, "$", Color.GREEN);
### END ############
##########---------------------------TEST OPTIONS---------------------------------------------
#hint timetest: Test according to timeperiods
#hint expiry: Numbers of candles after signal (1 = next candle after signal, 2 = second candle)
#hint secondcandle: Use only if candleexpiry = 1. Adding signals taking second candle after loss
#hint moneycount: display labels with profit/loss in $
#hint invest: amount of investment per trade
#hint RPI: Return Per Investment (payout)
input expiry = 1;
input secondcandle = no;
input moneycount = no;
input invest = 25;
input RPI = 0.80;
input timetest = no;
########-------------------------------------------TIME FILTER-----------------------------------------------
#hint TradingOpen1: EST NY TIME
input TradingOpen1 = 330;
input TradingClose1 = 530;
input TradingOpen2 = 0930;
input TradingClose2 = 1130;
#hint input AsiaOpenTime1 = 2000;
#hint input AsiaCloseTime1 = 2359;
#hint input AsiaOpenTime2 = 0000;
#hint input AsiaCloseTime2 = 0200;
#hint input EUOpenTime = 330;
#hint input EUCloseTime = 530;
#hint input USOpenTime = 0930;
#hint input USCloseTime = 1130;
# Set below to 'True' to allow for DST difference adjustment if you are setting
# windows up for a european instrument like the euro.
input EnableDSTAutoAdjust = {default "Yes", "No"};
input DSTOffsetHours = 1;
#==========================================================================
# Figure out DST adjustment for diffence between USA and europe
#==========================================================================
#basically, if we are after the 2nd Sunday in March and before
#the last Sunday in March, we need to offset the Trading Windows by 1hr forward
#if we are after the last Sunday in Oct, until the 1st Sunday in Nov
# we need to offset the trading windows by 1hr backward...
def CurrentYear = GetYear();
def CurrentMonth = GetMonth();
def CurrentDOM = GetDayOfMonth(GetYYYYMMDD());
#What is the first day of the week for the 1st of this month?
def Day1DOW1 = GetDayOfWeek(CurrentYear * 10000 + CurrentMonth * 100 + 1);
def FirstSundayDOM1 = if Day1DOW1 < 7
then 7 - Day1DOW1 + 1
else 1;
def SecondSundayOfMonth = FirstSundayDOM1 + 7;
def isMarch = If (CurrentMonth == 3, 1, 0);
def SpringDSTShiftStart = If (isMarch and (SecondSundayOfMonth <= CurrentDOM), 1, 0);
#last sunday in march...
def SpringDSTShiftStop = If (isMarch and ((SecondSundayOfMonth + 14) > CurrentDOM), 1, 0);
def DoSpringShift = If (SpringDSTShiftStart and SpringDSTShiftStop and EnableDSTAutoAdjust, 1, 0);
def isOctober = If (CurrentMonth == 10, 1, 0);
def isNovember = If (CurrentMonth == 11, 1, 0);
def FallDSTShiftStart = If (isOctober and ((SecondSundayOfMonth + 14) <= CurrentDOM), 1, 0);
def FallDSTShiftStop = If (isNovember and FirstSundayDOM1 > CurrentDOM, 1, 0);
def DoFallShift = If (FallDSTShiftStart or FallDSTShiftStop and EnableDSTAutoAdjust, 1, 0);
def isToday = If(GetDay() == GetLastDay(), 1, 0);
#PITA. SecondsTillTime only takes constants... Need to manually adjust for DST if it's enabled.
def DSTAdjust = If (DoSpringShift, DSTOffsetHours * 3600, If (DoFallShift, -DSTOffsetHours * 3600, 0));
def TradingOpenTime1 = If((SecondsTillTime(TradingOpen1) + DSTAdjust > 0), 0, 1);
def TradingCloseTime1 = If((SecondsTillTime(TradingClose1) + DSTAdjust > 0), 0, 1);
def TradingWindow1 = If(TradingOpenTime1 and !TradingCloseTime1, 1, 0);
def TradingOpenTime2 = If((SecondsTillTime(TradingOpen2) + DSTAdjust > 0), 0, 1);
def TradingCloseTime2 = If((SecondsTillTime(TradingClose2) + DSTAdjust > 0), 0, 1);
def TradingWindow2 = If(TradingOpenTime2 and !TradingCloseTime2, 1, 0);
AddVerticalLine(TradingWindow1 and TradingWindow1[1] == 0 and timetest, "TradingOpen 1" , Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(TradingWindow1 == 0 and TradingWindow1[1] and timetest, "TradingClose 1" , Color.RED, Curve.SHORT_DASH);
AddVerticalLine(TradingWindow2 and TradingWindow2[1] == 0 and timetest, "TradingOpen 2" , Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(TradingWindow2 == 0 and TradingWindow2[1] and timetest, "TradingClose 2" , Color.RED, Curve.SHORT_DASH);
#####-------------------------------------TESTER-----------------------------------------------------
def ITM1 = if timetest and TradingWindow1 == 0 and TradingWindow2 == 0 then 0 else if (Up[expiry] and close[0] > close[expiry]) or (Down[expiry] and close[0] < close[expiry]) or (secondcandle and Up[2] and close[1] < close[2] and close > close[1]) or (secondcandle and Down[2] and close[1] > close[2] and close < close[1]) then 1 else 0;
def itm = if IsNaN(ITM1) then 0 else ITM1;
def itmsum = TotalSum(itm);
def OTM1 = if timetest and TradingWindow1 == 0 and TradingWindow2 == 0 then 0 else if (Up[expiry] and close[0] < close[expiry]) or (Down[expiry] and close[0] > close[expiry]) or (secondcandle and Up[2] and close[1] < close[2] and close < close[1]) or (secondcandle and Down[2] and close[1] > close[2] and close > close[1]) then 1 else 0;
def otm = if IsNaN(OTM1) then 0 else OTM1;
def otmsum = TotalSum(otm);
def itmrate = RoundUp((itmsum / (itmsum + otmsum) * 100), 2);
def label = 1;
AddLabel(label, Concat("ITM = ", itmsum), Color.GREEN);
AddLabel(label, Concat("OTM = ", otmsum), Color.RED);
AddLabel(label, Concat("ITM RATE = %", itmrate), Color.WHITE);
#####---------Moneycount--------------------------------------------
def PL = invest * itmsum * RPI - invest * otmsum;
def PLColor = if PL > 0 then 6 else 5;
AddLabel(moneycount, Concat("PROFIT/LOSS = $", PL), GetColor(PLColor));
#DYMI MQ PC HO CCI
#10.09.2015
input price = close;
input stdevLength = 5;
input avgOfStdevLength = 23;
input DYMILength = 11;
input DYMILengthLowerLimit = 3;
input DYMILengthUpperLimit = 60;
input Over_Bought = 90;
input Over_sold = 10;
Assert(DYMILengthLowerLimit > 0, "'dymi length lower limit' must be positive: " + DYMILengthLowerLimit);
Assert(DYMILength between DYMILengthLowerLimit and DYMILengthUpperLimit, "'dymi length' must be between lower and upper limit: " + DYMILength);
def std = StDev(price, stdevLength);
def ratio = std / Average(std, avgOfStdevLength);
def dynamicLength = Floor(DYMILength / ratio);
def limitedLength = if dynamicLength between DYMILengthLowerLimit and DYMILengthUpperLimit then dynamicLength else 0;
def sf = 2 / (limitedLength + 1);
def bn = Max(BarNumber(), 0);
# 10^-5 precision for ema multiplier
def expIndex = if limitedLength == 0 then 1 else Max(1, bn - Ceil(-5 / Lg(1 - sf)));
def fromIndex = if IsNaN(expIndex) then 1 else expIndex;
def chg = price - price[1];
def absChg = AbsValue(chg);
def netChgAvg = fold indexN = fromIndex to bn + 1 with accuN do sf * (if IsNaN(GetValue(chg, bn - indexN)) then 0 else GetValue(chg, bn - indexN)) + (1 - sf) * accuN;
def totChgAvg = fold indexT = fromIndex to bn + 1 with accuT do sf * (if IsNaN(GetValue(absChg, bn - indexT)) then 0 else GetValue(absChg, bn - indexT)) + (1 - sf) * accuT;
def RSI = if totChgAvg != 0 and limitedLength != 0 then 50 * (netChgAvg / totChgAvg + 1) else RSI[1];
def DYMI = RSI;
def OverBought = Over_Bought;
def OverSold = Over_sold;
def centr1 = 50;
def centr2 = 50;
#####################################################################
input NumBars = 5;
input scalingMultiplier = 0.2;
input valueLevel = 6.0;
def VarNumBars = if NumBars < 5 then 5 else if NumBars > 1000 then 1000 else NumBars;
def VarP = Round(VarNumBars / 5.0, 0);
def TLow = if close < low[1] then close else low[1];
def THigh = if close > high[1] then close else high[1];
def VarA = if VarP == 1 then THigh - TLow else Highest(high, VarP) - Lowest(low, VarP);
def VarTotal = if VarP == 1 then Sum(VarA, VarNumBars) else Sum(VarA, VarNumBars);
def VarCount = VarNumBars;
def LRange = (VarTotal / VarCount) * scalingMultiplier;
def VLup = Average(hl2, VarNumBars) + ((LRange) * valueLevel);
def VLdown = Average(hl2, VarNumBars) - ((LRange) * valueLevel);
#####################################################################
def UpD = if DYMI crosses below OverSold and price < VLdown then 1 else 0;
def DownD = if DYMI crosses above OverBought and price > VLup then 1 else 0;
################ PC #############
input displace = 0;
input length = 20;
def LowerBand = Lowest(low[-displace + 1], length);
def UpperBand = Highest(high[-displace + 1], length);
def upP = if close < LowerBand and close[1] > LowerBand[1] then 1 else 0;
def downP = if close > UpperBand and close[1] < UpperBand[1] then 1 else 0;
########### HO ##############
input priceH = hl2;
input lengthH = 10;
input OuterValue = 0.03;
def displacement = (-lengthH / 2) + 1;
def dPrice = priceH[displacement];
rec CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(lengthH)) else CMA[1] + (CMA[1] - CMA[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;
########## CCI ###########
input lengthC = 14;
input over_soldC = -200;
input over_boughtC = 200;
def priceC = close + low + high;
def linDev = LinDev(priceC, lengthC);
def CCI = if linDev == 0 then 0 else (priceC - Average(priceC, lengthC)) / linDev / 0.015;
def OverBoughtC = over_boughtC;
def ZeroLine = 0;
def OverSoldC = over_soldC;
def upc = if CCI < OverSoldC then 1 else 0;
def downc = if CCI > OverBoughtC then 1 else 0;
########### PLOT ARROW ############
plot up = if upD and upP and upH and upC then 1 else 0;
plot down = if downD and downP and downH and downC 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, "$", Color.RED);
AddLabel(up, "$", Color.GREEN);
### END ############
##########---------------------------TEST OPTIONS---------------------------------------------
#hint timetest: Test according to timeperiods
#hint expiry: Numbers of candles after signal (1 = next candle after signal, 2 = second candle)
#hint secondcandle: Use only if candleexpiry = 1. Adding signals taking second candle after loss
#hint moneycount: display labels with profit/loss in $
#hint invest: amount of investment per trade
#hint RPI: Return Per Investment (payout)
input expiry = 1;
input secondcandle = no;
input moneycount = no;
input invest = 25;
input RPI = 0.80;
input timetest = no;
########-------------------------------------------TIME FILTER-----------------------------------------------
#hint TradingOpen1: EST NY TIME
input TradingOpen1 = 330;
input TradingClose1 = 530;
input TradingOpen2 = 0930;
input TradingClose2 = 1130;
#hint input AsiaOpenTime1 = 2000;
#hint input AsiaCloseTime1 = 2359;
#hint input AsiaOpenTime2 = 0000;
#hint input AsiaCloseTime2 = 0200;
#hint input EUOpenTime = 330;
#hint input EUCloseTime = 530;
#hint input USOpenTime = 0930;
#hint input USCloseTime = 1130;
# Set below to 'True' to allow for DST difference adjustment if you are setting
# windows up for a european instrument like the euro.
input EnableDSTAutoAdjust = {default "Yes", "No"};
input DSTOffsetHours = 1;
#==========================================================================
# Figure out DST adjustment for diffence between USA and europe
#==========================================================================
#basically, if we are after the 2nd Sunday in March and before
#the last Sunday in March, we need to offset the Trading Windows by 1hr forward
#if we are after the last Sunday in Oct, until the 1st Sunday in Nov
# we need to offset the trading windows by 1hr backward...
def CurrentYear = GetYear();
def CurrentMonth = GetMonth();
def CurrentDOM = GetDayOfMonth(GetYYYYMMDD());
#What is the first day of the week for the 1st of this month?
def Day1DOW1 = GetDayOfWeek(CurrentYear * 10000 + CurrentMonth * 100 + 1);
def FirstSundayDOM1 = if Day1DOW1 < 7
then 7 - Day1DOW1 + 1
else 1;
def SecondSundayOfMonth = FirstSundayDOM1 + 7;
def isMarch = If (CurrentMonth == 3, 1, 0);
def SpringDSTShiftStart = If (isMarch and (SecondSundayOfMonth <= CurrentDOM), 1, 0);
#last sunday in march...
def SpringDSTShiftStop = If (isMarch and ((SecondSundayOfMonth + 14) > CurrentDOM), 1, 0);
def DoSpringShift = If (SpringDSTShiftStart and SpringDSTShiftStop and EnableDSTAutoAdjust, 1, 0);
def isOctober = If (CurrentMonth == 10, 1, 0);
def isNovember = If (CurrentMonth == 11, 1, 0);
def FallDSTShiftStart = If (isOctober and ((SecondSundayOfMonth + 14) <= CurrentDOM), 1, 0);
def FallDSTShiftStop = If (isNovember and FirstSundayDOM1 > CurrentDOM, 1, 0);
def DoFallShift = If (FallDSTShiftStart or FallDSTShiftStop and EnableDSTAutoAdjust, 1, 0);
def isToday = If(GetDay() == GetLastDay(), 1, 0);
#PITA. SecondsTillTime only takes constants... Need to manually adjust for DST if it's enabled.
def DSTAdjust = If (DoSpringShift, DSTOffsetHours * 3600, If (DoFallShift, -DSTOffsetHours * 3600, 0));
def TradingOpenTime1 = If((SecondsTillTime(TradingOpen1) + DSTAdjust > 0), 0, 1);
def TradingCloseTime1 = If((SecondsTillTime(TradingClose1) + DSTAdjust > 0), 0, 1);
def TradingWindow1 = If(TradingOpenTime1 and !TradingCloseTime1, 1, 0);
def TradingOpenTime2 = If((SecondsTillTime(TradingOpen2) + DSTAdjust > 0), 0, 1);
def TradingCloseTime2 = If((SecondsTillTime(TradingClose2) + DSTAdjust > 0), 0, 1);
def TradingWindow2 = If(TradingOpenTime2 and !TradingCloseTime2, 1, 0);
AddVerticalLine(TradingWindow1 and TradingWindow1[1] == 0 and timetest, "TradingOpen 1" , Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(TradingWindow1 == 0 and TradingWindow1[1] and timetest, "TradingClose 1" , Color.RED, Curve.SHORT_DASH);
AddVerticalLine(TradingWindow2 and TradingWindow2[1] == 0 and timetest, "TradingOpen 2" , Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(TradingWindow2 == 0 and TradingWindow2[1] and timetest, "TradingClose 2" , Color.RED, Curve.SHORT_DASH);
#####-------------------------------------TESTER-----------------------------------------------------
def ITM1 = if timetest and TradingWindow1 == 0 and TradingWindow2 == 0 then 0 else if (Up[expiry] and close[0] > close[expiry]) or (Down[expiry] and close[0] < close[expiry]) or (secondcandle and Up[2] and close[1] < close[2] and close > close[1]) or (secondcandle and Down[2] and close[1] > close[2] and close < close[1]) then 1 else 0;
def itm = if IsNaN(ITM1) then 0 else ITM1;
def itmsum = TotalSum(itm);
def OTM1 = if timetest and TradingWindow1 == 0 and TradingWindow2 == 0 then 0 else if (Up[expiry] and close[0] < close[expiry]) or (Down[expiry] and close[0] > close[expiry]) or (secondcandle and Up[2] and close[1] < close[2] and close < close[1]) or (secondcandle and Down[2] and close[1] > close[2] and close > close[1]) then 1 else 0;
def otm = if IsNaN(OTM1) then 0 else OTM1;
def otmsum = TotalSum(otm);
def itmrate = RoundUp((itmsum / (itmsum + otmsum) * 100), 2);
def label = 1;
AddLabel(label, Concat("ITM = ", itmsum), Color.GREEN);
AddLabel(label, Concat("OTM = ", otmsum), Color.RED);
AddLabel(label, Concat("ITM RATE = %", itmrate), Color.WHITE);
#####---------Moneycount--------------------------------------------
def PL = invest * itmsum * RPI - invest * otmsum;
def PLColor = if PL > 0 then 6 else 5;
AddLabel(moneycount, Concat("PROFIT/LOSS = $", PL), GetColor(PLColor));
Вложения
Последнее редактирование модератором: