커뮤니티

문의드립니다.

프로필 이미지
플로스트
2020-10-25 06:27:32
1044
글번호 143373
답변완료
늘 초보들을 위해 힘 써 주셔서 감사합니다. 아래는 트레이딩뷰 지표인데 예스에 맞게 변환 부탁드립니다. https://www.tradingview.com/script/OBOvLOxW-QuantNomad-Heikin-Ashi-PSAR-Alerts/ // INPUTS // start = input(0.02, title = "PSAR Start") increment = input(0.02, title = "PSAR Increment") maximum = input(0.2, title = "PSAR Max") // Calculation HA Values haopen = 0.0 haclose = (open + high + low + close) / 4 haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2 hahigh = max(high, max(haopen, haclose)) halow = min(low, min(haopen, haclose)) // HA colors hacolor = haclose > haopen ? color.green : color.red psar = 0.0 // PSAR af = 0.0 // Acceleration Factor trend_dir = 0 // Current direction of PSAR ep = 0.0 // Extreme point trend_bars = 0 sar_long_to_short = trend_dir[1] == 1 and haclose <= psar[1] // PSAR switches from long to short sar_short_to_long = trend_dir[1] == -1 and haclose >= psar[1] // PSAR switches from short to long trend_change = na(psar[2]) or sar_long_to_short or sar_short_to_long // Calculate trend direction trend_dir := na(psar[2]) and haclose[1] > haopen[1] ? 1 : na(psar[2]) and haclose[1] <= haopen[1] ? -1 : sar_long_to_short ? -1 : sar_short_to_long ? 1 : nz(trend_dir[1]) trend_bars := sar_long_to_short ? -1 : sar_short_to_long ? 1 : trend_dir == 1 ? nz(trend_bars[1]) + 1 : trend_dir == -1 ? nz(trend_bars[1]) - 1 : nz(trend_bars[1]) // Calculate Acceleration Factor af := trend_change ? start : (trend_dir == 1 and hahigh > ep[1]) or (trend_dir == -1 and low < ep[1]) ? min(maximum, af[1] + increment) : af[1] // Calculate extreme point ep := trend_change and trend_dir == 1 ? hahigh : trend_change and trend_dir == -1 ? halow : trend_dir == 1 ? max(ep[1], hahigh) : min(ep[1], halow) // Calculate PSAR psar := na(psar[2]) and haclose[1] > haopen[1] ? halow[1] : na(psar[2]) and haclose[1] <= haopen[1] ? hahigh[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep) plotcandle(haopen, hahigh, halow, haclose, title = "HA", color = hacolor) plot(psar, style=plot.style_cross, color=trend_dir == 1 ? color.green : color.red, linewidth = 2) plotshape(sar_short_to_long, color = color.green, style = shape.arrowup, text = "Long", location = location.abovebar) plotshape(sar_long_to_short, color = color.red, style = shape.arrowdown, text = "Short", location = location.belowbar) alertcondition(sar_short_to_long, "HA PSAR Long", "HA PSAR Long") alertcondition(sar_long_to_short, "HA PSAR Short", "HA Short Long")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2020-10-26 13:20:43

안녕하세요 예스스탁입니다. 1 강조 var : haopen(0),haclose(0),hahigh(0),halow(0),hacolor(0); // Calculation HA Values if index == 0 then { haOpen = open; haClose = (O+H+L+C)/4; haHigh = MaxList( high, haOpen, haClose); haLow = MinList( low, haOpen,haClose); } else { haClose = (O+H+L+C)/4; haOpen = (haOpen [1] + haClose [1])/2 ; haHigh = MaxList(High, haOpen, haClose) ; haLow = MinList(Low, haOpen, haClose) ; } // HA colors hacolor = iff(haclose > haopen , green ,red); PlotPaintBar(hahigh, halow, haopen,haclose, "HA",hacolor); 2 지표 input : start(0.02),increment(0.02),maximum(0.2); var : haopen(0),haclose(0),hahigh(0),halow(0),hacolor(0); var : af(0),trend_dir(0),ep(0),trend_bars(0),psar(0); var : sar_long_to_short(False),sar_short_to_long(False),trend_change(False); // Calculation HA Values if index == 0 then { haOpen = open; haClose = (O+H+L+C)/4; haHigh = MaxList( high, haOpen, haClose); haLow = MinList( low, haOpen,haClose); } else { haClose = (O+H+L+C)/4; haOpen = (haOpen [1] + haClose [1])/2 ; haHigh = MaxList(High, haOpen, haClose) ; haLow = MinList(Low, haOpen, haClose) ; } // HA colors hacolor = iff(haclose > haopen , green ,red); psar = 0.0; // PSAR af = 0.0; // Acceleration Factor trend_dir = 0; // Current direction of PSAR ep = 0.0; // Extreme point trend_bars = 0; sar_long_to_short = trend_dir[1] == 1 and haclose <= psar[1]; // PSAR switches from long to short sar_short_to_long = trend_dir[1] == -1 and haclose >= psar[1]; // PSAR switches from short to long trend_change = IsNaN(psar[2]) == true or sar_long_to_short or sar_short_to_long; // Calculate trend direction trend_dir = iff(IsNaN(psar[2]) == true and haclose[1] > haopen[1] , 1 , IFf(IsNaN(psar[2]) == true and haclose[1] <= haopen[1] , -1 , iff(sar_long_to_short , -1 , iff(sar_short_to_long , 1 , trend_dir[1])))); trend_bars = iff(sar_long_to_short , -1 , iff(sar_short_to_long , 1 , iff(trend_dir == 1 , trend_bars[1] + 1 , iff(trend_dir == -1 , trend_bars[1] - 1 ,trend_bars[1])))); // Calculate Acceleration Factor af = iff(trend_change , start , iff((trend_dir == 1 and hahigh > ep[1]) or (trend_dir == -1 and low < ep[1]) , min(maximum, af[1] + increment),af[1])); // Calculate extreme point ep = iff(trend_change and trend_dir == 1 , hahigh , iff(trend_change and trend_dir == -1 , halow , iff(trend_dir == 1 , max(ep[1], hahigh) ,min(ep[1], halow)))); // Calculate PSAR psar = iff(IsNaN(psar[2]) == true and haclose[1] > haopen[1] , halow[1] , iff(IsNan(psar[2]) == true and haclose[1] <= haopen[1] , hahigh[1] , iff(trend_change , ep[1] , IFf(trend_dir == 1 , psar[1] + af * (ep - psar[1]) , psar[1] - af * (psar[1] - ep) )))); plot1(psar,"Sar",iff(trend_dir == 1 , green ,red)); 즐거운 하루되세요 > 플로스트 님이 쓴 글입니다. > 제목 : 문의드립니다. > 늘 초보들을 위해 힘 써 주셔서 감사합니다. 아래는 트레이딩뷰 지표인데 예스에 맞게 변환 부탁드립니다. https://www.tradingview.com/script/OBOvLOxW-QuantNomad-Heikin-Ashi-PSAR-Alerts/ // INPUTS // start = input(0.02, title = "PSAR Start") increment = input(0.02, title = "PSAR Increment") maximum = input(0.2, title = "PSAR Max") // Calculation HA Values haopen = 0.0 haclose = (open + high + low + close) / 4 haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2 hahigh = max(high, max(haopen, haclose)) halow = min(low, min(haopen, haclose)) // HA colors hacolor = haclose > haopen ? color.green : color.red psar = 0.0 // PSAR af = 0.0 // Acceleration Factor trend_dir = 0 // Current direction of PSAR ep = 0.0 // Extreme point trend_bars = 0 sar_long_to_short = trend_dir[1] == 1 and haclose <= psar[1] // PSAR switches from long to short sar_short_to_long = trend_dir[1] == -1 and haclose >= psar[1] // PSAR switches from short to long trend_change = na(psar[2]) or sar_long_to_short or sar_short_to_long // Calculate trend direction trend_dir := na(psar[2]) and haclose[1] > haopen[1] ? 1 : na(psar[2]) and haclose[1] <= haopen[1] ? -1 : sar_long_to_short ? -1 : sar_short_to_long ? 1 : nz(trend_dir[1]) trend_bars := sar_long_to_short ? -1 : sar_short_to_long ? 1 : trend_dir == 1 ? nz(trend_bars[1]) + 1 : trend_dir == -1 ? nz(trend_bars[1]) - 1 : nz(trend_bars[1]) // Calculate Acceleration Factor af := trend_change ? start : (trend_dir == 1 and hahigh > ep[1]) or (trend_dir == -1 and low < ep[1]) ? min(maximum, af[1] + increment) : af[1] // Calculate extreme point ep := trend_change and trend_dir == 1 ? hahigh : trend_change and trend_dir == -1 ? halow : trend_dir == 1 ? max(ep[1], hahigh) : min(ep[1], halow) // Calculate PSAR psar := na(psar[2]) and haclose[1] > haopen[1] ? halow[1] : na(psar[2]) and haclose[1] <= haopen[1] ? hahigh[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep) plotcandle(haopen, hahigh, halow, haclose, title = "HA", color = hacolor) plot(psar, style=plot.style_cross, color=trend_dir == 1 ? color.green : color.red, linewidth = 2) plotshape(sar_short_to_long, color = color.green, style = shape.arrowup, text = "Long", location = location.abovebar) plotshape(sar_long_to_short, color = color.red, style = shape.arrowdown, text = "Short", location = location.belowbar) alertcondition(sar_short_to_long, "HA PSAR Long", "HA PSAR Long") alertcondition(sar_long_to_short, "HA PSAR Short", "HA Short Long")