커뮤니티

고생이 많으세요 트레이딩뷰 식 변환 부탁드립니다.

프로필 이미지
midasys
2021-03-12 15:31:36
740
글번호 147048
답변완료
감사합니다. //@version=2 strategy("Forex Master v4.0", overlay=true) Price = close Length = input(20) Mult = input(1.5) Basis = sma(Price, Length) StdDev = Mult * stdev(Price, Length) Upper = Basis + StdDev Lower = Basis - StdDev ADX_Length = input(50) TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1]))) DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0 DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0 SmoothedTrueRange = nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/ADX_Length) + TrueRange SmoothedDirectionalMovementPlus = nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/ADX_Length) + DirectionalMovementPlus SmoothedDirectionalMovementMinus = nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/ADX_Length) + DirectionalMovementMinus DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100 DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100 DX = abs(DIPlus - DIMinus) / (DIPlus + DIMinus)*100 SmoothedADX1 = ema(DX, input(6)) SmoothedADX2 = ema(DX, input(12)) Condition1 = crossover(Price, Lower) and SmoothedADX1 < SmoothedADX2 Condition2 = crossunder(Price, Upper) and SmoothedADX1 < SmoothedADX2 Take_Profit = input(500) Stop_Loss = input(500) strategy.entry("LongEntry", true, when = Condition1) strategy.exit("LongExit", "LongEntry", profit = Take_Profit, loss = Stop_Loss) strategy.entry("ShortEntry", false, when = Condition2) strategy.exit("ShortExit", "ShortEntry", profit = Take_Profit, loss = Stop_Loss)
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-03-12 15:59:16

안녕하세요 예스스탁입니다. input : Length(20),Mult(1.5); input : ADX_Length(50),P1(6),P2(12); input : Take_Profit(500),Stop_Loss(500); var : Price(0),Basis(0),StdDev(0),upper(0),lower(0); var : TR(0),DirectionalMovementPlus(0),DirectionalMovementMinus(0); var : SmoothedTrueRange(0),SmoothedDirectionalMovementPlus(0),SmoothedDirectionalMovementMinus(0); var : DIP(0),DIM(0),DX(0),SmoothedADX1(0),SmoothedADX2(0); Price = close; Basis = ma(Price, Length); StdDev = Mult * std(Price, Length); Upper = Basis + StdDev; Lower = Basis - StdDev; TR = max(max(high-low, abs(high-close[1])), abs(low-close[1])); DirectionalMovementPlus = iff(high-high[1] > low[1]-low , max(high-high[1], 0) , 0); DirectionalMovementMinus = iff(low[1]-low > high-high[1] , max(low[1]-low, 0) , 0); SmoothedTrueRange = SmoothedTrueRange - (SmoothedTrueRange/ADX_Length) + TR; SmoothedDirectionalMovementPlus = SmoothedDirectionalMovementPlus - (SmoothedDirectionalMovementPlus/ADX_Length) + DirectionalMovementPlus; SmoothedDirectionalMovementMinus = SmoothedDirectionalMovementMinus - (SmoothedDirectionalMovementMinus/ADX_Length) + DirectionalMovementMinus; DIP = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100; DIM = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100; DX = abs(DIP - DIM) / (DIP + DIM)*100; SmoothedADX1 = ema(DX, P1); SmoothedADX2 = ema(DX, P2); Condition1 = CrossUp(Price, Lower) and SmoothedADX1 < SmoothedADX2; Condition2 = CrossDown(Price, Upper) and SmoothedADX1 < SmoothedADX2; if Condition1 == true Then Buy(); if Condition2 == true Then Sell(); SetStopProfittarget(Take_Profit,PointStop); SetStopLoss(Stop_Loss,PointStop); 즐거운 하루되세요 > midasys 님이 쓴 글입니다. > 제목 : 고생이 많으세요 트레이딩뷰 식 변환 부탁드립니다. > 감사합니다. //@version=2 strategy("Forex Master v4.0", overlay=true) Price = close Length = input(20) Mult = input(1.5) Basis = sma(Price, Length) StdDev = Mult * stdev(Price, Length) Upper = Basis + StdDev Lower = Basis - StdDev ADX_Length = input(50) TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1]))) DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0 DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0 SmoothedTrueRange = nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/ADX_Length) + TrueRange SmoothedDirectionalMovementPlus = nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/ADX_Length) + DirectionalMovementPlus SmoothedDirectionalMovementMinus = nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/ADX_Length) + DirectionalMovementMinus DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100 DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100 DX = abs(DIPlus - DIMinus) / (DIPlus + DIMinus)*100 SmoothedADX1 = ema(DX, input(6)) SmoothedADX2 = ema(DX, input(12)) Condition1 = crossover(Price, Lower) and SmoothedADX1 < SmoothedADX2 Condition2 = crossunder(Price, Upper) and SmoothedADX1 < SmoothedADX2 Take_Profit = input(500) Stop_Loss = input(500) strategy.entry("LongEntry", true, when = Condition1) strategy.exit("LongExit", "LongEntry", profit = Take_Profit, loss = Stop_Loss) strategy.entry("ShortEntry", false, when = Condition2) strategy.exit("ShortExit", "ShortEntry", profit = Take_Profit, loss = Stop_Loss)