커뮤니티

예스랭귀지 Q&A

글쓰기
답변완료

수식 부탁드립니다.

안녕하세요? 고생 많으십니다 1. 이전 N개봉 동안 5이평> 20이평 상태에서 조건1 이 발생했을 때 매수. 2. (이전에) 조건2가 발생 했을 때 (다른 지표에서)조건3이었고 이후 조건3을 계속 만족한 상태에서 조건4가 발생하면 매수. 수식만 있으면 제가 초보라서 해석이 잘 안되므로 간단한 설명도 부탁 드립니다. 항상 감사 드립니다.
프로필 이미지
매매신호
2023-11-23
1261
글번호 174293
시스템
답변완료

문의 드립니다.

study(title="Twin Range Filter", overlay=true) source = input(defval=close, title="Source") // Smooth Average Range per1 = input(defval=27, minval=1, title="Fast period") mult1 = input(defval=1.6, minval=0.1, title="Fast range") per2 = input(defval=55, minval=1, title="Slow period") mult2 = input(defval=2, minval=0.1, title="Slow range") smoothrng(x, t, m) => wper = t * 2 - 1 avrng = ema(abs(x - x[1]), t) smoothrng = ema(avrng, wper) * m smoothrng smrng1 = smoothrng(source, per1, mult1) smrng2 = smoothrng(source, per2, mult2) smrng = (smrng1 + smrng2) / 2 // Range Filter rngfilt(x, r) => rngfilt = x rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r rngfilt filt = rngfilt(source, smrng) upward = 0.0 upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) downward = 0.0 downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) hband = filt + smrng lband = filt - smrng longCond = bool(na) shortCond = bool(na) longCond := source > filt and source > source[1] and upward > 0 or source > filt and source < source[1] and upward > 0 shortCond := source < filt and source < source[1] and downward > 0 or source < filt and source > source[1] and downward > 0 CondIni = 0 CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] long = longCond and CondIni[1] == -1 short = shortCond and CondIni[1] == 1 // Plotting plotshape(long, title="Long", text="Long", style=shape.labelup, textcolor=color.black, size=size.tiny, location=location.belowbar, color=color.lime, transp=0) plotshape(short, title="Short", text="Short", style=shape.labeldown, textcolor=color.white, size=size.tiny, location=location.abovebar, color=color.red, transp=0) // Alerts alertcondition(long, title="Long", message="Long") alertcondition(short, title="Short", message="Short") 트레이딩뷰 수식인데 예스 시스템식으로 부탁드려요.
프로필 이미지
신대륙발견
2023-11-23
1343
글번호 174292
시스템
답변완료

안녕하세요. 수식 작성 도움 부탁드립니다.

매수 종가>200일 이동평균선 and 종가<전일저가 일때 신호봉 신호봉 고가 돌파시 시장가 매수 stop loss 신호봉 저가 -1틱 청산 이익이나는 첫 종가 다음 날 시가 시장가 매도 비중 : 손실폭이 총 자산의 2% 되는 수량. 손실 폭 = (기준봉 고가+1틱) -(기준봉 저가 -1틱)
프로필 이미지
sw98
2023-11-23
1268
글번호 174291
시스템
답변완료

문의드립니다

15분봉에서, 130봉중(일주간: 일일 26봉*5일)의 최고가를, 1봉전에 돌파한 것을 0봉에 검색코자 합니다. 단, 1.1봉전의 돌파봉은 최소 3%이상 2.129봉간 -고가/저가기준으로는 최고가 ~ 최저가 차이가 10%이하 OR -종가기준은 5%이하 차이 (돌파봉(1봉전)의 상승분은 무시: 129봉전 ~ 2봉전까지 최고/최저 가격차이) 3.당일 첫번째 돌파만 검색(이후는 무시) 가능하시다면 검색수식 부탁올립니다.
프로필 이미지
ksks
2023-11-23
1845
글번호 174290
종목검색
답변완료

문의 드립니다!

안녕하세요! 아래수식을 예스로 변환부탁드립니다 감사합니다! A = ((predayhigh()+predaylow()+ predayclose())/3)+ (predayhigh()-predaylow()) (c,(A*1.07))
프로필 이미지
유로파54
2023-11-22
1577
글번호 174289
지표
답변완료

수식 변경 부탁드립니다

// This function calcualtes a se lectable average type GetAverage(_data, _len, MAOption) => value = switch MAOption 'SMA' => ta.sma(_data, _len) 'EMA' => ta.ema(_data, _len) 'HMA' => ta.hma(_data, _len) 'RMA' => ta.rma(_data, _len) => ta.wma(_data, _len) // *********************************************************************************************************** // ======================================================================================== // Normalization function - Normalizes values that are not restricted within a zero to 100 range // This technique provides a scale that is closer to a "human" estimation of value in "bands" // as in: low, below average, average, above average, high, super high // this also avoids the issue of extreme values when using the stoch() -based technique // these values are subjective, and can be changed - but slight changes here won't lead to major changes in outcome // since all is relative to the same data series. // Normalize(_Value, _Avg) => _X = _Value / _Avg _Nor = _X > 1.50 ? 1.00 : _X > 1.20 ? 0.90 : _X > 1.00 ? 0.80 : _X > 0.80 ? 0.70 : _X > 0.60 ? 0.60 : _X > 0.40 ? 0.50 : _X > 0.20 ? 0.25 : 0.1 // =================================================================================== // =========================================================================================================== // Inputs // =========================================================================================================== grp_1 = 'Rate of FLow (RoF)' grp_2 = 'Lookback Parameters' grp_3 = 'Bias / Sentiment' grp_4 = 'EVEREX Bands' length = input.int(10, minval = 1, inline = 'ROF', group = grp_1) MA_Type = input.string(defval = 'WMA', title = 'MA type', options = ['WMA', 'EMA', 'SMA', 'HMA', 'RMA'], inline = 'ROF', group = grp_1) smooth = input.int(defval = 3, title = 'Smooth', minval = 1, inline = 'ROF', group = grp_1) //src = input.source(close, title = "Source (for 2-Bar Shift)", group = grp_1) sig_length = input.int(5, 'Signal Length', minval = 1, inline = 'Signal', group = grp_1) S_Type = input.string(defval = 'WMA', title = 'Signal Type', options = ['WMA', 'EMA', 'SMA', 'HMA', 'RMA'], inline = 'Signal', group = grp_1) lookback = input.int(defval = 20, title = 'Length', minval = 1, inline = 'Lookback', group = grp_2) lkbk_Calc = input.string(defval = 'Simple', title = 'Averaging', options = ['Simple', 'Same as RRoF'], inline='Lookback', group = grp_2 ) showBias = input.bool(defval = false, title = 'Bias Plot ? -- ', inline = 'Bias', group = grp_3) B_Length = input.int(defval = 30, title = 'Length', minval = 1, inline = 'Bias', group = grp_3) B_Type = input.string(defval = 'WMA', title = 'MA type', options = ['WMA', 'EMA', 'SMA', 'HMA', 'RMA'], inline = 'Bias', group = grp_3) showEVEREX = input.bool(true, 'Show EVEREX Bands ? -- ', inline = 'EVEREX', group = grp_4) // a simple mechanism to control/change the strength band scale for improving visualization // applies only to the "bands" and the level hlines bandscale = str.tonumber(input.string("100", title = "Band Scale", options = ['100', '200', '400'], inline = 'EVEREX', group = grp_4)) DispBias = showBias ? display.pane : display.none DispBands = showEVEREX ? display.pane : display.none showhlines = showEVEREX ? display.all : display.none Disp_vals = display.status_line + display.data_window // =========================================================================================================== // Calculations // =========================================================================================================== // Volume "effort" Calculation -- will revert to no volume acceleration for instruments with no volume data v = na(volume) ? 1 : volume // this part ensures we're not hit with calc issues due to NaN's NoVol_Flag = na(volume) ? true : false // this is a flag to use later lkbk_MA_Type = lkbk_Calc == 'Simple' ? 'SMA' : MA_Type Vola = GetAverage(v, lookback, lkbk_MA_Type) Vola_n_pre = Normalize(v, Vola) * 100 //Now trap the case of no volume data - ensure final calculation not impacted Vola_n = NoVol_Flag ? 100 : Vola_n_pre //plot(Vola_n , "Volume Normalized", color = color.white, display = display.none) // =============================================================================================================== // Price "result" calculation // we'll consider "result" (strength or weakness) to be the outcome (average) of 6 elements: // Same (in-)Bar strength elements: // 1 - Bar Closing: the closing within the bar --> this will be a direct +100 / -100 value // 2 - Spread to range: the spread to range ratio (that's BoP formula) --> direct +100 / -100 value // 3 - Relative Spread: spread relative to average spread during lookback period --> normalized // 2-bar strength elements: // 4 - 2-bar closing: the closing within 2-bar range (that accomodates open gap effect) // 5 - 2-bar Closing Shift to Range: Change in close relative to the 2-bar range // 6 - 2-bar Relative Shift: the 2-bar Close (or source price) shift - relative to the average 2-bar shift during lookback period --> normalized BarSpread = close - open BarRange = high - low R2 = ta.highest(2) - ta.lowest(2) SrcShift = ta.change(close) //TR = ta.tr(true) sign_shift = math.sign(SrcShift) sign_spread = math.sign(BarSpread) // ========================================================================================================= // in-bar assessments // ========================================================================================================= // 1. Calculate closing within bar - should be max value at either ends of the bar range barclosing = 2 * (close - low) / BarRange * 100 - 100 //plot(barclosing, "Bar Closing %" , color=color.fuchsia, display = display.none) // 2. caluclate spread to range ratio s2r = BarSpread / BarRange * 100 //plot(s2r, "Spread:Range", color = color.lime, display = display.none) // 3. Calculate relative spread compared to average spread during lookback BarSpread_abs = math.abs(BarSpread) BarSpread_avg = GetAverage(BarSpread_abs, lookback, lkbk_MA_Type) BarSpread_ratio_n = Normalize(BarSpread_abs, BarSpread_avg) * 100 * sign_spread //plot(BarSpread_ratio_n, "Bar Spread Ratio", color=color.orange, display=display.none) // ========================================================================================================= // 2-bar assessments // ========================================================================================================= // 4. Calculate closing within 2 bar range - should be max value at either ends of the 2-bar range barclosing_2 = 2 * (close - ta.lowest(2)) / R2 * 100 - 100 //plot(barclosing_2, "2-Bar Closing %" , color=color.navy, display = display.none) // 5. calculate 2-bar shift to range ratio Shift2Bar_toR2 = SrcShift / R2 * 100 //plot(Shift2Bar_toR2, "2-bar Shift vs 2R", color=color.yellow, display = display.none) // 6. Calculate 2-bar Relative Shift SrcShift_abs = math.abs(SrcShift) srcshift_avg = GetAverage(SrcShift_abs, lookback, lkbk_MA_Type) srcshift_ratio_n = Normalize(SrcShift_abs, srcshift_avg) * 100 * sign_shift //plot(srcshift_ratio_n, "2-bar Shift vs Avg", color=color.white, display = display.none) // =============================================================================== // ========================================================================================= // Relative Price Strength combining all strength elements Pricea_n = (barclosing + s2r + BarSpread_ratio_n + barclosing_2 + Shift2Bar_toR2 + srcshift_ratio_n) / 6 //plot(Pricea_n, "Price Normalized", color=color.orange, display = display.none) //Let's take Bar Flow as the combined price strength * the volume:avg ratio // this works in a similar way to a volume-weighted RSI bar_flow = Pricea_n * Vola_n / 100 //plot(bar_flow, 'bar_flow', color=color.green, display = display.none) // calc avergae relative rate of flow, then smooth the resulting average // classic formula would be this //RROF = f_ma(bar_flow, length, MA_Type) // // or we can create a relative index by separating bulls from bears, like in an RSI - my preferred method // here we have an added benefit of plotting the (average) bulls vs bears separately - as an option bulls = math.max(bar_flow, 0) bears = -1 * math.min(bar_flow, 0) bulls_avg = GetAverage(bulls, length, MA_Type) bears_avg = GetAverage(bears, length, MA_Type) dx = bulls_avg / bears_avg RROF = 2 * (100 - 100 / (1 + dx)) - 100 RROF_s = ta.wma(RROF, smooth) Signal = GetAverage(RROF_s, sig_length, S_Type) // Calculate Bias / sentiment on longer length dx_b = GetAverage(bulls, B_Length, B_Type) / GetAverage(bears, B_Length, B_Type) RROF_b = 2 * (100 - 100 / (1 + dx_b)) - 100 RROF_bs = ta.wma(RROF_b, smooth) // =========================================================================================================== // Colors & plots // =========================================================================================================== c_zero = color.new(#1163f6, 25) c_band = color.new(color.yellow, 40) c_up = color.aqua c_dn = color.orange c_sup = color.new(#00aa00, 70) c_sdn = color.new(#ff180b, 70) up = RROF_s >= 0 s_up = RROF_bs >=0 // ==================================== Plots ========================================================== // // Display the ATR & VOl Ratio values only on the indicator status line & in the Data Window // plotchar(shift, title = "Shift", char = "", color = color.white, editable=false, display=display.status_line + display.data_window) // plotchar(lbk_tr, title = "Avg Shift", char = "", color = color.aqua, editable=false, display=display.status_line + display.data_window) // plotchar(vola/lbk_vola, title = "Vol Ratio", char = "", color = color.yellow, editable=false, display=display.status_line + display.data_window) hline(0, 'Zero Line', c_zero, linestyle = hline.style_solid) // plot the band scale guide lines -- these lines will show/hide along with the EVEREX "Equalizer Bands Plot" hline(0.25 * bandscale, title = '1/4 Level', color=c_band, linestyle = hline.style_dotted, display = showhlines) hline(0.50 * bandscale, title = '2/4 Level', color=c_band, linestyle = hline.style_dotted, display = showhlines) hline(0.75 * bandscale, title = '3/4 Level', color=c_band, linestyle = hline.style_dotted, display = showhlines) hline(bandscale, title = '4/4 Level', color=c_band, linestyle = hline.style_dotted, display = showhlines) // Plot Bulls & Bears - these are optional plots and hidden by default - adjust this section later plot(ta.wma(bulls_avg, smooth), "Bulls", color = #11ff20, linewidth = 2, display = display.none) plot(ta.wma(bears_avg, smooth), "Bears", color = #d5180b, linewidth = 2, display = display.none) // ============================================================================= // Plot Bias / Sentiment plot (RROF_bs, "Bias / Sentiment", style=plot.style_area, color = s_up ? c_sup : c_sdn, linewidth = 4, display = DispBias ) // ============================================================================= // Plot Price Strength & Relative Volume as stacked "equalizer bands" // adding visualization option to make the bands joint or separate at the mid-scale mark Eq_band_option = input.string("Joint", title = 'Band Option', options = ["Joint", "Separate"], group = grp_4) nPrice = math.max(math.min(Pricea_n, 100), -100) nVol = math.max(math.min(Vola_n, 100), -100) bar = bar_flow c_vol_grn = color.new(#26a69a, 75) c_vol_red = color.new(#ef5350, 75) cb_vol_grn = color.new(#26a69a, 20) cb_vol_red = color.new(#ef5350, 20) c_vol = bar > 0 ? c_vol_grn : c_vol_red cb_vol = bar > 0 ? cb_vol_grn : cb_vol_red vc_lo = 0 vc_hi = nVol * bandscale / 100 / 2 plotcandle(vc_lo, vc_hi, vc_lo, vc_hi , "Volume Band", c_vol, c_vol, bordercolor = cb_vol, display = DispBands) c_pri_grn = color.new(#3ed73e, 75) c_pri_red = color.new(#ff870a, 75) cb_pri_grn = color.new(#3ed73e, 20) cb_pri_red = color.new(#ff870a, 20) c_pri = bar > 0 ? c_pri_grn : c_pri_red cb_pri = bar > 0 ? cb_pri_grn : cb_pri_red pc_lo_base = Eq_band_option == "Joint" ? vc_hi : 0.50 * bandscale pc_lo = pc_lo_base pc_hi = pc_lo_base + math.abs(nPrice) * bandscale / 100 / 2 plotcandle(pc_lo, pc_hi, pc_lo ,pc_hi , "Price Band", c_pri, c_pri, bordercolor = cb_pri, display = DispBands) // print the normalized volume and price values - only on statys line and in the data window // these values are independant of the band scale or visualization options plotchar(nVol, "Normalized Vol", char = "", color = c_vol, editable = false, display = Disp_vals) plotchar(nPrice, "Normalized Price", char = "", color = c_pri, editable = false, display = Disp_vals) // ============================================================================= // ============================================================================= // Plot main plot, smoothed plot and signal line plot(RROF, 'RROF Raw', color.new(#2470f0, 9), display=display.none) plot(RROF_s, 'RROF Smooth', color = color.new(#b2b5be,40), linewidth = 2) plot(Signal, "Signal Line", up ? c_up : c_dn, 3) // =========================================================================================================== // basic alerts // =========================================================================================================== Alert_up = ta.crossover(RROF_s,0) Alert_dn = ta.crossunder(RROF_s,0) Alert_swing = ta.cross(RROF_s,0) // "." in alert title for the alerts to show in the right order up/down/swing alertcondition(Alert_up, ". RROF Crossing 0 Up", "RROF Up - Buying Action Detected!") alertcondition(Alert_dn, ".. RROF Crossing 0 Down", "RROF Down - Selling Action Detected!") alertcondition(Alert_swing, "... RROF Crossing 0", "RROF Swing - Possible Reversal") // =========================================================================================================== // v2.0 Adding Markers for Key Patterns // =========================================================================================================== // we can re-utilize the Normailize() function here too - but it's cleaner to have a separate ratio calc nPrice_abs = math.abs(nPrice) //EV_Ratio = 100 * Normalize(nPrice_abs, nVol) EV_Ratio = 100 * nPrice_abs / nVol // initial mapping of return ratios (to be revised) // ------------------------------------------------------- // Case (1): Price > Vol => ratio > 120 = Ease of Move (EoM) // Case (2): Price close to Vol => ratio between 80 - 120 = Reasonable Balance // Case (3): Price less than Vol but reasonable => ratio between 80 - 50 = Drift / "nothing much to see here" bar // Case (4): Price a lot less than Vol => 50 or less = Compression / Squat // we're most interested in cases 1 & 4 //plot (EV_Ratio) // for validation only is_positive = nPrice > 0 is_Compression = EV_Ratio <= 50 is_EoM = EV_Ratio >= 120 //Provide option to show/hide those EVEREX Markers - and an option for Compression bar // - some folks would prefer a cross, others may prefer a circle - can adjust based on feedback // no option for Ease of Move, guessing the triangle has the right significance var showMarkers = input.bool(true, 'Show EVEREX Markers ?') var Mshape = input.string("Circles", "Compression Marker", options = ['Circles','Crosses']) SetShape(_x) => switch _x 'Circles' => shape.circle 'Crosses' => shape.cross // Plot markers plotshape(showMarkers and is_EoM and is_positive ? 0 : na, "EoM +ve", shape.triangleup, color=color.green, location=location.absolute, size=size.auto, editable = false, display = display.pane) plotshape(showMarkers and is_EoM and not(is_positive) ? 0 : na, "EoM -ve", shape.triangledown, color=color.red, location=location.absolute, size=size.auto, editable = false, display = display.pane) plotshape(showMarkers and is_Compression and is_positive ? 0 : na, "Compression +ve", style = SetShape(Mshape), color=color.green, location=location.absolute, size = size.auto, editable = false, display = display.pane) plotshape(showMarkers and is_Compression and not(is_positive) ? 0 : na, "Compression -ve", style = SetShape(Mshape), color=color.red, location=location.absolute, size=size.auto, editable = false, display = display.pane)
프로필 이미지
센스짱
2023-11-22
1937
글번호 174288
지표
답변완료

계좌번호 지정 매매에 대해 문의드립니다.

안녕하세요~늘 훌륭한 답변에 진심으로 감사드리며 다음과 같이 문의드립니다. 초보입니다. if GetAccount(0)=="200-00-000000" Then { if 진입조건 then Buy("B",OnClose, Def,1); } 가령 이런식으로 산식에 계좌를 특정할 수 있는지요? 실시간 그리고 전략실행차트 상에서 만 가능한가요? 안되네요. 산식에서 계좌를 특정할 수 있는 방법이 있으면 부탁드립니다. 감사합니다~
프로필 이미지
ash
2023-11-22
1357
글번호 174287
시스템
답변완료

문의드립니다...

highest(v(1),200)<v and highest(h,3) 여기서 200 수치는 period(기간)입니다.. 위수식은 키움분봉상신호검색인데 예스에서 분봉기준 종목검색 부탁드립니다...
프로필 이미지
서민순
2023-11-22
1163
글번호 174274
검색
답변완료

수정 부탁드립니다.

안녕하세요. 아래 수식에서 TL_SetColor(TL1,Red); TL_SetColor(TL2,magenta); TL_SetColor(TL3,Gray); 라인 두깨를 표기할 수 있도록 부탁드립니다. 거듭 감사드립니다. 좋은 시간되세요. =========================== input : P1(2),P2(3),P3(5); var : cnt(0),d1(0); var : sum1(0),sum2(0),sum3(0),mav1(0),mav2(0),mav3(0); var : TL1(0),TL2(0),TL3(0); Array : C2[100](0); if data2(Bdate != Bdate[1]) Then { For cnt = 99 DownTo 1 { C2[cnt] = C2[cnt-1]; TL_Delete(TL1[cnt]); TL_Delete(TL2[cnt]); TL_Delete(TL3[cnt]); } C2[0] = Data2(c); sum1 = 0; sum2 = 0; sum3 = 0; For cnt = 0 to max(P1,P2,P3) { if cnt < P1 Then sum1 = sum1 + C2[cnt]; if cnt < P2 Then sum2 = sum3 + C2[cnt]; if cnt < P3 Then sum3 = sum3 + C2[cnt]; } mav1 = sum1/P1; mav2 = sum2/P2; mav3 = sum3/P3; d1 = Data2(Bdate[1]); TL1 = TL_New_Self(d1,150000,mav1,sDate,sTime,mav1); TL2 = TL_New_Self(d1,150000,mav2,sDate,sTime,mav2); TL3 = TL_New_Self(d1,150000,mav3,sDate,sTime,mav3); TL_SetColor(TL1,Red); TL_SetColor(TL2,magenta); TL_SetColor(TL3,Gray); } Else { C2[0] = Data2(c); TL_SetEnd(TL1,NextBarSdate,NextBarStime,mav1); TL_SetEnd(TL2,NextBarSdate,NextBarStime,mav2); TL_SetEnd(TL3,NextBarSdate,NextBarStime,mav3); } Plot1(Data2(OpenD(0)),"시가라인");
프로필 이미지
포보스
2023-11-22
942
글번호 174273
지표
답변완료

문의

선물시간 8시45분 시작으로 기존 사용하던 수식에 오류가 생겼습니다. input : d2(1000); if Data2(c>lowd(0)+d2) Then Buy(); 기존에는 위 수식으로 아래 내용을 모두 해결하였는데 data1 코스피200선물 data2 외인주식순매수금액 data1 코스피200선물 data2 외인선물순매수금액 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 문제가 발생하였습니다. data1 코스피200선물 084500(3분봉) 시작 data2 외인주식순매수금액 090000(3분봉) 시작 코스피선물과 외인주식순매수금액이 시작하는 시간이 다르기 때문에 8시45분 첫봉에서 이유 없이 진입하는 경우가 자주 발생합니다. 외인주식순매수금액 봉이 9시부터 발생하므로 그 이후부터 계산하여 진입할 수 있도록 수정바랍니다. 요청사항 1. 수정할 수식입니다.(d2는 외국인주식순매수금액) input : d2(1000); if Data2(c>lowd(0)+d2) Then Buy(); 요청사항 2. 외국인순매수금액을 제외조건에 사용한 수식에서도 영향이 있을 것 같아서 추가로 수정 요청드리는 수식입니다. (d2는 외국인주식순매수금액) input : d3(1000),d2(500); if Data3(c>lowd(0)+d3) and !(data2(c<highd(0)-d2)) Then Buy();
프로필 이미지
목마와숙녀
2023-11-22
982
글번호 174271
시스템