Кто нибуть подскажет как по этому индикатору торговать
название master_option_17
код
declare upper;
input AlertsOn = no;
input MO_length = 25;
input TypeMA = {default EMA, SMA};
input MA_length = 8;
input PC_length = 14;
def price = close;
def UMOBR = Highest(high[-0 + 1], 14);
def LOMOB = Lowest(low[-0 + 1], 14);
def MSMOB = (UMOBR + LOMOB) / 2;
def displacement = (-MO_length / 2) + 1;
def dPrice = hl2[displacement];
rec CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(12)) else CMA[1] + (CMA[1] - CMA[2]);
def ExtremeBand = CMA * 0.004 / 100;
;
def EOMOB = CMA * 0.01 / 100;
def NIMOB = CMA * 0.008 / 100;
def UMGOOB = if !IsNaN(price) then CMA + EOMOB else Double.NaN;
def LMGOOB = if !IsNaN(price) then CMA - EOMOB else Double.NaN;
def sDev = StDev(data = price[-0], length = 20);
def JMMOL = ExpAverage(data = price[-0], length = 20);
def JCMOL = JMMOL + -2.0 * sDev;
def JCMOU = JMMOL + 2.0 * sDev;
plot MOUp = if low <= LMGOOB and price crosses below LOMOB then 1 else 0;
;
MOUp.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_UP);
MOUp.SetDefaultColor(Color.WHITE);
MOUp.SetLineWeight(3);
Alert(AlertsOn && MOUp, "MOMAIN UP", Alert.BAR, Sound.Ding);
MOUp.HideBubble();
MOUp.HideTitle();
plot MODn = if high >= UMGOOB and price crosses above UMOBR then 1 else 0;
;
MODn.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_DOWN);
MODn.SetDefaultColor(Color.WHITE);
MODn.SetLineWeight(3);
Alert(AlertsOn && MODn, "MOMAIN DN", Alert.BAR, Sound.Ding);
MODn.HideBubble();
MODn.HideTitle();
plot MOMUp = if low <= LMGOOB and price crosses below MSMOB then 1 else 0;
;
MOMUp.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_UP);
MOMUp.SetDefaultColor(Color.YELLOW);
MOMUp.SetLineWeight(3);
Alert(AlertsOn && MOMUp, "MOMAIN UP", Alert.BAR, Sound.Ding);
MOMUp.HideBubble();
MOMUp.HideTitle();
plot MOMDn = if high >= UMGOOB and price crosses above MSMOB then 1 else 0;
;
MOMDn.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_DOWN);
MOMDn.SetDefaultColor(Color.YELLOW);
MOMDn.SetLineWeight(3);
Alert(AlertsOn && MOMDn, "MOMAIN DN", Alert.BAR, Sound.Ding);
MOMDn.HideBubble();
MOMDn.HideTitle();
plot JCMOUp = if low <= LMGOOB and price crosses below JMMOL then 1 else 0;
;
JCMOUp.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_UP);
JCMOUp.SetDefaultColor(Color.YELLOW);
JCMOUp.SetLineWeight(3);
Alert(AlertsOn && JCMOUp, "MOADIT UP", Alert.BAR, Sound.Ding);
JCMOUp.HideBubble();
JCMOUp.HideTitle();
plot JCMODn = if high >= UMGOOB and price crosses above JMMOL then 1 else 0;
JCMODn.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_DOWN);
JCMODn.SetDefaultColor(Color.YELLOW);
JCMODn.SetLineWeight(3);
Alert(AlertsOn && JCMODn, "MOADIT DN", Alert.BAR, Sound.Ding);
JCMODn.HideBubble();
JCMODn.HideTitle();
plot MA;
switch (TypeMA) {
case EMA:
MA = ExpAverage(price[-0], MA_length);
case SMA:
MA = Average(price[-0], MA_length);
}
MA.AssignValueColor(if MA > MA[1] then Color.UPTICK else Color.DOWNTICK);
MA.SetLineWeight(3);
MA.HideBubble();
MA.HideTitle();
plot UpperBand = Highest(high[-0 + 1], PC_length);
UpperBand.SetDefaultColor(GetColor(5));
UpperBand.SetLineWeight(2);
UpperBand.HideBubble();
UpperBand.HideTitle();
plot LowerBand = Lowest(low[-0 + 1], PC_length);
LowerBand.SetDefaultColor(GetColor(6));
LowerBand.SetLineWeight(2);
LowerBand.HideBubble();
LowerBand.HideTitle();
rec up = if MOUp or MOMUp or JCMOUp then 1 else 0;
rec down = if MODn or MOMDn or jcmodn then 1 else 0;
##########---------------------------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));