커뮤니티

예스랭귀지 Q&A

글쓰기

[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내

안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
프로필 이미지
예스스탁
2026-02-27
1305
글번호 230811
지표
답변완료

부탁드립니다

아래글에 답변감사드립니다. 그런데 매수신호가 나지않습니다. 아래수식에 매일오후3시5분 추가매수식수정부탁드립니다. input : short1(12),long1(26),sig1(9); input : period(20); input : Per(10); var : MACDO1(0,Data1),Mav2(0,Data2); var : tt(0,Data1),t1(0,Data1),entry(0,Data1); MACDO1 = Data1(MACD_OSC(short1,long1,sig1)); Mav2 = Data2(ma(C,period)); tt = TotalTrades; if Data1(Bdate != Bdate[1]) Then t1 = tt[1]; entry = tt-t1+IFf(MarketPosition!=0,1,0); if MarketPosition == 0 and Data2(CrossUp(c,Mav2)) and entry < 1 and sTime >= 150500 and sTime <= 151000 Then Buy(); if MarketPosition == 1 Then { if data1(CrossDown(MACDO1,0)) Then ExitLong("bx1",OnClose,Def,"",Ceiling(MaxContracts*(Per/100)/10)*10,2); if data2(CrossDown(c,Mav2)) Then ExitLong("bx2"); }
프로필 이미지
2685up
2025-06-20
256
글번호 191971
시스템
답변완료

지표로 전환 부탁드려요

건강하세요 var : aa(0),bb(0),a(0),b(0),av(0),bv(0),d(0),e(0),f(0),g(0); var : bf(0),sf(0),pbf(0),psf(0),bfh(0),SFH(0); aa=C-(H+L)/2; bb=(O+C+H+L+Iff(0<=aa,(C+H)/2,(C+L)/2))/5; A=Accum(Iff(0<=aa,bb*V,0)); B=Accum(Iff(aa<0,bb*V,0)); AV=Accum(Iff(0<=aa,V,0)); BV=Accum(Iff(aa<0,V,0)); if sDate != sDate[1] Then { D=A[1]; E=B[1]; F=AV[1]; G=BV[1]; } BF=(A-D)/(AV-F); SF=(B-E)/(BV-G); PBF=Iff(0<BF,BF,bb); PSF=Iff(0<SF,SF,bb); IF PBF>PSF && CROSSUP(C, PBF) && C>O TheN Find(1);
프로필 이미지
뽀스뽀스
2025-06-20
287
글번호 191964
지표
답변완료

수식 부탁드립니다

지표식 부탁 드립니다. //@version=5 indicator(title='Machine Learning Momentum Index (MLMI)', shorttitle='Machine Learning Momentum Index (MLMI)', overlay=false, precision=1) // ~~ ToolTips { t1 ="This parameter controls the number of neighbors to consider while making a prediction using the k-Nearest Neighbors (k-NN) algorithm. By modifying the value of k, you can change how sensitive the prediction is to local fluctuations in the data. ₩n₩nA smaller value of k will make the prediction more sensitive to local variations and can lead to a more erratic prediction line. ₩n₩nA larger value of k will consider more neighbors, thus making the prediction more stable but potentially less responsive to sudden changes." t2 ="The parameter controls the length of the trend used in computing the momentum. This length refers to the number of periods over which the momentum is calculated, affecting how quickly the indicator reacts to changes in the underlying price movements. ₩n₩nA shorter trend length (smaller momentumWindow) will make the indicator more responsive to short-term price changes, potentially generating more signals but at the risk of more false alarms. ₩n₩nA longer trend length (larger momentumWindow) will make the indicator smoother and less responsive to short-term noise, but it may lag in reacting to significant price changes." //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Input Parameters { numNeighbors = input(200, title='Prediction Data (k)', tooltip=t1) momentumWindow = input.int(20, step=2, minval=10, maxval=200, title='Trend Length', tooltip=t2) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Moving Averages & RSI { MA_quick = ta.wma(close, 5) MA_slow = ta.wma(close, 20) rsi_quick = ta.wma(ta.rsi(close, 5),momentumWindow) rsi_slow = ta.wma(ta.rsi(close, 20),momentumWindow) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Crossover Conditions { pos = ta.crossover(MA_quick, MA_slow) neg = ta.crossunder(MA_quick, MA_slow) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Type Definition { type Data array<float> parameter1 array<float> parameter2 array<float> priceArray array<float> resultArray // Create a Data object var data = Data.new(array.new_float(1, 0), array.new_float(1, 0), array.new_float(1, 0), array.new_float(1, 0)) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Method that saves the last trade and temporarily holds the current one. { method storePreviousTrade(Data d, p1, p2) => d.parameter1.push(d.parameter1.get(d.parameter1.size() - 1)) d.parameter2.push(d.parameter2.get(d.parameter2.size() - 1)) d.priceArray.push(d.priceArray.get(d.priceArray.size() - 1)) d.resultArray.push(close >= d.priceArray.get(d.priceArray.size() - 1) ? 1 : -1) d.parameter1.set(d.parameter1.size() - 1, p1) d.parameter2.set(d.parameter2.size() - 1, p2) d.priceArray.set(d.priceArray.size() - 1, close) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Method to Make Prediction { method knnPredict(Data d, p1, p2, k) => // Create a Distance Array distances = array.new_float(0) n = d.parameter1.size() - 1 for i = 0 to n distance = math.sqrt(math.pow(p1 - d.parameter1.get(i), 2) + math.pow(p2 - d.parameter2.get(i), 2)) distances.push(distance) // Get Neighbors sortedDistances = distances.copy() sortedDistances.sort() 셀렉티드Distances = sortedDistances.slice( 0, math.min(k, sortedDistances.size())) maxDist = 셀렉티드Distances.max() neighbors = array.new_float(0) for i = 0 to distances.size() - 1 if distances.get(i) <= maxDist neighbors.push(d.resultArray.get(i)) // Return Prediction prediction = neighbors.sum() prediction if pos or neg data.storePreviousTrade(rsi_slow, rsi_quick) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Plots { prediction = data.knnPredict(rsi_slow, rsi_quick, numNeighbors) prediction_ = plot(prediction, color=color.new(#426eff, 0), title="MLMI Prediction") prediction_ma = ta.wma(prediction, 20) plot(prediction_ma, color=color.new(#31ffc8, 0), title="WMA of MLMI Prediction") hline(0, title="Mid Level") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Gradient Fill { upper = ta.highest(prediction,2000) lower = ta.lowest(prediction,2000) upper_ = upper - ta.ema(ta.stdev(prediction,20),20) lower_ = lower + ta.ema(ta.stdev(prediction,20),20) channel_upper = plot(upper, color = na, editable = false, display = display.none) channel_lower = plot(lower, color = na, editable = false, display = display.none) channel_mid = plot(0, color = na, editable = false, display = display.none) // ~~ Channel Gradient Fill { fill(channel_mid, channel_upper, top_value = upper, bottom_value = 0, bottom_color = na, top_color = color.new(color.lime,75),title = "Channel Gradient Fill") fill(channel_mid, channel_lower, top_value = 0, bottom_value = lower, bottom_color = color.new(color.red,75) , top_color = na,title = "Channel Gradient Fill") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Overbought/Oversold Gradient Fill { fill(prediction_, channel_mid, upper, upper_, top_color = color.new(color.lime, 0), bottom_color = color.new(color.green, 100),title = "Overbought Gradient Fill") fill(prediction_, channel_mid, lower_, lower, top_color = color.new(color.red, 100), bottom_color = color.new(color.red, 0),title = "Oversold Gradient Fill")
프로필 이미지
사노소이
2025-06-20
500
글번호 191959
지표
답변완료

진입횟수 조절

안녕하세요 일 진입횟수를 1~10회까지 변경 적용할 수 있도록 수식 부탁드리빈다. 진입 수식은 매수 crossup(C,H[10]) then buy 매도 crossdown(C, L[10]) then sell 이 두가지로 적용해주시면 됩니다.
프로필 이미지
소드노
2025-06-20
252
글번호 191952
시스템
답변완료

부틱드립니다

수고하십니다 매번 부탁드려서 죄송합니다 예스로 변경드립니다 // This Pine S cript™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // &#169; ChartPrime //@version=5 indicator('Linear Regression Channel', overlay = true, max_lines_count = 3) // ---------------------------------------------------------------------------------------------------------------------} // &#120400;&#120398;&#120384;&#120397; &#120388;&#120393;&#120395;&#120400;&#120399;&#120398; // ---------------------------------------------------------------------------------------------------------------------{ bool bands = input.bool(true, "Plot Linear Regression Bands", group = "Settings Bands") int window = input.int(150, "Length", group = "Settings Bands") float devlen_b = input.float(3., "Deviation Linear Regression Bands",step=0.1, group = "Settings Bands") bool channel = input.bool(false, "Plot Linear Regression Channel", group = "Settings Channel") int window1 = input.int(150, "Channel Length", group = "Settings Channel") float devlen1 = input.float(1., "Deviation Linear Regression Channel",step=0.1, group = "Settings Channel") bool channel1 = input.bool(false, "Plot Future Projection of linear regression", group = "Future Projection Channel") bool arr_dirc = input.bool(false, "Plot Arrow Direction", group = "Future Projection Channel") int window2 = input.int(50, "Length", group = "Future Projection Channel") float devlen2 = input.float(1., "Deviation Future Projection Regression Channel",step=0.1, group = "Future Projection Channel") // Define colors for up, down, and mid lines color col_dn = #f01313 color col_up = color.aqua color col_mid = color.yellow color gray = color.gray color fg_col = chart.fg_color // Regression Channel Arrays Line var reglines = array.new_line(3) var reglines_ = array.new_line(3) // ---------------------------------------------------------------------------------------------------------------------} // &#120388;&#120393;&#120383;&#120388;&#120382;&#120380;&#120399;&#120394;&#120397; &#120382;&#120380;&#120391;&#120382;&#120400;&#120391;&#120380;&#120399;&#120388;&#120394;&#120393;&#120398; // ---------------------------------------------------------------------------------------------------------------------{ //@function linear_regression //@des cription Calculates linear regression coefficients for a given source and window. //@param src (series float) The data series on which linear regression is calculated. //@param window (int) The number of bars to use in the calculation. //@returns the intercept slope, Deviation, end of the channel. linear_regression(src, window) => sum_x = 0.0 sum_y = 0.0 sum_xy = 0.0 sum_x_sq = 0.0 // Calculate sums for i = 0 to window - 1 by 1 sum_x += i + 1 sum_y += src[i] sum_xy += (i + 1) * src[i] sum_x_sq += math.pow(i + 1, 2) // Calculate linear regression coefficients slope = (window * sum_xy - sum_x * sum_y) / (window * sum_x_sq - math.pow(sum_x, 2)) intercept = (sum_y - slope * sum_x) / window y1 = intercept + slope * (window - 1) dev = 0.0 for i = 0 to window - 1 dev := dev + math.pow(src[i] - (slope * (window - i) + intercept), 2) dev := math.sqrt(dev/window) [intercept, y1, dev, slope] [y2, y1, dev, slope] = linear_regression(close, window) [y2_, y1_, dev_, slope_] = linear_regression(close, window1) [y2__, y1__, dev__, slope__] = linear_regression(close, window2) // Linear Regression Channel Lines series float mid = y2 + slope series float upper = mid + ta.rma(high - low, window) * devlen_b series float lower = mid - ta.rma(high - low, window) * devlen_b // Returns True for window length period isAllowed = (last_bar_index - bar_index < window1) // ---------------------------------------------------------------------------------------------------------------------} // &#120401;&#120388;&#120398;&#120400;&#120380;&#120391;&#120388;&#120405;&#120380;&#120399;&#120388;&#120394;&#120393; // ---------------------------------------------------------------------------------------------------------------------{ // Plot upper, lower, and mid lines if channel is not enabled p_u = plot(upper, color = bands and channel ? na : bands ? gray : na, linewidth = 2) p_l = plot(lower, color = bands and channel ? na : bands ? gray : na, linewidth = 2) p_m = plot(mid, color = bands and channel ? na : bands ? gray : na) // Fill areas between upper/mid and lower/mid lines fill(p_u, p_m, mid, upper, na, bands and channel ? na : bands ? color.new(col_up, 80) : na) fill(p_m, p_l, lower, mid, bands and channel ? na : bands ? color.new(col_dn, 80) : na, na) if barstate.islast and channel for i = 0 to 2 array.set(reglines, i, line.new(x1 = bar_index - (window1 - 1), y1 = y1_ + dev_ * devlen1 * (i - 1), x2 = bar_index, y2 = y2_ + dev_ * devlen1 * (i - 1), color = color.gray, style = i % 2 == 1 ? line.style_dashed : line.style_solid, width = 2, extend = extend.none) ) linefill.new(array.get(reglines, 1), array.get(reglines, 2), color = color.new(col_up, 90)) linefill.new(array.get(reglines, 1), array.get(reglines, 0), color = color.new(col_dn, 90)) if barstate.islast and channel1 for i = 0 to 2 array.set(reglines_, i, line.new(x1 = bar_index - (window2 - 1), y1 = y1__ + dev__ * devlen2 * (i - 1), x2 = bar_index, y2 = y2__ + dev__ * devlen2 * (i - 1), color = color.gray, style = i % 2 == 1 ? line.style_dotted : line.style_dashed, width = 1, extend = extend.right) ) linefill.new(array.get(reglines_, 1), array.get(reglines_, 2), color = color.new(col_up, 95)) linefill.new(array.get(reglines_, 1), array.get(reglines_, 0), color = color.new(col_dn, 95)) if arr_dirc l1 = label.new(chart.point.from_index(bar_index, hl2 > y2__ ? high : low), text = hl2 > y2__ ? "&#8663;" : hl2 < y2__ ? "&#8664;" : "⇒", textcolor = hl2 > y2__ ? col_up : hl2 < y2__ ? col_dn : gray, color = color(na), size = size.huge, style = label.style_label_left ) label.delete(l1[1]) // Bar Heat Map b_c = (close - lower) / (upper - lower) b_c := b_c > 1 ? 1 : b_c < 0 ? 0 : b_c bar_color = channel ? (isAllowed ? (b_c <= 0.5 ? color.from_gradient(b_c, 0, 0.5, col_up, col_mid) : color.from_gradient(b_c, 0.5, 1, col_mid, col_dn)) : na) : (b_c >= 0.5 ? color.from_gradient(b_c, 0.5, 1, col_mid, col_up) : color.from_gradient(b_c, 0, 0.5, col_dn, col_mid)) plotcandle(open, high, low, close, title = "Bar HeatMap", color = bar_color, wickcolor = bar_color, bordercolor = bar_color ) barcolor(bar_color) // Conditions for crossovers condition1 = bands and channel ? na : bands ? ta.pivotlow(3, 3) and close < lower : na condition2 = bands and channel ? na : bands ? ta.pivothigh(3, 3) and close > upper: na // Plot markers for channel break outs plotchar(condition1, "", "◆", size=size.tiny, location=location.belowbar, color = col_up) plotchar(condition2, "", "◆", size=size.tiny, location=location.abovebar, color = col_dn) // ------------------------------------------------------------------------------------
프로필 이미지
파생돌이
2025-06-20
431
글번호 191951
지표
답변완료

종목검색식 부탁드림니다.

항상 노고에 감사드림니다. 아래의 수식을 종목검색식으로 부탁드림니다. A=wavg(2*wavg(scr,len/2) - wavg(scr,len), floor(sqrt(len))); A>A(1) && A(1)<A(2); A1=MM=MA(C, 기간1, 종류); MN=MA(C, 기간2, 종류); 조건=CrossUp(MM, MN); Valuewhen(1, 조건, H); Crossup(C, A, A1) 지표변수 scr 종가 len 49 기간1 5 기간2 20 종류 가중
프로필 이미지
존슨비치
2025-06-20
300
글번호 191950
종목검색
답변완료

트레이딩뷰 지표 변환 요청

트레이딩뷰 지표소스로 종목 검색식을 만들고 싶은데 가능할까요? 지표상 Buy 신호 종목 검색을 하고 싶습니다. //@version=4 study("Hull Trend", shorttitle="HMA Trend",overlay=true) length = input(24) src = input(hl2) showcross = input(true, "Show cross over/under") hma(_src, _length)=> wma((2 * wma(_src, _length / 2)) - wma(_src, _length), round(sqrt(_length))) hma3(_src, _length)=> p = length/2 wma(wma(close,p/3)*3 - wma(close,p/2) - wma(close,p),p) a = hma(src, length) b = hma3(src, length) c = b > a ? color.lime : color.red p1 = plot(a,color=c,linewidth=1,transp=75) p2 = plot(b,color=c,linewidth=1,transp=75) fill(p1,p2,color=c,transp=55) crossdn = a > b and a[1] < b[1] crossup = b > a and b[1] < a[1] plotshape(showcross and crossdn ? a : na, location=location.absolute, style=shape.labeldown, color=color.red, size=size.tiny, text="Sell", textcolor=color.white, transp=0, offset=-1) plotshape(showcross and crossup ? a : na, location=location.absolute, style=shape.labelup, color=color.green, size=size.tiny, text="Buy", textcolor=color.white, transp=0, offset=-1)
프로필 이미지
무서운라냐
2025-06-20
374
글번호 191949
종목검색
답변완료

수식변환요청

수고 많으십니다 다음 수식 변환 부탁드립니다 A=avg(V,5); B1=( (avg(ma(v, n, 단순),Period)+D*stdev(ma(v, n, 단순),Period)) - (avg(ma(v, n, 단순),Period)-D*stdev(ma(v, n, 단순),Period))) / avg(ma(v, n, 단순),Period); 조건=V>A && B1>=비율1 조건 && !조건(1)
프로필 이미지
김승빈
2025-06-20
289
글번호 191948
종목검색
답변완료

부틱드립니다

수고하십니다 예스로 부탁드립니다 // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // &#169; LuxAlgo //@version=5 indicator("Order Block Detector [LuxAlgo]" , overlay = true , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ length = input.int(5, 'Volume Pivot Length' , minval = 1) bull_ext_last = input.int(3, 'Bullish OB&#8196;' , minval = 1 , inline = 'bull') bg_bull_css = input.color(color.new(#169400, 80), '' , inline = 'bull') bull_css = input.color(#169400, '' , inline = 'bull') bull_avg_css = input.color(color.new(#9598a1, 37), '' , inline = 'bull') bear_ext_last = input.int(3, 'Bearish OB' , minval = 1 , inline = 'bear') bg_bear_css = input.color(color.new(#ff1100, 80), '' , inline = 'bear') bear_css = input.color(#ff1100, '' , inline = 'bear') bear_avg_css = input.color(color.new(#9598a1, 37), '' , inline = 'bear') line_style = input.string('&#9135;&#9135;&#9135;', 'Average Line Style' , options = ['&#9135;&#9135;&#9135;', '----', '····']) line_width = input.int(1, 'Average Line Width' , minval = 1) mitigation = input.string('Wick', 'Mitigation Methods' , options = ['Wick', 'Close']) //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ //Line Style function get_line_style(style) => out = switch style '&#9135;&#9135;&#9135;' => line.style_solid '----' => line.style_dashed '····' => line.style_dotted //Function to get order block coordinates get_coordinates(condition, top, btm, ob_val)=> var ob_top = array.new_float(0) var ob_btm = array.new_float(0) var ob_avg = array.new_float(0) var ob_left = array.new_int(0) float ob = na //Append coordinates to arrays if condition avg = math.avg(top, btm) array.unshift(ob_top, top) array.unshift(ob_btm, btm) array.unshift(ob_avg, avg) array.unshift(ob_left, time[length]) ob := ob_val [ob_top, ob_btm, ob_avg, ob_left, ob] //Function to remove mitigated order blocks from coordinate arrays remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=> mitigated = false target_array = bull ? ob_btm : ob_top for element in target_array idx = array.indexof(target_array, element) if (bull ? target < element : target > element) mitigated := true array.remove(ob_top, idx) array.remove(ob_btm, idx) array.remove(ob_avg, idx) array.remove(ob_left, idx) mitigated //Function to set order blocks set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=> var ob_box = array.new_box(0) var ob_lvl = array.new_line(0) //Fill arrays with boxes/lines if barstate.isfirst for i = 0 to ext_last-1 array.unshift(ob_box, box.new(na,na,na,na , xloc = xloc.bar_time , extend= extend.right , bgcolor = bg_css , border_color = color.new(border_css, 70))) array.unshift(ob_lvl, line.new(na,na,na,na , xloc = xloc.bar_time , extend = extend.right , color = lvl_css , style = get_line_style(line_style) , width = line_width)) //Set order blocks if barstate.islast if array.size(ob_top) > 0 for i = 0 to math.min(ext_last-1, array.size(ob_top)-1) get_box = array.get(ob_box, i) get_lvl = array.get(ob_lvl, i) box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i)) box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i)) line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i)) line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i)) //-----------------------------------------------------------------------------} //Global elements //-----------------------------------------------------------------------------{ var os = 0 var target_bull = 0. var target_bear = 0. n = bar_index upper = ta.highest(length) lower = ta.lowest(length) if mitigation == 'Close' target_bull := ta.lowest(close, length) target_bear := ta.highest(close, length) else target_bull := lower target_bear := upper os := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1] phv = ta.pivothigh(volume, length, length) //-----------------------------------------------------------------------------} //Get bullish/bearish order blocks coordinates //-----------------------------------------------------------------------------{ [bull_top , bull_btm , bull_avg , bull_left , bull_ob] = get_coordinates(phv and os == 1, hl2[length], low[length], low[length]) [bear_top , bear_btm , bear_avg , bear_left , bear_ob] = get_coordinates(phv and os == 0, high[length], hl2[length], high[length]) //-----------------------------------------------------------------------------} //Remove mitigated order blocks //-----------------------------------------------------------------------------{ mitigated_bull = remove_mitigated(bull_top , bull_btm , bull_left , bull_avg , target_bull , true) mitigated_bear = remove_mitigated(bear_top , bear_btm , bear_left , bear_avg , target_bear , false) //-----------------------------------------------------------------------------} //Display order blocks //-----------------------------------------------------------------------------{ //Set bullish order blocks set_order_blocks(bull_top , bull_btm , bull_left , bull_avg , bull_ext_last , bg_bull_css , bull_css , bull_avg_css) //Set bearish order blocks set_order_blocks(bear_top , bear_btm , bear_left , bear_avg , bear_ext_last , bg_bear_css , bear_css , bear_avg_css) //Show detected order blocks plot(bull_ob, 'Bull OB', bull_css, 2, plot.style_linebr , offset = -length , display = display.none) plot(bear_ob, 'Bear OB', bear_css, 2, plot.style_linebr , offset = -length , display = display.none) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ alertcondition(bull_ob, 'Bullish OB Formed', 'Bullish order block detected') alertcondition(bear_ob, 'Bearish OB Formed', 'bearish order block detected') alertcondition(mitigated_bull, 'Bullish OB Mitigated', 'Bullish order block mitigated') alertcondition(mitigated_bear, 'Bearish OB Mitigated', 'bearish order block mitigated') //-----------------------------------------------------------------------------}
프로필 이미지
파생돌이
2025-06-20
435
글번호 191947
지표