커뮤니티

수식작성 부탁드립니다.

프로필 이미지
고박사122
2023-05-07 16:56:57
1440
글번호 168749
답변완료
안녕하세요. 운영자님 아래와 같은 트레이딩뷰 수식을 예스트레이더 수식으로 변환 꼭 좀 부탁드립니다. 감사합니다. 안녕하세요. 운영자님 아래와 같은 트레이딩뷰 수식을 예스트레이더 수식으로 변환 부탁드립니다. 감사합니다. // === INPUTS === // rsi rsiSource = input(defval = open, title = "RSI Source") rsiLength = input(defval = 8, title = "RSI Length", minval = 1) // sma maLength = input(defval = 34, title = "MA Period", minval = 1) // invert trade direction tradeInvert = input(defval = false, title = "Invert Trade Direction?") // risk management useStop = input(defval = false, title = "Use Initial Stop Loss?") slPoints = input(defval = 25, title = "Initial Stop Loss Points", minval = 1) useTS = input(defval = true, title = "Use Trailing Stop?") tslPoints = input(defval = 120, title = "Trail Points", minval = 1) useTSO = input(defval = false, title = "Use Offset For Trailing Stop?") tslOffset = input(defval = 20, title = "Trail Offset Points", minval = 1) // === /INPUTS === // === BASE FUNCTIONS === // delay for direction change actions switchDelay(exp, len) => average = len >= 2 ? sum(exp, len) / len : exp[1] up = exp > average down = exp < average state = up ? true : down ? false : up[1] // === /BASE FUNCTIONS === // === SERIES and VAR === // rsi shunt = rsiSource == open ? 0 : 1 rsiUp = rma(max(change(rsiSource[shunt]), 0), rsiLength) rsiDown = rma(-min(change(rsiSource[shunt]), 0), rsiLength) rsi = (rsiDown == 0 ? 100 : rsiUp == 0 ? 0 : 100 - (100 / (1 + rsiUp / rsiDown))) - 50 // shifted 50 points to make 0 median // sma of rsi rsiMa = sma(rsi, maLength) // self explanatory.. tradeDirection = tradeInvert ? 0 <= rsiMa ? true : false : 0 >= rsiMa ? true : false // === /SERIES === // === PLOTTING === barcolor(color = tradeDirection ? green : red, title = "Bar Colours") // hlines medianLine = hline(0, title = 'Median', color = #996600, linestyle = dotted, linewidth = 1) limitUp = hline(25, title = 'Limit Up', color = silver, linestyle = dotted, linewidth = 1) limitDown = hline(-25, title = 'Limit Down', color = silver, linestyle = dotted, linewidth = 1) // rsi and ma rsiLine = plot(rsi, title = 'RSI', color = purple, linewidth = 2, style = line, transp = 50) areaLine = plot(rsiMa, title = 'Area MA', color = silver, linewidth = 1, style = area, transp = 70) // === /PLOTTING === goLong() => not tradeDirection[1] and tradeDirection killLong() => tradeDirection[1] and not tradeDirection strategy.entry(id = "Buy", long = true, when = goLong()) strategy.close(id = "Buy", when = killLong()) goShort() => tradeDirection[1] and not tradeDirection killShort() => not tradeDirection[1] and tradeDirection strategy.entry(id = "Sell", long = false, when = goShort()) strategy.close(id = "Sell", when = killShort()) if (useStop) strategy.exit("XSL", from_entry = "Buy", loss = slPoints) strategy.exit("XSS", from_entry = "Sell", loss = slPoints) // if we're using the trailing stop if (useTS and useTSO) // with offset strategy.exit("XSL", from_entry = "Buy", trail_points = tslPoints, trail_offset = tslOffset) strategy.exit("XSS", from_entry = "Sell", trail_points = tslPoints, trail_offset = tslOffset) if (useTS and not useTSO) // without offset strategy.exit("XSL", from_entry = "Buy", trail_points = tslPoints) strategy.exit("XSS", from_entry = "Sell", trail_points = tslPoints)
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-05-08 11:20:16

안녕하세요 예스스탁입니다. 1 지표 input : rsiSource(open),rsiLength(8),maLength(34),tradeInvert(false); input : useStop(false),slPoints(25),useTS(true),tslPoints(120),useTSO(false),tslOffset(20); var : shunt(0),change(0),alpha(0),rsiUp(0),rsiDown(0),rsiv(0),rsiMa(0),tradeDirection(0); var : barcolor(0); shunt = iff(rsiSource == open , 0 , 1); change = rsiSource-rsiSource[1]; alpha = 1/rsiLength; rsiUp = 0.0; rsiUp = iff(IsNan(rsiUp[1]) == true , ma(max(change[shunt], 0), rsiLength), alpha * max(change[shunt], 0) + (1 - alpha) * iff(IsNan(rsiUp[1])==true,0,rsiUp[1])); rsiDown = 0.0; rsiDown = iff(IsNan(rsiDown[1]) == true , ma(-min(change[shunt], 0), rsiLength), alpha * -min(change[shunt], 0)+ (1 - alpha) * iff(IsNan(rsiUp[1])==true,0,rsiDown[1])); rsiv = (iff(rsiDown == 0 , 100 , iff(rsiUp == 0 , 0 , 100 - (100 / (1 + rsiUp / rsiDown))) - 50)); rsiMa = ma(rsiv, maLength); tradeDirection = iff(tradeInvert , iff(0 <= rsiMa , 1 , 0), IFf(0 >= rsiMa , 1 , 0)); barcolor == IFf(tradeDirection ==1 , green , red); PlotBaseLine1(0, "Median", Gold); PlotBaseLine2(25, "Limit Up", silver); PlotBaseLine31(-25, "Limit Down",silver); // rsi and ma plot1(rsiv, "RSI",purple); plot2(rsiMa, "Area MA",silver); 2 시스템 input : rsiSource(open),rsiLength(8),maLength(34),tradeInvert(0); input : slPoints(25),tslPoints(120),tslOffset(20); var : shunt(0),change(0),alpha(0),rsiUp(0),rsiDown(0),rsiv(0),rsiMa(0),tradeDirection(0); var : barcolor(0),goLong(False),killLong(False),goshort(False),killshort(False); shunt = iff(rsiSource == open , 0 , 1); change = rsiSource-rsiSource[1]; alpha = 1/rsiLength; rsiUp = 0.0; rsiUp = iff(IsNan(rsiUp[1]) == true , ma(max(change[shunt], 0), rsiLength), alpha * max(change[shunt], 0) + (1 - alpha) * iff(IsNan(rsiUp[1])==true,0,rsiUp[1])); rsiDown = 0.0; rsiDown = iff(IsNan(rsiDown[1]) == true , ma(-min(change[shunt], 0), rsiLength), alpha * -min(change[shunt], 0)+ (1 - alpha) * iff(IsNan(rsiUp[1])==true,0,rsiDown[1])); rsiv = (iff(rsiDown == 0 , 100 , iff(rsiUp == 0 , 0 , 100 - (100 / (1 + rsiUp / rsiDown))) - 50)); rsiMa = ma(rsiv, maLength); tradeDirection = iff(tradeInvert == 1 , iff(0 <= rsiMa , 1 , 0), IFf(0 >= rsiMa , 1 , 0)); barcolor == IFf(tradeDirection , green , red); goLong = tradeDirection[1] == 0 and tradeDirection == 1; killLong = tradeDirection[1] == 1 and tradeDirection == 0; goShort = tradeDirection[1] == 1 and tradeDirection == 0; killShort = tradeDirection[1] == 0 and tradeDirection == 1; if goLong == true Then buy("b"); if killLong == true Then ExitLong("bx"); if goShort == true Then Sell("s"); if killShort == true Then ExitShort("sx"); SetStopLoss(slPoints,PointStop); SetStopTrailing(tslOffset,tslPoints,PointStop); SetStopProfittarget(tslPoints,PointStop); 즐거운 하루되세요 > 고박사122 님이 쓴 글입니다. > 제목 : 수식작성 부탁드립니다. > 안녕하세요. 운영자님 아래와 같은 트레이딩뷰 수식을 예스트레이더 수식으로 변환 꼭 좀 부탁드립니다. 감사합니다. 안녕하세요. 운영자님 아래와 같은 트레이딩뷰 수식을 예스트레이더 수식으로 변환 부탁드립니다. 감사합니다. // === INPUTS === // rsi rsiSource = input(defval = open, title = "RSI Source") rsiLength = input(defval = 8, title = "RSI Length", minval = 1) // sma maLength = input(defval = 34, title = "MA Period", minval = 1) // invert trade direction tradeInvert = input(defval = false, title = "Invert Trade Direction?") // risk management useStop = input(defval = false, title = "Use Initial Stop Loss?") slPoints = input(defval = 25, title = "Initial Stop Loss Points", minval = 1) useTS = input(defval = true, title = "Use Trailing Stop?") tslPoints = input(defval = 120, title = "Trail Points", minval = 1) useTSO = input(defval = false, title = "Use Offset For Trailing Stop?") tslOffset = input(defval = 20, title = "Trail Offset Points", minval = 1) // === /INPUTS === // === BASE FUNCTIONS === // delay for direction change actions switchDelay(exp, len) => average = len >= 2 ? sum(exp, len) / len : exp[1] up = exp > average down = exp < average state = up ? true : down ? false : up[1] // === /BASE FUNCTIONS === // === SERIES and VAR === // rsi shunt = rsiSource == open ? 0 : 1 rsiUp = rma(max(change(rsiSource[shunt]), 0), rsiLength) rsiDown = rma(-min(change(rsiSource[shunt]), 0), rsiLength) rsi = (rsiDown == 0 ? 100 : rsiUp == 0 ? 0 : 100 - (100 / (1 + rsiUp / rsiDown))) - 50 // shifted 50 points to make 0 median // sma of rsi rsiMa = sma(rsi, maLength) // self explanatory.. tradeDirection = tradeInvert ? 0 <= rsiMa ? true : false : 0 >= rsiMa ? true : false // === /SERIES === // === PLOTTING === barcolor(color = tradeDirection ? green : red, title = "Bar Colours") // hlines medianLine = hline(0, title = 'Median', color = #996600, linestyle = dotted, linewidth = 1) limitUp = hline(25, title = 'Limit Up', color = silver, linestyle = dotted, linewidth = 1) limitDown = hline(-25, title = 'Limit Down', color = silver, linestyle = dotted, linewidth = 1) // rsi and ma rsiLine = plot(rsi, title = 'RSI', color = purple, linewidth = 2, style = line, transp = 50) areaLine = plot(rsiMa, title = 'Area MA', color = silver, linewidth = 1, style = area, transp = 70) // === /PLOTTING === goLong() => not tradeDirection[1] and tradeDirection killLong() => tradeDirection[1] and not tradeDirection strategy.entry(id = "Buy", long = true, when = goLong()) strategy.close(id = "Buy", when = killLong()) goShort() => tradeDirection[1] and not tradeDirection killShort() => not tradeDirection[1] and tradeDirection strategy.entry(id = "Sell", long = false, when = goShort()) strategy.close(id = "Sell", when = killShort()) if (useStop) strategy.exit("XSL", from_entry = "Buy", loss = slPoints) strategy.exit("XSS", from_entry = "Sell", loss = slPoints) // if we're using the trailing stop if (useTS and useTSO) // with offset strategy.exit("XSL", from_entry = "Buy", trail_points = tslPoints, trail_offset = tslOffset) strategy.exit("XSS", from_entry = "Sell", trail_points = tslPoints, trail_offset = tslOffset) if (useTS and not useTSO) // without offset strategy.exit("XSL", from_entry = "Buy", trail_points = tslPoints) strategy.exit("XSS", from_entry = "Sell", trail_points = tslPoints)