커뮤니티

수식 문의드립니다.

프로필 이미지
cooparoo
2024-05-16 23:43:28
1006
글번호 179621
답변완료
안녕하세요. 다음 파인 스크립트 수식을 예스로 변환 부탁드립니다. 쓰기 금지단어 셀렉트&업데이트는 한글로 수정했습니다. 그리고 Table 과 Break-Even Curve는 시간이 걸리면 생략해도 됩니다. 다시 한번 감사드립니다^^ indicator(overlay=true,max_lines_count=500) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Settings { // ~~ Tooltips t1 = "셀렉트 the method used to calculate the trailing stop. 'Auto' dynamically calculates based on market conditions. 'Percentage' uses a fixed percentage for trailing. ₩n₩nThe second value defines the lookback period over which to calculate the highest high and lowest low for trailing stop calculations. Increasing this value will make the trailing stop less sensitive to price changes." t2 = "Sets the percentage step for the trailing stop when 'Percentage' method is 셀렉티드. Increasing this value will increase the distance of the trailing stop from the price." t3 = "Determines the bias of the trailing stop. 'Bullish' sets it to track only upward moves, 'Bearish' only downward, and 'Auto' adjusts dynamically based on price action." // ~~ Inputs step = input.string("Auto","Trailing Method",["Auto","Percentage","Pivot"], group="Trailing", inline="Trailing", tooltip="") prd = input.int(20,"Trailing Size", minval=2, group="Trailing", inline="Trailing", tooltip=t1) perc = input.float(.5,"Percentage Step",step=.01,group="Trailing", inline="", tooltip=t2)/100 bias = input.string("Auto","Set Bias",["Bullish","Bearish","Auto"], group="Bias", inline="", tooltip=t3) upcol = input.color(#089981 , title='', group='Style', inline="Style") dncol = input.color(#f23645, title='', group='Style', inline="Style") upcol1 = input.color(color.lime , title='', group='Style', inline="Style1") dncol1 = input.color(color.maroon, title='', group='Style', inline="Style1") showBE = input.bool(true,"Break-Even Curve",group="Table",inline="Table") showTable = input.bool(true, title='Show Table', group='Table', inline='Table') labels = input.bool(false, title='Show Labels', group='Table', inline='Table') tblSize = input.string("Auto","Table Size",["Auto","Tiny","Small","Normal","Large","Huge"], group="Table", inline="style") posi = input.string(position.top_right, title="",options =[position.top_right,position.top_center, position.top_left,position.bottom_right,position.bottom_center,position.bottom_left,position.middle_right,position.middle_left], group="Table",inline="style", tooltip="") Table_Text = input.color(color.new(color.white, 0), title='Text', inline='style', group='Table') Table_BG = input.color(color.new(#176cff, 0), title='BG', inline='style', group='Table') //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ General Variables { b = bar_index dot = label(na) var curve = array.new<line>() var labs = array.new<label>() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ AutoMove calc { hi = ta.highest(high,prd*10) lo = ta.lowest(low,prd*10) var ph = high var pl = low var phL = b var plL = b var peaks = array.new<float>() ph := ta.highestbars(high, prd) == 0 ? high : ph pl := ta.lowestbars(low, prd) == 0 ? low : pl phL:= ta.highestbars(high, prd) == 0 ? b : phL plL:= ta.lowestbars(low, prd) == 0 ? b : plL dir = phL>plL ? 1 : -1 //Delayed if dir!=dir[1] peaks.push(dir>0 ? (ph[1]-pl)/ph[1] : (ph-pl[1])/pl[1]) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Functions { Switch(Los)=> autocalc = na(peaks.median())?0:peaks.median() output = switch step "Auto" => Los?low-(low*autocalc):high+(high*autocalc) "Percentage" => Los?low-(low*perc):high+(high*perc) "Pivot" => Los?pl:ph Cleaner(arr)=> if arr.size()>0 for a in arr a.delete() arr.clear() ts = switch tblSize "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large "Huge" => size.huge "Auto" => size.auto //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Trailing Mangement { var longtsl = Switch(true) var shorttsl = Switch(false) var pos = 0 if low<=longtsl longtsl := Switch(true) shorttsl := Switch(false) pos := -1 if high>=shorttsl longtsl := Switch(true) shorttsl := Switch(false) pos := 1 pos := bias=="Bullish"?1:bias=="Bearish"?-1:pos //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Plots { active = longtsl==longtsl[1] lt1 = plot(longtsl,color=active?pos>0?dncol:upcol:na, title="TSL") st1 = plot(shorttsl,color=active?pos>0?upcol:dncol:na, title="TSL") p1 = plot(close,"",color(na),editable=false,display=display.none) mid = math.avg(longtsl,shorttsl) plot(mid,color=active?color.rgb(125, 196, 255):na, style=plot.style_steplinebr, title="Mid") PosOver = pos ==-1 and close>mid?na:upcol1 NegUnder = pos ==1 and close<mid?na:dncol1 fill(p1,lt1,pos>0 and active?color.new(PosOver,80):active?color.new(NegUnder,80):na, title="") fill(p1,st1,pos>0 and active?color.new(upcol,80):active?color.new(dncol,80):na, title="") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Table { if barstate.islast tpdist = pos>0?shorttsl-close:close-longtsl sldist = pos>0?close-longtsl:shorttsl-close distdiff = tpdist/sldist wr = (1/(1+distdiff))*100 if showTable var tbl = table.new(posi, 2, 5, frame_color=color.black, frame_width=3, border_width=2, border_color=color.new(color.white, 100)) tbl.cell(0, 0, 'Risk/Reward', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 0, "1:"+str.tostring(math.round(distdiff,2)), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0,1, 'Minimum Winrate', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1,1, str.tostring(wr,format.percent), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0, 2, 'Reward', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 2, str.tostring((tpdist/close)*100,format.percent), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0, 3, 'Risk', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 3, str.tostring((sldist/close)*100,format.percent), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0, 4, 'Bias', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 4, str.tostring(pos>0?"Bullish":"Bearish"), text_halign=text.align_center, bgcolor=pos>0?color.rgb(104, 218, 108):color.red, text_color=Table_Text, text_size=ts) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Break-Even Curve { if showBE Cleaner(curve) top = lo + (hi-lo)/3 float prev_y = top for j=b+100 to b+200 by 1 y = prev_y-((prev_y-lo)/14) curve.push(line.new(j,prev_y,j+1,y,color=color.blue, width=2)) prev_y := y //Create & 업데이트 Frame var box box_upper_left = box.new(na,na,na,na,na, text="Zone 2", text_color = color.white, bgcolor=color.new(color.lime, 80)) var box box_upper_right = box.new(na,na,na,na,na, text="The Magic Zone",text_color = color.white, bgcolor=color.new(color.lime, 70)) var box box_lower_left = box.new(na,na,na,na,na, text ="Zone 1", text_color = color.white,bgcolor=color.new(color.green, 70)) var box box_lower_right = box.new(na,na,na,na,na, text="Zone 3", text_color = color.white,bgcolor=color.new(color.green, 80)) box_upper_left.set_lefttop(b+100,top) box_upper_left.set_rightbottom(b+150,(top+lo)/2) box_upper_right.set_lefttop(b+150,top) box_upper_right.set_rightbottom(b+200,(top+lo)/2) box_lower_left.set_lefttop(b+100,(top+lo)/2) box_lower_left.set_rightbottom(b+150,lo) box_lower_right.set_lefttop(b+150,(top+lo)/2) box_lower_right.set_rightbottom(b+200,lo) // Delete & Add labels Cleaner(labs) for i=0 to 10 labs.push(label.new(chart.point.from_index(b+100,lo+i*(top-lo)/10), str.tostring(i*2)+"R", color=color(na), textcolor=chart.fg_color, style=label.style_label_right)) labs.push(label.new(chart.point.from_index(b+100+i*10, lo), str.tostring(i * 10) + "%", color=color(na), textcolor=chart.fg_color, style=label.style_label_up)) // Dot for the 'Break-Even Point' y = (top-lo)*(distdiff/20) dot := label.new(chart.point.from_index(b+100+int(wr),lo+y), style=label.style_circle,color=color.yellow,size=size.tiny) (dot[1]).delete() // ~~ labels { var label stopLossLabel = na var label riskRewardLabel = na stoploss = pos>0?longtsl:shorttsl riskreward = pos>0?shorttsl:longtsl if labels stopLossLabel := label.new(bar_index+5, stoploss, "Risk" + " " + str.tostring((sldist/close)*100,format.percent), color=dncol, textcolor=color.white, style=label.style_label_left, yloc=yloc.price) riskRewardLabel := label.new(bar_index+5, riskreward, "Reward" + " " + str.tostring((tpdist/close)*100,format.percent), color=upcol, textcolor=color.white, style=label.style_label_left, yloc=yloc.price) label.delete(stopLossLabel[1]) label.delete(riskRewardLabel[1]) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Trend Change switchUp = pos==1 switchDn = pos==-1 plotshape(switchUp and switchDn[1]?longtsl:na, location=location.absolute, style=shape.triangleup, color=upcol, size=size.small, title="Positive Trend") plotshape(switchDn and switchUp[1]?shorttsl:na, location=location.absolute, style=shape.triangledown ,color=dncol, size=size.small, title="Negative Trend") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-05-17 11:29:08

안녕하세요 예스스탁입니다. Table 과 Break-Even Curve 까지는 작성이 어렵습니다. 지표만 출력되게 작성해 드립니다. 영문 인서트가 게시판 금칙어라 In*sertArray와 같이 *이 중간에 포함되어 있습니다. *은 삭제하시고 적용하셔야 합니다. input : stp("Auto"); input : prd(20); input : perc(0.5); input : bias("Auto"); input : upcol(Green); input : dncol(Red); input : upcol1(lime); input : dncol1(maroon); var : b(0),hi(0),lo(0),ph(0),pl(0),phl(0),pll(0),dir(0); var : cnt(0); Array : peaks[1000](0); b = index; hi = highest(high,prd*10); lo = lowest(low,prd*10); ph = iff(NthHighestBar(1,high, prd) == 0 , high , ph); pl = iff(NthLowestBar(1,low, prd) == 0 , low , pl); phL = iff(NthHighestBar(1,high, prd) == 0 , b , phL); plL = iff(NthLowestBar(1,low, prd) == 0 , b , plL); dir = iff(phL>plL , 1 , -1); if dir!=dir[1] Then { In*sertArray(peaks, 0, iff(dir>0 , (ph[1]-pl)/ph[1] , (ph-pl[1])/pl[1])) ; //*삭제 cnt = cnt+1; } var : autocalc(0),SwitchTrue(0),SwitchFalse(0); autocalc = iff(cnt == 0 ,0 , MedianArray(peaks, cnt)); if stp == "Auto" Then { SwitchTrue = low-(low*autocalc); Switchfalse = high+(high*autocalc); } if stp == "Percentage" Then { SwitchTrue = low-(low*(perc/100)); Switchfalse = high+(high*(perc)/100); } if stp == "Pivot" Then { SwitchTrue = pl; Switchfalse = ph; } var : longtsl(0),shorttsl(0),pos(0); if low<=longtsl Then { longtsl = Switchtrue; shorttsl = Switchfalse; pos = -1; } if high>=shorttsl then { longtsl = Switchtrue; shorttsl = Switchfalse; pos = 1; } pos = iff(bias=="Bullish",1, IFf(bias=="Bearish",-1,pos)); var : active(False),mid(0); active = longtsl==longtsl[1]; plot1(longtsl,"ltl",iff(active,IFF(pos>0,dncol,upcol),Black)); plot2(shorttsl,"stl",iff(active,iff(pos>0,upcol,dncol),Black)); plot3(close,"c"); mid = Avg(longtsl,shorttsl); plot4(mid,"Mid",iff(active,rgb(125, 196, 255),black)); 즐거운 하루되세요 > cooparoo 님이 쓴 글입니다. > 제목 : 수식 문의드립니다. > 안녕하세요. 다음 파인 스크립트 수식을 예스로 변환 부탁드립니다. 쓰기 금지단어 셀렉트&업데이트는 한글로 수정했습니다. 그리고 Table 과 Break-Even Curve는 시간이 걸리면 생략해도 됩니다. 다시 한번 감사드립니다^^ indicator(overlay=true,max_lines_count=500) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Settings { // ~~ Tooltips t1 = "셀렉트 the method used to calculate the trailing stop. 'Auto' dynamically calculates based on market conditions. 'Percentage' uses a fixed percentage for trailing. ₩n₩nThe second value defines the lookback period over which to calculate the highest high and lowest low for trailing stop calculations. Increasing this value will make the trailing stop less sensitive to price changes." t2 = "Sets the percentage step for the trailing stop when 'Percentage' method is 셀렉티드. Increasing this value will increase the distance of the trailing stop from the price." t3 = "Determines the bias of the trailing stop. 'Bullish' sets it to track only upward moves, 'Bearish' only downward, and 'Auto' adjusts dynamically based on price action." // ~~ Inputs step = input.string("Auto","Trailing Method",["Auto","Percentage","Pivot"], group="Trailing", inline="Trailing", tooltip="") prd = input.int(20,"Trailing Size", minval=2, group="Trailing", inline="Trailing", tooltip=t1) perc = input.float(.5,"Percentage Step",step=.01,group="Trailing", inline="", tooltip=t2)/100 bias = input.string("Auto","Set Bias",["Bullish","Bearish","Auto"], group="Bias", inline="", tooltip=t3) upcol = input.color(#089981 , title='', group='Style', inline="Style") dncol = input.color(#f23645, title='', group='Style', inline="Style") upcol1 = input.color(color.lime , title='', group='Style', inline="Style1") dncol1 = input.color(color.maroon, title='', group='Style', inline="Style1") showBE = input.bool(true,"Break-Even Curve",group="Table",inline="Table") showTable = input.bool(true, title='Show Table', group='Table', inline='Table') labels = input.bool(false, title='Show Labels', group='Table', inline='Table') tblSize = input.string("Auto","Table Size",["Auto","Tiny","Small","Normal","Large","Huge"], group="Table", inline="style") posi = input.string(position.top_right, title="",options =[position.top_right,position.top_center, position.top_left,position.bottom_right,position.bottom_center,position.bottom_left,position.middle_right,position.middle_left], group="Table",inline="style", tooltip="") Table_Text = input.color(color.new(color.white, 0), title='Text', inline='style', group='Table') Table_BG = input.color(color.new(#176cff, 0), title='BG', inline='style', group='Table') //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ General Variables { b = bar_index dot = label(na) var curve = array.new<line>() var labs = array.new<label>() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ AutoMove calc { hi = ta.highest(high,prd*10) lo = ta.lowest(low,prd*10) var ph = high var pl = low var phL = b var plL = b var peaks = array.new<float>() ph := ta.highestbars(high, prd) == 0 ? high : ph pl := ta.lowestbars(low, prd) == 0 ? low : pl phL:= ta.highestbars(high, prd) == 0 ? b : phL plL:= ta.lowestbars(low, prd) == 0 ? b : plL dir = phL>plL ? 1 : -1 //Delayed if dir!=dir[1] peaks.push(dir>0 ? (ph[1]-pl)/ph[1] : (ph-pl[1])/pl[1]) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Functions { Switch(Los)=> autocalc = na(peaks.median())?0:peaks.median() output = switch step "Auto" => Los?low-(low*autocalc):high+(high*autocalc) "Percentage" => Los?low-(low*perc):high+(high*perc) "Pivot" => Los?pl:ph Cleaner(arr)=> if arr.size()>0 for a in arr a.delete() arr.clear() ts = switch tblSize "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large "Huge" => size.huge "Auto" => size.auto //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Trailing Mangement { var longtsl = Switch(true) var shorttsl = Switch(false) var pos = 0 if low<=longtsl longtsl := Switch(true) shorttsl := Switch(false) pos := -1 if high>=shorttsl longtsl := Switch(true) shorttsl := Switch(false) pos := 1 pos := bias=="Bullish"?1:bias=="Bearish"?-1:pos //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Plots { active = longtsl==longtsl[1] lt1 = plot(longtsl,color=active?pos>0?dncol:upcol:na, title="TSL") st1 = plot(shorttsl,color=active?pos>0?upcol:dncol:na, title="TSL") p1 = plot(close,"",color(na),editable=false,display=display.none) mid = math.avg(longtsl,shorttsl) plot(mid,color=active?color.rgb(125, 196, 255):na, style=plot.style_steplinebr, title="Mid") PosOver = pos ==-1 and close>mid?na:upcol1 NegUnder = pos ==1 and close<mid?na:dncol1 fill(p1,lt1,pos>0 and active?color.new(PosOver,80):active?color.new(NegUnder,80):na, title="") fill(p1,st1,pos>0 and active?color.new(upcol,80):active?color.new(dncol,80):na, title="") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Table { if barstate.islast tpdist = pos>0?shorttsl-close:close-longtsl sldist = pos>0?close-longtsl:shorttsl-close distdiff = tpdist/sldist wr = (1/(1+distdiff))*100 if showTable var tbl = table.new(posi, 2, 5, frame_color=color.black, frame_width=3, border_width=2, border_color=color.new(color.white, 100)) tbl.cell(0, 0, 'Risk/Reward', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 0, "1:"+str.tostring(math.round(distdiff,2)), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0,1, 'Minimum Winrate', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1,1, str.tostring(wr,format.percent), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0, 2, 'Reward', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 2, str.tostring((tpdist/close)*100,format.percent), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0, 3, 'Risk', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 3, str.tostring((sldist/close)*100,format.percent), text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(0, 4, 'Bias', text_halign=text.align_center, bgcolor=Table_BG, text_color=Table_Text, text_size=ts) tbl.cell(1, 4, str.tostring(pos>0?"Bullish":"Bearish"), text_halign=text.align_center, bgcolor=pos>0?color.rgb(104, 218, 108):color.red, text_color=Table_Text, text_size=ts) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Break-Even Curve { if showBE Cleaner(curve) top = lo + (hi-lo)/3 float prev_y = top for j=b+100 to b+200 by 1 y = prev_y-((prev_y-lo)/14) curve.push(line.new(j,prev_y,j+1,y,color=color.blue, width=2)) prev_y := y //Create & 업데이트 Frame var box box_upper_left = box.new(na,na,na,na,na, text="Zone 2", text_color = color.white, bgcolor=color.new(color.lime, 80)) var box box_upper_right = box.new(na,na,na,na,na, text="The Magic Zone",text_color = color.white, bgcolor=color.new(color.lime, 70)) var box box_lower_left = box.new(na,na,na,na,na, text ="Zone 1", text_color = color.white,bgcolor=color.new(color.green, 70)) var box box_lower_right = box.new(na,na,na,na,na, text="Zone 3", text_color = color.white,bgcolor=color.new(color.green, 80)) box_upper_left.set_lefttop(b+100,top) box_upper_left.set_rightbottom(b+150,(top+lo)/2) box_upper_right.set_lefttop(b+150,top) box_upper_right.set_rightbottom(b+200,(top+lo)/2) box_lower_left.set_lefttop(b+100,(top+lo)/2) box_lower_left.set_rightbottom(b+150,lo) box_lower_right.set_lefttop(b+150,(top+lo)/2) box_lower_right.set_rightbottom(b+200,lo) // Delete & Add labels Cleaner(labs) for i=0 to 10 labs.push(label.new(chart.point.from_index(b+100,lo+i*(top-lo)/10), str.tostring(i*2)+"R", color=color(na), textcolor=chart.fg_color, style=label.style_label_right)) labs.push(label.new(chart.point.from_index(b+100+i*10, lo), str.tostring(i * 10) + "%", color=color(na), textcolor=chart.fg_color, style=label.style_label_up)) // Dot for the 'Break-Even Point' y = (top-lo)*(distdiff/20) dot := label.new(chart.point.from_index(b+100+int(wr),lo+y), style=label.style_circle,color=color.yellow,size=size.tiny) (dot[1]).delete() // ~~ labels { var label stopLossLabel = na var label riskRewardLabel = na stoploss = pos>0?longtsl:shorttsl riskreward = pos>0?shorttsl:longtsl if labels stopLossLabel := label.new(bar_index+5, stoploss, "Risk" + " " + str.tostring((sldist/close)*100,format.percent), color=dncol, textcolor=color.white, style=label.style_label_left, yloc=yloc.price) riskRewardLabel := label.new(bar_index+5, riskreward, "Reward" + " " + str.tostring((tpdist/close)*100,format.percent), color=upcol, textcolor=color.white, style=label.style_label_left, yloc=yloc.price) label.delete(stopLossLabel[1]) label.delete(riskRewardLabel[1]) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Trend Change switchUp = pos==1 switchDn = pos==-1 plotshape(switchUp and switchDn[1]?longtsl:na, location=location.absolute, style=shape.triangleup, color=upcol, size=size.small, title="Positive Trend") plotshape(switchDn and switchUp[1]?shorttsl:na, location=location.absolute, style=shape.triangledown ,color=dncol, size=size.small, title="Negative Trend") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}