커뮤니티

예스랭귀지 Q&A

글쓰기

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

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

문의드립니다

var : tx(0); Text_Delete(tx); tx = Text_New(NextBarSdate,NextBarStime,NextBarOpen,NumToStr(NextBarOpen,2)); Text_SetStyle(tx,0,0); ============== 참조종목 분봉시가표시 수식 좀 알려주세요 감사합니다
프로필 이미지
러블리
2025-05-21
298
글번호 191046
지표
답변완료

문의드립니다.

아래의 트레이딩뷰 수식을 변환부탁드립니다. =========================== // Settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - supertrendAtrPeriod &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=input.int (defval =10 ,step =1 ,title ="ATR Length",group ="Supertrend") supertrendAtrMultiplier &#160;&#160;&#160;&#160;&#160;&#160;=input.float (defval =2.7 ,step =0.1 ,title ="ATR Multiplier",group ="Supertrend") // &#160;Heikin Ashi Candles haOpen =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,open ) haHigh =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,high ) haLow =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,low ) haClose =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,close ) plotcandle (haOpen <haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Green Candles',color =green ,wickcolor =green ,bordercolor =green ,display =display.pane ) plotcandle (haOpen >=haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Red Candles',color =red ,wickcolor =red ,bordercolor =red ,display =display.pane ) plot (display =display.status_line ,series =haOpen ,color =green ) plot (display =display.status_line ,series =haHigh ,color =green ) plot (display =display.status_line ,series =haLow ,color =red ) plot (display =display.status_line ,series =haClose ,color =red ) // &#160;HA Supertrend haTrueRange =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,ta.atr (supertrendAtrPeriod ))// math.max(haHigh - haLow, math.abs(haHigh - haClose[1]), math.abs(haLow - haClose[1])) haSupertrendUp =((haHigh +haLow )/2 )-(supertrendAtrMultiplier *haTrueRange ) haSupertrendDown =((haHigh +haLow )/2 )+(supertrendAtrMultiplier *haTrueRange ) float trendingUp =na float trendingDown =na direction =0 trendingUp :=haClose [1 ]>trendingUp [1 ]?math.max (haSupertrendUp ,trendingUp [1 ]):haSupertrendUp trendingDown :=haClose [1 ]<trendingDown [1 ]?math.min (haSupertrendDown ,trendingDown [1 ]):haSupertrendDown direction :=haClose >trendingDown [1 ]?1 :haClose <trendingUp [1 ]?-1 :nz (direction [1 ],1 ) supertrend =direction ==1 ?trendingUp :trendingDown supertrendUp =ta.change (direction )<0 supertrendDown =ta.change (direction )>0 // &#160;Plots, Lines, and Labels bodyMiddle =plot ((haOpen +haClose )/2 ,display =display.none ) downTrend =plot (direction <0 ?supertrend :na ,"Down Trend",color =red ,style =plot.style_linebr ) upTrend =plot (direction <0 ?na :supertrend ,"Up Trend",color =green ,style =plot.style_linebr ) fill (bodyMiddle ,upTrend ,lightGreen ,fillgaps =false ) fill (bodyMiddle ,downTrend ,lightRed ,fillgaps =false ) ========================= 첨부된 그림처럼 빨강선과 녹색선을 표현하고자 합니다. atr길이와 atr배수을 변경할수 있게 부탁드립니다. 수식이 길어서 전략은 삭제하고 라인만 나타나보이게 올렸으니 감안하여 부족한 부분이 있다면 보완해주셔서 변환해주시면 더욱 감사하겠습니다. 오늘도 감사합니다. 수고하세요!!!
프로필 이미지
해암
2025-05-21
335
글번호 191045
지표

사공하늘 님에 의해서 삭제되었습니다.

프로필 이미지
사공하늘
2025-05-21
200
글번호 191044
검색
답변완료

수식 의뢰 드립니다.

안녕하세요! 콜과풋 교차차트에서 콜 1종목에만 당일 저가와 고가의 수식을 아래와 같이 적용했는데 콜과풋 모두에게 적용이 됩니다! 혹시 콜이나 풋 한종목에만 적용시키고 배경색을 넣을 수 있는지요? var1 = DayHigh; var2 = DayLow; Plot1(DayHigh,"당일고가"); Plot2(DayLow,"당일저가");
프로필 이미지
qha71
2025-05-21
237
글번호 191043
지표

와우리 님에 의해서 삭제되었습니다.

프로필 이미지
와우리
2025-05-21
51
글번호 191035
지표

사공하늘 님에 의해서 삭제되었습니다.

프로필 이미지
사공하늘
2025-05-21
74
글번호 191029
검색
답변완료

문의드립니다.

안녕하세요 항상 감사드립니다. 아래의 서식에서 추가적인 서식을 부탁드립니다. *추가사항 1.전일 대비 갭상승(하락)시 진입 금지. 갭의 값은 3pt로 해주시고, 추후 최적화를 하여 결정할 예정입니다. 최적화를 할 수 있도록 input으로 넣어주시기 바랍니다. # KOSPI 선물 10분봉 input: tt(150000),당일진입횟수(3); var: chkP(10), reChkP(20), stopChk(25); var: HH(0), LL(0), BS(0), SS(0); var: dayChk(0); var : TotalCount(0),PreDay(0),DayEntry(0); TotalCount = TotalTrades; if Bdate != Bdate[1] Then PreDay = TotalCount[1]; DayEntry = (TotalCount-PreDay)+IFF(MarketPosition != 0,1,0); if BarIndex == 0 then ClearDebug(); if dayindex == chkP then { HH = Highest(Max(C,O), chkP+1); LL = Lowest(Min(C,O), chkP+1); #if date == 20240612 then messageLog("--HH %.2f, LL: %.2f", HH, LL); } #if High >= HH and MarketPosition == 0 and ExitDate(1) < Date and time > 93000 then messageLog("HH %.2f, High: %.2f", HH, High); if DayIndex >= chkP # and Time < 95000 and sDate == NextBarSdate and EntryDate(0) < Date and EntryDate(1) < Date and DayEntry < 당일진입횟수 Then { Buy("B1", AtStop, HH); Sell("S1", AtStop, LL); } //if dayChk == 0 and High >= HH and MarketPosition == 0 and ExitDate(1) < Date and time > 93000 then { // messageLog("HH %.2f, High: %.2f", HH, High); // dayChk = 1; //} if ExitDate(1) == Date and Time < 150000 // and LatestEntryName(1) != "B2" // and LatestEntryName(1) != "S2" // and LatestEntryName(0) != "B2" // and LatestEntryName(0) != "S2" Then { if DayIndex < reChkP Then { HH = Highest(Max(C,O), DayIndex+1); LL = Lowest(Min(C,O), DayIndex+1); } Else { HH = Highest(Max(C,O), reChkP); LL = Lowest(Min(C,O), reChkP); } if DayEntry < 당일진입횟수 Then { Buy("B2", AtStop, HH); Sell("S2", AtStop, LL); } } if (MarketPosition == 1) Then { if DayIndex < stopChk Then { BS = Lowest(Min(C,O), DayIndex+1); } Else { BS = Lowest(Min(C,O), stopChk); } ExitLong("EL", AtStop, BS); } if (MarketPosition == -1) Then { if DayIndex < stopChk Then { SS = Highest(Max(C,O), DayIndex+1); } Else { SS = Highest(Max(C,O), stopChk); } #messageLog(" SS %.2f", SS); ExitShort("ES", AtStop, SS); } var : month(0),nday(0),week(0),X(False); month = int(date/100)-int(date/10000)*100; nday = date - int(date/100)*100; Week = DayOfWeek(date); #만기일 if (month%3 == 0 and nday >= 8 and nday <= 14 and week == 4) then { X = true; SetStopEndofday(151500); } Else#만기일아닐때 { X = False; SetStopEndofday(152000); }
프로필 이미지
가자아이
2025-05-21
296
글번호 191028
지표
답변완료

감사합니다 지표 변환 부탁드립니다

// INPUT SETTINGS period = input.int(10, "Period", minval=2) color lineUpColor = input(title="Color ↑", defval=#6ba583, inline="lines", group="&#9830;&#65038; lines") color lineDnColor = input(title="↓", defval=#d75442, inline="lines", group="&#9830;&#65038; lines") lw = input.int(2, "Width", [1, 2, 3, 4], inline="lines", group="&#9830;&#65038; lines") bool rangeLines = input.bool(true, "Range Lines", inline = 'rangelines', group = "&#9830;&#65038; lines") color rnglineColor = input(title="", defval=#000000, inline="rangelines", group="&#9830;&#65038; lines") //bool rnglineextend = input.bool(false, "Extend", inline = 'rangelines', group = "lines") delta = input.string('Percent', '&#120607; Format', options = [ 'Percent', 'Absolute'], group = '&#9830;&#65038; labels', inline = 'st') txtsz = input.string("Small", title="Text Size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group = "&#9830;&#65038; labels", inline = 'st') bool cyclelab = input.bool(false, "Display Cycle", "Add Highs/Lows Cycle to the labels", group = "&#9830;&#65038; labels") showtable = input.bool(true, 'Show Stats table', group = '&#9830;&#65038; statistics table') locationtable = input.string('Top Right', 'Location', ['Top Right','Top Left', 'Bottom Right', 'Bottom Left'], group = '&#9830;&#65038; statistics table', inline = 'tbpr') sizetable = input.string('Normal', 'Size', ['Large', 'Normal', 'Small', 'Tiny'], group = '&#9830;&#65038; statistics table', inline = 'tbpr') avgln = input.int(10, "Averaging", minval=2, step=1, tooltip="Number of past occurrences to average", group = '&#9830;&#65038; statistics table') ts = txtsz == "Tiny" ? size.tiny :txtsz == "Small" ? size.small :txtsz == "Normal" ? size.normal:txtsz == "Large" ? size.large : size.huge // Variables { // LAST SWING TYPE var string lastSwingType = "" // SWING HIGHS var float[] swingHighValues = array.new_float(0) var int[] swingHighBarIndexes = array.new_int(0) var label[] swingHighLabels = array.new_label(0) // SWING LOWS var float[] swingLowValues = array.new_float(0) var int[] swingLowBarIndexes = array.new_int(0) var label[] swingLowLabels = array.new_label(0) // LINES var line[] highToHighLines = array.new_line(0) var line[] lowToLowLines = array.new_line(0) var line[] bullishLines = array.new_line(0) var line[] bearishLines = array.new_line(0) // STS var float[] highToHighPriceDiffs = array.new_float(0) var int[] highToHighTimeDiffs = array.new_int(0) var float[] lowToLowPriceDiffs = array.new_float(0) var int[] lowToLowTimeDiffs = array.new_int(0) var float[] bullishPriceDiffs = array.new_float(0) var float[] bullishPrcDiffs = array.new_float(0) var int[] bullishTimeDiffs = array.new_int(0) var float[] bearishPriceDiffs = array.new_float(0) var float[] bearishPrcDiffs = array.new_float(0) var int[] bearishTimeDiffs = array.new_int(0) //} pH = high == ta.highest(high, period) ? high : na pL = low == ta.lowest(low, period) ? low : na // Adds a new swing high point, calculates differences (same-type and cross-type), creates a label, and draws connecting lines{ f_addHighSwingPoint(highValue, barIndex) => // Calculate opposite-type differences (with most recent low) oppPriceDiff = (array.size(swingLowValues) > 0) ? highValue - array.get(swingLowValues, 0) : 0.0 oppPctDiff = (array.size(swingLowValues) > 0) ? oppPriceDiff / array.get(swingLowValues, 0) * 100 : 0.0 oppTimeDiff = (array.size(swingLowBarIndexes) > 0) ? barIndex - array.get(swingLowBarIndexes, 0) : 0 // Calculate same-type differences (with previous high) samePriceDiff = (array.size(swingHighValues) > 0) ? highValue - array.get(swingHighValues, 0) : 0.0 sameTimeDiff = (array.size(swingHighBarIndexes) > 0) ? barIndex - array.get(swingHighBarIndexes, 0) : 0 patternH = "" if array.size(swingHighValues) > 0 patternH := (highValue > array.get(swingHighValues, 0)) ? "&#668;&#668;" : "&#671;&#668;" labelText = "" if array.size(swingLowValues) > 0 textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##") labelText := str.tostring(patternH) + "₩n+" + textx + "₩n&#9201;" + str.tostring(oppTimeDiff) //"L↑H " + str.tostring(oppPriceDiff, "#.##") if array.size(swingHighValues) > 0 and cyclelab labelText := labelText + "₩n&#668;&#618;&#610;&#668; &#7428;&#655;&#7428;&#671;&#7431;₩n" + "&#9201;" + str.tostring(sameTimeDiff) //+ str.tostring(samePriceDiff, "#.##") // Create label at swing high point newLabel = label.new(barIndex, highValue, labelText, textcolor = #6ba583, style=label.style_label_down, color=color.new(#000000, 100), size=ts, text_formatting = text.format_bold) // Store swing high data array.unshift(swingHighValues, highValue) array.unshift(swingHighBarIndexes, barIndex) array.unshift(swingHighLabels, newLabel) // Draw lin connection betwn cons swing highs // if previous high exists if array.size(swingHighValues) > 1 prevBar = array.get(swingHighBarIndexes, 1) prevValue = array.get(swingHighValues, 1) newLine = rangeLines?line.new(prevBar, prevValue, barIndex, highValue, color=rnglineColor, width=1, style = line.style_solid):na array.unshift(highToHighLines, newLine) // Calculate and store differences for this high-to-high line priceDiff = highValue - prevValue timeDiff = barIndex - prevBar array.unshift(highToHighPriceDiffs, priceDiff) array.unshift(highToHighTimeDiffs, timeDiff) // Draw bullish line if the last swing was // (from a low to this high) if array.size(swingLowValues) > 0 and lastSwingType != "high" prevLowBar = array.get(swingLowBarIndexes, 0) prevLowValue = array.get(swingLowValues, 0) newBullishLine = line.new(prevLowBar, prevLowValue, barIndex, highValue, color=lineUpColor, width=lw, style = line.style_solid) array.unshift(bullishLines, newBullishLine) bullishPdiff = highValue - prevLowValue bullishTdiff = barIndex - prevLowBar array.unshift(bullishPriceDiffs, bullishPdiff) array.unshift(bullishPrcDiffs, oppPctDiff) array.unshift(bullishTimeDiffs, bullishTdiff) //} // 업데이트 the current swing high point // if a new candidate is more extreme, recalculates differences, // 업데이트 the label text, and 업데이트 connecting lines{ f_업데이트HighSwingPoint(highValue, barIndex) => if highValue > array.get(swingHighValues, 0) array.set(swingHighValues, 0, highValue) array.set(swingHighBarIndexes, 0, barIndex) oppPriceDiff = (array.size(swingLowValues) > 0) ? highValue - array.get(swingLowValues, 0) : 0.0 oppPctDiff = (array.size(swingLowValues) > 0) ? oppPriceDiff / array.get(swingLowValues, 0) * 100 : 0.0 oppTimeDiff = (array.size(swingLowBarIndexes) > 0) ? barIndex - array.get(swingLowBarIndexes, 0) : 0 samePriceDiff = (array.size(swingHighValues) > 1) ? highValue - array.get(swingHighValues, 1) : 0.0 sameTimeDiff = (array.size(swingHighBarIndexes) > 1) ? barIndex - array.get(swingHighBarIndexes, 1) : 0 labelText = "" patternH = "" if array.size(swingHighValues) > 1 patternH := (highValue > array.get(swingHighValues, 1)) ? "&#668;&#668;" : "&#671;&#668;" if array.size(swingLowValues) > 0 textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##") labelText := str.tostring(patternH) + "₩n+"+ textx + "₩n&#9201;" + str.tostring(oppTimeDiff) //+ str.tostring(oppPriceDiff, "#.##") if array.size(swingHighValues) > 1 and cyclelab labelText := labelText + "₩n&#668;&#618;&#610;&#668; &#7428;&#655;&#7428;&#671;&#7431;₩n" + "&#9201;" + str.tostring(sameTimeDiff) //str.tostring(samePriceDiff, "#.##") + // 업데이트 label for current swing high lbl = array.get(swingHighLabels, 0) label.set_xy(lbl, barIndex, highValue) label.set_text(lbl, labelText) // 업데이트 high-to-high connection if it exists if array.size(swingHighValues) > 1 and array.size(highToHighLines) > 0 prevBar = array.get(swingHighBarIndexes, 1) prevValue = array.get(swingHighValues, 1) line.set_xy1(array.get(highToHighLines, 0), array.get(swingHighBarIndexes, 1), array.get(swingHighValues, 1)) line.set_xy2(array.get(highToHighLines, 0), barIndex, highValue) // Upd stored diffs for high-to-high connection array.set(highToHighPriceDiffs, 0, highValue - prevValue) array.set(highToHighTimeDiffs, 0, barIndex - prevBar) // Upd bullish connection if array.size(swingLowValues) > 0 and array.size(bullishLines) > 0 prevLowBar = array.get(swingLowBarIndexes, 0) prevLowValue = array.get(swingLowValues, 0) line.set_xy1(array.get(bullishLines, 0), prevLowBar, prevLowValue) line.set_xy2(array.get(bullishLines, 0), barIndex, highValue) array.set(bullishPriceDiffs, 0, highValue - prevLowValue) array.set(bullishPrcDiffs, 0, (highValue - prevLowValue)/prevLowValue * 100) array.set(bullishTimeDiffs, 0, barIndex - prevLowBar) 0. //} // Adds a new swing low point, calculates differences (same-type and cross-type),creates a label, and draws connecting lines{ f_addLowSwingPoint(lowValue, barIndex) => // Calculate opposite-type differences (with most recent high) oppPriceDiff = (array.size(swingHighValues) > 0) ? lowValue - array.get(swingHighValues, 0) : 0.0 oppPctDiff = (array.size(swingHighValues) > 0) ? oppPriceDiff / array.get(swingHighValues, 0) * 100 : 0.0 oppTimeDiff = (array.size(swingHighBarIndexes) > 0) ? barIndex - array.get(swingHighBarIndexes, 0) : 0 // Calculate same-type differences (with previous low) samePriceDiff = (array.size(swingLowValues) > 0) ? lowValue - array.get(swingLowValues, 0) : 0.0 sameTimeDiff = (array.size(swingLowBarIndexes) > 0) ? barIndex - array.get(swingLowBarIndexes, 0) : 0 labelText = "" patternL = "" if array.size(swingLowValues) > 0 patternL := (lowValue < array.get(swingLowValues, 0)) ? "&#671;&#671;" : "&#668;&#671;" if array.size(swingHighValues) > 0 textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##") labelText := str.tostring(patternL) + "₩n" + textx + "₩n&#9201;" + str.tostring(oppTimeDiff) //"H↓L "+ str.tostring(oppPriceDiff, "#.##") if array.size(swingLowValues) > 0 and cyclelab labelText := labelText + "₩n&#671;&#7439;&#7457; &#7428;&#655;&#7428;&#671;&#7431;₩n" + "&#9201;" + str.tostring(sameTimeDiff) //+ str.tostring(samePriceDiff, "#.##") // Create label at swing low point newLabel = label.new(barIndex, lowValue, labelText, textcolor = #d75442, style=label.style_label_up, color=color.new(#000000, 100), size=ts, text_formatting = text.format_bold) // Store swing low data array.unshift(swingLowValues, lowValue) array.unshift(swingLowBarIndexes, barIndex) array.unshift(swingLowLabels, newLabel) // connection line betwn consecutive swing lows if array.size(swingLowValues) > 1 prevBar = array.get(swingLowBarIndexes, 1) prevValue = array.get(swingLowValues, 1) newLine = rangeLines?line.new(prevBar, prevValue, barIndex, lowValue, color=rnglineColor, width=1, style = line.style_solid):na array.unshift(lowToLowLines, newLine) // Calculate and store differences for this low-to-low line priceDiff = lowValue - prevValue timeDiff = barIndex - prevBar array.unshift(lowToLowPriceDiffs, priceDiff) array.unshift(lowToLowTimeDiffs, timeDiff) // Draw bearish line if the last swing was of the opposite type (from a high to this low) if array.size(swingHighValues) > 0 and lastSwingType != "low" prevHighBar = array.get(swingHighBarIndexes, 0) prevHighValue = array.get(swingHighValues, 0) newBearishLine = line.new(prevHighBar, prevHighValue, barIndex, lowValue, color=lineDnColor, width=lw, style = line.style_solid) array.unshift(bearishLines, newBearishLine) bearishPdiff = lowValue - prevHighValue bearishTdiff = barIndex - prevHighBar array.unshift(bearishPriceDiffs, bearishPdiff) array.unshift(bearishPrcDiffs, oppPctDiff) array.unshift(bearishTimeDiffs, bearishTdiff) //} // 업데이트 the current swing low point if a new is more extreme, recalculates differences, 업데이트 the lab text, and connecting lines{ f_업데이트LowSwingPoint(lowValue, barIndex) => if lowValue < array.get(swingLowValues, 0) array.set(swingLowValues, 0, lowValue) array.set(swingLowBarIndexes, 0, barIndex) oppPriceDiff = (array.size(swingHighValues) > 0) ? lowValue - array.get(swingHighValues, 0) : 0.0 oppPctDiff = (array.size(swingHighValues) > 0) ? oppPriceDiff / array.get(swingHighValues, 0) * 100 : 0.0 oppTimeDiff = (array.size(swingHighBarIndexes) > 0) ? barIndex - array.get(swingHighBarIndexes, 0) : 0 samePriceDiff = (array.size(swingLowValues) > 1) ? lowValue - array.get(swingLowValues, 1) : 0.0 sameTimeDiff = (array.size(swingLowBarIndexes) > 1) ? barIndex - array.get(swingLowBarIndexes, 1) : 0 labelText = "" patternL = "" if array.size(swingLowValues) > 1 patternL := (lowValue < array.get(swingLowValues, 1)) ? "&#671;&#671;" : "&#668;&#671;" if array.size(swingHighValues) > 0 textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##") labelText := str.tostring(patternL)+ "₩n"+ textx + "₩n&#9201;" + str.tostring(oppTimeDiff) //"L↑H "+ str.tostring(oppPriceDiff, "#.##") if array.size(swingLowValues) > 1 and cyclelab labelText := labelText + "₩n&#671;&#7439;&#7457; &#7428;&#655;&#7428;&#671;&#7431;₩n" + "&#9201;" + str.tostring(sameTimeDiff) //+ str.tostring(samePriceDiff, "#.##") // 업데이트 label for current swing low lbl = array.get(swingLowLabels, 0) label.set_xy(lbl, barIndex, lowValue) label.set_text(lbl, labelText) // 업데이트 low-to-low connection if it exists if array.size(swingLowValues) > 1 and array.size(lowToLowLines) > 0 prevBar = array.get(swingLowBarIndexes, 1) prevValue = array.get(swingLowValues, 1) line.set_xy1(array.get(lowToLowLines, 0), prevBar, prevValue) line.set_xy2(array.get(lowToLowLines, 0), barIndex, lowValue) array.set(lowToLowPriceDiffs, 0, lowValue - prevValue) array.set(lowToLowTimeDiffs, 0, barIndex - prevBar) // 업데이트 bearish connection if exists if array.size(swingHighValues) > 0 and array.size(bearishLines) > 0 prevHighBar = array.get(swingHighBarIndexes, 0) prevHighValue = array.get(swingHighValues, 0) line.set_xy1(array.get(bearishLines, 0), prevHighBar, prevHighValue) line.set_xy2(array.get(bearishLines, 0), barIndex, lowValue) array.set(bearishPriceDiffs, 0, lowValue - prevHighValue) array.set(bearishPrcDiffs, 0, (lowValue - prevHighValue)/prevHighValue * 100) array.set(bearishTimeDiffs, 0, barIndex - prevHighBar) 0. //} if array.size(highToHighLines) > 0 and array.size(lowToLowLines) > 0 linefill.new(array.get(highToHighLines, 0), array.get(lowToLowLines, 0), color.rgb(0, 0, 0, 95)) // Process pivs { var int direction = 0 direction := (not na(pH) and na(pL)) ? 1 : (not na(pL) and na(pH)) ? -1 : direction bool directionChanged = direction != nz(direction[1]) bool bullish = direction == 1 bool bearish = direction == -1 bool bull = direction[1]==-1 and direction==1 bool bear = direction[1]==1 and direction==-1 if direction==1 if lastSwingType != "high" f_addHighSwingPoint(pH, bar_index) lastSwingType := "high" else f_업데이트HighSwingPoint(pH, bar_index) if direction==-1 if lastSwingType != "low" f_addLowSwingPoint(pL, bar_index) lastSwingType := "low" else f_업데이트LowSwingPoint(pL, bar_index) //} // Function for geometric averaging { f_geometric_avg(_source, _condition, _length) => var float geom_avg = na var float[] valuesArray = array.new_float() if _condition if _source > 0 array.push(valuesArray, _source) while array.size(valuesArray) > _length array.shift(valuesArray) n = array.size(valuesArray) if n > 0 logSum = 0.0 for val in valuesArray logSum += math.log(val) geom_avg := math.exp(logSum / n) else geom_avg := na geom_avg var float sourcebull = na var float sourcebear = na var int sourcebullt = na var int sourcebeart = na if array.size(bullishPriceDiffs)>0 and array.size(bullishPrcDiffs)>0 sourcebull := delta=="Percent"?array.get(bullishPrcDiffs, 0) : array.get(bullishPriceDiffs, 0) sourcebullt:=array.get(bullishTimeDiffs, 0) conditionbull = lastSwingType=="low" and lastSwingType[1]== "high" rma_valuebull = f_geometric_avg(sourcebull, conditionbull, avgln) rma_valuebullt = f_geometric_avg(sourcebullt, conditionbull, avgln) if array.size(bearishPriceDiffs)>0 and array.size(bearishPrcDiffs)>0 sourcebear := delta=="Percent"?array.get(bearishPrcDiffs, 0) : array.get(bearishPriceDiffs, 0) sourcebeart:=array.get(bearishTimeDiffs, 0) conditionbear = lastSwingType=="high" and lastSwingType[1] == "low" rma_valuebear = f_geometric_avg(math.abs(sourcebear), conditionbear, avgln) rma_timebear = f_geometric_avg(sourcebeart, conditionbear, avgln) //} //Table{ var table_loc = locationtable == 'Top Right' ? position.top_right : locationtable == 'Bottom Right' ? position.bottom_right : locationtable == 'Top Center' ? position.top_center : locationtable == 'Top Left' ? position.top_left : position.bottom_left var table_size = sizetable == 'Large' ? size.large : sizetable == 'Normal' ? size.normal : sizetable == 'Small' ? size.small : size.tiny var table = showtable ? table.new(table_loc, 16, 16, #2a2e39, #1e1e1e, 2, #1f232f, 2) : na table_cell(column, row, txt, signal = false) => table.cell(table, column, row, txt, 0, 0, signal ? #ffffff : #ffffff, text_size = table_size) table_cell_bg(column, row, col) => table.cell_set_bgcolor(table, column, row, col) if barstate.islast and showtable table_cell(0, 0, "STATISTICS TABLE") table_cell(0, 1, "&#610;&#7431;&#7439;&#7437;&#7431;&#7451;&#640;&#618;&#7428;₩n&#7424;&#7456;&#7431;&#640;&#7424;&#610;&#618;&#628;&#610;") table_cell(1, 1, "&#120723; &#7448;&#640;&#618;&#7428;&#7431;") table_cell(2, 1, "&#120723; &#7451;&#618;&#7437;&#7431;") table_cell(0, 2, '&#7452;&#7448;&#7451;&#640;&#7431;&#628;&#7429;') table_cell(0, 3, '&#7429;&#7439;&#7457;&#628;&#7451;&#640;&#7431;&#628;&#7429;') table_cell(1, 2, "+"+str.tostring(rma_valuebull, delta=="Percent"?format.percent:format.mintick)) table_cell(1, 3, "-"+str.tostring(rma_valuebear, delta=="Percent"?format.percent:format.mintick)) table_cell(2, 2, str.tostring(rma_valuebullt, format.mintick)) table_cell(2, 3, str.tostring(rma_timebear, format.mintick)) table.cell_set_text_font_family(table, 0,0, font.family_monospace) table.cell_set_text_formatting(table, 1, 1, text.format_bold) table.cell_set_text_formatting(table, 2, 1, text.format_bold) table.cell_set_text_formatting(table, 0, 2, text.format_bold) table.cell_set_text_formatting(table, 0, 3, text.format_bold) table.cell_set_text_color(table, 0, 1, color.gray) table.cell_set_text_size(table, 0, 1, size.small) table.merge_cells(table, 0,0,2,0) //}
프로필 이미지
갈랑교
2025-05-21
450
글번호 191027
지표
답변완료

부탁드립니다 항상 감사합니다

Input: rsiLen(14), rsiCut(50), macdFastLen(12), macdSlowLen(26), macdSignalLen(9), tp1Ratio(0.995), tp2Ratio(0.990), tp3Ratio(0.985), slRatio(1.01), volumeMultiplier(2.0), 평균거래량기간(20), 시작시간(93000), 종료시간(150000); Var: rsiVal(0), macdFastEMA(0), macdSlowEMA(0), macdMain(0), macdSignal(0), macdHist(0), 진입가(0), TP1(0), TP2(0), TP3(0), SL(0), 거래량기준(0), 텍스트ID(0), TL1(0), TL2(0), TL3(0), TL4(0), 손익라벨(0), 매도조건(false), 청산1(false), 청산2(false), 청산3(false); // 1. RSI + MACD 계산 rsiVal = RSI(rsiLen); If CurrentBar = 1 Then Begin macdFastEMA = Close; macdSlowEMA = Close; End Else Begin macdFastEMA = (Close * (2 / (macdFastLen + 1))) + macdFastEMA[1] * (1 - (2 / (macdFastLen + 1))); macdSlowEMA = (Close * (2 / (macdSlowLen + 1))) + macdSlowEMA[1] * (1 - (2 / (macdSlowLen + 1))); macdMain = macdFastEMA - macdSlowEMA; macdSignal = (macdMain * (2 / (macdSignalLen + 1))) + macdSignal[1] * (1 - (2 / (macdSignalLen + 1))); macdHist = macdMain - macdSignal; End; // 2. 거래량 조건 거래량기준 = Average(Volume, 평균거래량기간); // 3. 조건 진입 If sTime >= 시작시간 and sTime <= 종료시간 and 매도조건 = false Then Begin If rsiVal < rsiCut and macdHist < 0 and macdHist[1] > 0 and Volume > 거래량기준 * volumeMultiplier Then Begin 진입가 = Close; TP1 = 진입가 * tp1Ratio; TP2 = 진입가 * tp2Ratio; TP3 = 진입가 * tp3Ratio; SL = 진입가 * slRatio; // 자동 매도 포지션 진입 SellShort("ShortEntry") Next Bar at Market; // 손익비 박스 TL_Delete(TL1); TL_Delete(TL2); TL_Delete(TL3); TL_Delete(TL4); Text_Delete(손익라벨); TL1 = TL_New(Date, Time, SL, Date + 1, Time, SL); TL2 = TL_New(Date, Time, TP3, Date + 1, Time, TP3); TL3 = TL_New(Date, Time, SL, Date, Time, TP3); TL4 = TL_New(Date + 1, Time, SL, Date + 1, Time, TP3); TL_SetColor(TL1, RGB(255,200,200)); TL_SetColor(TL2, RGB(255,200,200)); TL_SetColor(TL3, RGB(255,200,200)); TL_SetColor(TL4, RGB(255,200,200)); TL_SetSize(TL1, 1); TL_SetSize(TL2, 1); TL_SetSize(TL3, 1); TL_SetSize(TL4, 1); // 손익비 계산 및 라벨 표시 손익라벨 = Text_New(Date, Time, (SL + TP3)/2, "손익비 " + NumToStr((진입가 - TP3) / (SL - 진입가), 1) + ":1"); Text_SetStyle(손익라벨, 1, 0); Text_SetColor(손익라벨, RGB(200, 0, 0)); 매도조건 = true; 청산1 = false; 청산2 = false; 청산3 = false; End; End; // 4. 청산 조건 (비율 분할 청산 시뮬레이션) If 매도조건 Then Begin // TP1 도달 시 If 청산1 = false and Close <= TP1 Then Begin Alert("TP1 도달: 30% 청산"); 청산1 = true; End; // TP2 도달 시 If 청산2 = false and Close <= TP2 Then Begin Alert("TP2 도달: 50% 청산"); 청산2 = true; End; // TP3 도달 시 If 청산3 = false and Close <= TP3 Then Begin Alert("TP3 도달: 나머지 전량 청산"); 청산3 = true; 매도조건 = false; End; // SL 도달 시 전체 손절 If Close >= SL Then Begin Alert("손절가 도달: 전량 청산"); 청산1 = true; 청산2 = true; 청산3 = true; 매도조건 = false; End; End; 검증시 오류가나서 구현할수있게 부탁드립니다 감사합니다
프로필 이미지
윤호석
2025-05-21
283
글번호 191026
지표