커뮤니티

수식변환 부탁드립니다

프로필 이미지
하루삼프로
2023-08-28 10:17:08
1129
글번호 171887
답변완료
안녕하세요 항상 감사드립니다. 예스 수식으로 지표식, 종목검색식 부탁드립니다. 수고 하십시요. // Inputs leftBars = input(10, title='PP Left Bars') rightBars = input(10, title='PP Right Bars') atr_length = input(100, title='ATR Length') atr_mult = input(100, title='ATR Mult') // Pivot High Significant Function pivotHighSig(left, right) => pp_ok = true atr = ta.atr(atr_length) for i = 1 to left by 1 if high[right] < high[right + i] + atr * atr_mult pp_ok := false pp_ok for i = 0 to right - 1 by 1 if high[right] < high[i] + atr * atr_mult pp_ok := false pp_ok pp_ok ? high[right] : na // Pivot Low Significant Function pivotLowSig(left, right) => pp_ok = true atr = ta.atr(atr_length) for i = 1 to left by 1 if low[right] > low[right + i] - atr * atr_mult pp_ok := false pp_ok for i = 0 to right - 1 by 1 if low[right] > low[i] - atr * atr_mult pp_ok := false pp_ok pp_ok ? low[right] : na swh = pivotHighSig(leftBars, rightBars) swl = pivotLowSig(leftBars, rightBars) swh_cond = not na(swh) hprice = 0.0 hprice := swh_cond ? swh : hprice[1] le = false le := swh_cond ? true : le[1] and high > hprice ? false : le[1] swl_cond = not na(swl) lprice = 0.0 lprice := swl_cond ? swl : lprice[1] se = false se := swl_cond ? true : se[1] and low < lprice ? false : se[1] // Pivots of pivots ph1 = 0.0 ph2 = 0.0 ph3 = 0.0 pl1 = 0.0 pl2 = 0.0 pl3 = 0.0 pphprice = 0.0 pplprice = 0.0 ph3 := swh_cond ? nz(ph2[1]) : nz(ph3[1]) ph2 := swh_cond ? nz(ph1[1]) : nz(ph2[1]) ph1 := swh_cond ? hprice : nz(ph1[1]) pl3 := swl_cond ? nz(pl2[1]) : nz(pl3[1]) pl2 := swl_cond ? nz(pl1[1]) : nz(pl2[1]) pl1 := swl_cond ? lprice : nz(pl1[1]) pphprice := swh_cond and ph2 > ph1 and ph2 > ph3 ? ph2 : nz(pphprice[1]) pplprice := swl_cond and pl2 < pl1 and pl2 < pl3 ? pl2 : nz(pplprice[1]) if le and not na(pphprice) and pphprice != 0 strategy.entry('PivRevLE', strategy.long, comment='PivRevLE', stop=pphprice + syminfo.mintick) if se and not na(pplprice) and pplprice != 0 strategy.entry('PivRevSE', strategy.short, comment='PivRevSE', stop=pplprice - syminfo.mintick) // Plotting plot(lprice, color=color.new(color.red, 55)) plot(hprice, color=color.new(color.green, 55)) plot(pplprice, color=color.new(color.red, 0), linewidth=2) plot(pphprice, color=color.new(color.green, 0), linewidth=2)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-08-29 10:02:19

안녕하세요 예스스탁입니다. 1 input : left(3),right(3),atr_length(10),atr_mult(2); var : i(0),atrv(0),ph_ok(false),pl_ok(false); var : pivotHighSig(0),pivotLowSig(0); var : swh(Nan),swl(Nan),swh_cond(False),swl_cond(False); var : hprice(0),lPrice(0),le(False),se(False); var : ph1(0),ph2(0),ph3(0),pl1(0),pl2(0),pl3(0); var : pphprice(0),pplprice(0); atrv = atr(atr_length); ph_ok = true; pl_ok = true; for i = 1 to left { if high[right] < high[right + i] + atrv * atr_mult Then ph_ok = false; if low[right] > low[right + i] - atrv * atr_mult Then pl_ok = False; } for i = 0 to right - 1 { if high[right] < high[i] + atrv * atr_mult Then ph_ok = false; if low[right] > low[i] - atrv * atr_mult Then pl_ok = False; } pivotHighSig = iff(ph_ok , high[right] , Nan); pivotLowSig = IFf(pl_ok , low[right] , Nan); swh = pivotHighSig; swl = pivotLowSig; swh_cond = IsNan(swh) == False ; hprice = iff(swh_cond , swh , hprice[1]); le = false; if swh_cond == true Then le = true; Else { if le[1] and high > hprice Then le = False; Else le = le[1]; } swl_cond = IsNan(swl) == False; lprice = iff(swl_cond , swl , lprice[1]); se = false; if swl_cond == true Then se = true; Else { if se[1] and low < lprice Then se = False; Else se = se[1]; } if swh_cond == true Then { ph3 = ph2[1]; ph2 = ph1[1]; ph1 = hprice; if ph2 > ph1 and ph2 > ph3 Then pphprice = ph2; } if swl_cond == true Then { pl3 = pl2[1]; pl2 = pl1[1]; pl1 = lprice; if pl2 < pl1 and pl2 < pl3 Then pplprice = pl2; } if lprice > 0 Then plot1(lprice, "lprice",red); if hprice > 0 Then plot2(hprice, "hprice", green); if pplprice > 0 Then plot3(pplprice,"pplorice", red); if pphprice > 0 Then plot4(pphprice,"pphprice", green); 2 수식안에 매수조건내용을 작성해 드립니다. input : left(3),right(3),atr_length(10),atr_mult(2); var : i(0),atrv(0),ph_ok(false),pl_ok(false); var : pivotHighSig(0),pivotLowSig(0); var : swh(Nan),swl(Nan),swh_cond(False),swl_cond(False); var : hprice(0),lPrice(0),le(False),se(False); var : ph1(0),ph2(0),ph3(0),pl1(0),pl2(0),pl3(0); var : pphprice(0),pplprice(0); atrv = atr(atr_length); ph_ok = true; pl_ok = true; for i = 1 to left { if high[right] < high[right + i] + atrv * atr_mult Then ph_ok = false; if low[right] > low[right + i] - atrv * atr_mult Then pl_ok = False; } for i = 0 to right - 1 { if high[right] < high[i] + atrv * atr_mult Then ph_ok = false; if low[right] > low[i] - atrv * atr_mult Then pl_ok = False; } pivotHighSig = iff(ph_ok , high[right] , Nan); pivotLowSig = IFf(pl_ok , low[right] , Nan); swh = pivotHighSig; swl = pivotLowSig; swh_cond = IsNan(swh) == False ; hprice = iff(swh_cond , swh , hprice[1]); le = false; if swh_cond == true Then le = true; Else { if le[1] and high > hprice Then le = False; Else le = le[1]; } swl_cond = IsNan(swl) == False; lprice = iff(swl_cond , swl , lprice[1]); se = false; if swl_cond == true Then se = true; Else { if se[1] and low < lprice Then se = False; Else se = se[1]; } if swh_cond == true Then { ph3 = ph2[1]; ph2 = ph1[1]; ph1 = hprice; if ph2 > ph1 and ph2 > ph3 Then pphprice = ph2; } if swl_cond == true Then { pl3 = pl2[1]; pl2 = pl1[1]; pl1 = lprice; if pl2 < pl1 and pl2 < pl3 Then pplprice = pl2; } if le and pphprice != 0 Then Find(1); 즐거운 하루되세요 > 하루삼프로 님이 쓴 글입니다. > 제목 : 수식변환 부탁드립니다 > 안녕하세요 항상 감사드립니다. 예스 수식으로 지표식, 종목검색식 부탁드립니다. 수고 하십시요. // Inputs leftBars = input(10, title='PP Left Bars') rightBars = input(10, title='PP Right Bars') atr_length = input(100, title='ATR Length') atr_mult = input(100, title='ATR Mult') // Pivot High Significant Function pivotHighSig(left, right) => pp_ok = true atr = ta.atr(atr_length) for i = 1 to left by 1 if high[right] < high[right + i] + atr * atr_mult pp_ok := false pp_ok for i = 0 to right - 1 by 1 if high[right] < high[i] + atr * atr_mult pp_ok := false pp_ok pp_ok ? high[right] : na // Pivot Low Significant Function pivotLowSig(left, right) => pp_ok = true atr = ta.atr(atr_length) for i = 1 to left by 1 if low[right] > low[right + i] - atr * atr_mult pp_ok := false pp_ok for i = 0 to right - 1 by 1 if low[right] > low[i] - atr * atr_mult pp_ok := false pp_ok pp_ok ? low[right] : na swh = pivotHighSig(leftBars, rightBars) swl = pivotLowSig(leftBars, rightBars) swh_cond = not na(swh) hprice = 0.0 hprice := swh_cond ? swh : hprice[1] le = false le := swh_cond ? true : le[1] and high > hprice ? false : le[1] swl_cond = not na(swl) lprice = 0.0 lprice := swl_cond ? swl : lprice[1] se = false se := swl_cond ? true : se[1] and low < lprice ? false : se[1] // Pivots of pivots ph1 = 0.0 ph2 = 0.0 ph3 = 0.0 pl1 = 0.0 pl2 = 0.0 pl3 = 0.0 pphprice = 0.0 pplprice = 0.0 ph3 := swh_cond ? nz(ph2[1]) : nz(ph3[1]) ph2 := swh_cond ? nz(ph1[1]) : nz(ph2[1]) ph1 := swh_cond ? hprice : nz(ph1[1]) pl3 := swl_cond ? nz(pl2[1]) : nz(pl3[1]) pl2 := swl_cond ? nz(pl1[1]) : nz(pl2[1]) pl1 := swl_cond ? lprice : nz(pl1[1]) pphprice := swh_cond and ph2 > ph1 and ph2 > ph3 ? ph2 : nz(pphprice[1]) pplprice := swl_cond and pl2 < pl1 and pl2 < pl3 ? pl2 : nz(pplprice[1]) if le and not na(pphprice) and pphprice != 0 strategy.entry('PivRevLE', strategy.long, comment='PivRevLE', stop=pphprice + syminfo.mintick) if se and not na(pplprice) and pplprice != 0 strategy.entry('PivRevSE', strategy.short, comment='PivRevSE', stop=pplprice - syminfo.mintick) // Plotting plot(lprice, color=color.new(color.red, 55)) plot(hprice, color=color.new(color.green, 55)) plot(pplprice, color=color.new(color.red, 0), linewidth=2) plot(pphprice, color=color.new(color.green, 0), linewidth=2)