커뮤니티

파인스크립트를 예스랭귀지로 부탁합니다~~

프로필 이미지
하날랑
2024-04-22 09:30:35
789
글번호 178778
답변완료
다음의 파인스트립드지표를 자동매매에 적용해 보고자 하오니 예스랭귀지로 부탁드립니다. 적용시간은 16:00에서 익일05:57입니다. 다음의 지표에 추가할 것이 있어 매수진입 매수청산 매도진입 매수청산이 되도록 부탁드려봅니다. var string calcGroup = 'Calculation' length = input.int(title='ATR Period', defval=22, group=calcGroup) mult = input.float(title='ATR Multiplier', step=0.1, defval=3.0, group=calcGroup) useClose = input.bool(title='Use Close Price for Extremums', defval=true, group=calcGroup) var string visualGroup = 'Visuals' showLabels = input.bool(title='Show Buy/Sell Labels', defval=true, group=visualGroup) highlightState = input.bool(title='Highlight State', defval=true, group=visualGroup) var string alertGroup = 'Alerts' awaitBarConfirmation = input.bool(title="Await Bar Confirmation", defval=true, group=alertGroup) atr = mult * ta.atr(length) longStop = (useClose ? ta.highest(close, length) : ta.highest(length)) - atr longStopPrev = nz(longStop[1], longStop) longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop shortStop = (useClose ? ta.lowest(close, length) : ta.lowest(length)) + atr shortStopPrev = nz(shortStop[1], shortStop) shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop var int dir = 1 dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir var color longColor = color.green var color shortColor = color.red var color longFillColor = color.new(color.green, 90) var color shortFillColor = color.new(color.red, 90) var color textColor = color.new(color.white, 0) longStopPlot = plot(dir == 1 ? longStop : na, title='Long Stop', style=plot.style_linebr, linewidth=2, color=color.new(longColor, 0)) buySignal = dir == 1 and dir[1] == -1 plotshape(buySignal ? longStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(longColor, 0)) plotshape(buySignal and showLabels ? longStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=textColor) shortStopPlot = plot(dir == 1 ? na : shortStop, title='Short Stop', style=plot.style_linebr, linewidth=2, color=color.new(shortColor, 0)) sellSignal = dir == -1 and dir[1] == 1 plotshape(sellSignal ? shortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(shortColor, 0)) plotshape(sellSignal and showLabels ? shortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=textColor) midPricePlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false) longStateFillColor = highlightState ? dir == 1 ? longFillColor : na : na shortStateFillColor = highlightState ? dir == -1 ? shortFillColor : na : na fill(midPricePlot, longStopPlot, title='Long State Filling', color=longStateFillColor) fill(midPricePlot, shortStopPlot, title='Short State Filling', color=shortStateFillColor) await = awaitBarConfirmation ? barstate.isconfirmed : true alertcondition(dir != dir[1] and await, title='Alert: CE Direction Change', message='Chandelier Exit has changed direction!') alertcondition(buySignal and await, title='Alert: CE Buy', message='Chandelier Exit Buy!') alertcondition(sellSignal and await, title='Alert: CE Sell', message='Chandelier Exit Sell!')
검색
답변 2
프로필 이미지

예스스탁 예스스탁 답변

2024-04-23 13:24:35

안녕하세요 예스스탁입니다. 1 지표 input : length(22); input : mult(3.0); input : useClose(1);//1:종가기준, 2:고/저가 기준 var : A(0),longStop(0),longStopPrev(0),shortStop(0),shortStopPrev(0); var : dir(1); var : longColor(green),shortColor(red); a = mult * atr(length); longStop = IFf(useClose == 1, highest(close, length) ,highest(H,length)) - a; longStopPrev = iff(IsNan(longStop[1]) == true, longStop,longStop[1]); longStop = iff(close[1] > longStopPrev ,max(longStop, longStopPrev) , longStop); shortStop = IFf(useClose == 1, lowest(close, length) , Lowest(L,length)) + a; shortStopPrev = iff(IsNan(shortStop[1]) == true, shortStop,shortStop[1]); shortStop = iff(close[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop); dir = iff(close > shortStopPrev , 1 , IFF(close < longStopPrev , -1 , dir)); if dir == 1 Then Plot1(longStop,"Long Stop",longColor); Else NoPlot(1); if dir != 1 Then plot2(shortStop, "Short Stop",shortColor); Else NoPlot(2); plot3((o+h+l+c)/4, "중심가",Black); 2 시스템 input : length(22); input : mult(3.0); input : useClose(1);//1:종가기준, 2:고/저가 기준 input : StartTime(160000),EndTime(055700); var : A(0),longStop(0),longStopPrev(0),shortStop(0),shortStopPrev(0); var : dir(1); var : buySignal(False),sellSignal(False); var : Tcond(False); IF Endtime > starttime Then SetStopEndofday(Endtime); Else { if sDate != sDate[1] Then SetStopEndofday(Endtime); } if Bdate != Bdate[1] Then { IF Endtime <= starttime Then { SetStopEndofday(0); } } if (sdate != sdate[1] and stime >= StartTime) or (sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then { Tcond = true; } if (sdate != sdate[1] and stime >= EndTime) or (sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then Tcond = False; a = mult * atr(length); longStop = IFf(useClose == 1, highest(close, length) ,highest(H,length)) - a; longStopPrev = iff(IsNan(longStop[1]) == true, longStop,longStop[1]); longStop = iff(close[1] > longStopPrev ,max(longStop, longStopPrev) , longStop); shortStop = IFf(useClose == 1, lowest(close, length) , Lowest(L,length)) + a; shortStopPrev = iff(IsNan(shortStop[1]) == true, shortStop,shortStop[1]); shortStop = iff(close[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop); dir = iff(close > shortStopPrev , 1 , IFF(close < longStopPrev , -1 , dir)); buySignal = dir == 1 and dir[1] == -1; sellSignal = dir == -1 and dir[1] == 1; if Tcond == true Then { if buySignal == true Then Buy("Buy"); if sellSignal == true Then Sell("Sell"); } 즐거운 하루되세요 > 하날랑 님이 쓴 글입니다. > 제목 : 파인스크립트를 예스랭귀지로 부탁합니다~~ > 다음의 파인스트립드지표를 자동매매에 적용해 보고자 하오니 예스랭귀지로 부탁드립니다. 적용시간은 16:00에서 익일05:57입니다. 다음의 지표에 추가할 것이 있어 매수진입 매수청산 매도진입 매수청산이 되도록 부탁드려봅니다. var string calcGroup = 'Calculation' length = input.int(title='ATR Period', defval=22, group=calcGroup) mult = input.float(title='ATR Multiplier', step=0.1, defval=3.0, group=calcGroup) useClose = input.bool(title='Use Close Price for Extremums', defval=true, group=calcGroup) var string visualGroup = 'Visuals' showLabels = input.bool(title='Show Buy/Sell Labels', defval=true, group=visualGroup) highlightState = input.bool(title='Highlight State', defval=true, group=visualGroup) var string alertGroup = 'Alerts' awaitBarConfirmation = input.bool(title="Await Bar Confirmation", defval=true, group=alertGroup) atr = mult * ta.atr(length) longStop = (useClose ? ta.highest(close, length) : ta.highest(length)) - atr longStopPrev = nz(longStop[1], longStop) longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop shortStop = (useClose ? ta.lowest(close, length) : ta.lowest(length)) + atr shortStopPrev = nz(shortStop[1], shortStop) shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop var int dir = 1 dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir var color longColor = color.green var color shortColor = color.red var color longFillColor = color.new(color.green, 90) var color shortFillColor = color.new(color.red, 90) var color textColor = color.new(color.white, 0) longStopPlot = plot(dir == 1 ? longStop : na, title='Long Stop', style=plot.style_linebr, linewidth=2, color=color.new(longColor, 0)) buySignal = dir == 1 and dir[1] == -1 plotshape(buySignal ? longStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(longColor, 0)) plotshape(buySignal and showLabels ? longStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=textColor) shortStopPlot = plot(dir == 1 ? na : shortStop, title='Short Stop', style=plot.style_linebr, linewidth=2, color=color.new(shortColor, 0)) sellSignal = dir == -1 and dir[1] == 1 plotshape(sellSignal ? shortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(shortColor, 0)) plotshape(sellSignal and showLabels ? shortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=textColor) midPricePlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false) longStateFillColor = highlightState ? dir == 1 ? longFillColor : na : na shortStateFillColor = highlightState ? dir == -1 ? shortFillColor : na : na fill(midPricePlot, longStopPlot, title='Long State Filling', color=longStateFillColor) fill(midPricePlot, shortStopPlot, title='Short State Filling', color=shortStateFillColor) await = awaitBarConfirmation ? barstate.isconfirmed : true alertcondition(dir != dir[1] and await, title='Alert: CE Direction Change', message='Chandelier Exit has changed direction!') alertcondition(buySignal and await, title='Alert: CE Buy', message='Chandelier Exit Buy!') alertcondition(sellSignal and await, title='Alert: CE Sell', message='Chandelier Exit Sell!')
프로필 이미지

하날랑

2024-04-23 16:16:44

대단히 감사합니다. 즐거운 하루 되십시오!!!!!!!!!!!!!! > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 파인스크립트를 예스랭귀지로 부탁합니다~~ > 안녕하세요 예스스탁입니다. 1 지표 input : length(22); input : mult(3.0); input : useClose(1);//1:종가기준, 2:고/저가 기준 var : A(0),longStop(0),longStopPrev(0),shortStop(0),shortStopPrev(0); var : dir(1); var : longColor(green),shortColor(red); a = mult * atr(length); longStop = IFf(useClose == 1, highest(close, length) ,highest(H,length)) - a; longStopPrev = iff(IsNan(longStop[1]) == true, longStop,longStop[1]); longStop = iff(close[1] > longStopPrev ,max(longStop, longStopPrev) , longStop); shortStop = IFf(useClose == 1, lowest(close, length) , Lowest(L,length)) + a; shortStopPrev = iff(IsNan(shortStop[1]) == true, shortStop,shortStop[1]); shortStop = iff(close[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop); dir = iff(close > shortStopPrev , 1 , IFF(close < longStopPrev , -1 , dir)); if dir == 1 Then Plot1(longStop,"Long Stop",longColor); Else NoPlot(1); if dir != 1 Then plot2(shortStop, "Short Stop",shortColor); Else NoPlot(2); plot3((o+h+l+c)/4, "중심가",Black); 2 시스템 input : length(22); input : mult(3.0); input : useClose(1);//1:종가기준, 2:고/저가 기준 input : StartTime(160000),EndTime(055700); var : A(0),longStop(0),longStopPrev(0),shortStop(0),shortStopPrev(0); var : dir(1); var : buySignal(False),sellSignal(False); var : Tcond(False); IF Endtime > starttime Then SetStopEndofday(Endtime); Else { if sDate != sDate[1] Then SetStopEndofday(Endtime); } if Bdate != Bdate[1] Then { IF Endtime <= starttime Then { SetStopEndofday(0); } } if (sdate != sdate[1] and stime >= StartTime) or (sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then { Tcond = true; } if (sdate != sdate[1] and stime >= EndTime) or (sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then Tcond = False; a = mult * atr(length); longStop = IFf(useClose == 1, highest(close, length) ,highest(H,length)) - a; longStopPrev = iff(IsNan(longStop[1]) == true, longStop,longStop[1]); longStop = iff(close[1] > longStopPrev ,max(longStop, longStopPrev) , longStop); shortStop = IFf(useClose == 1, lowest(close, length) , Lowest(L,length)) + a; shortStopPrev = iff(IsNan(shortStop[1]) == true, shortStop,shortStop[1]); shortStop = iff(close[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop); dir = iff(close > shortStopPrev , 1 , IFF(close < longStopPrev , -1 , dir)); buySignal = dir == 1 and dir[1] == -1; sellSignal = dir == -1 and dir[1] == 1; if Tcond == true Then { if buySignal == true Then Buy("Buy"); if sellSignal == true Then Sell("Sell"); } 즐거운 하루되세요 > 하날랑 님이 쓴 글입니다. > 제목 : 파인스크립트를 예스랭귀지로 부탁합니다~~ > 다음의 파인스트립드지표를 자동매매에 적용해 보고자 하오니 예스랭귀지로 부탁드립니다. 적용시간은 16:00에서 익일05:57입니다. 다음의 지표에 추가할 것이 있어 매수진입 매수청산 매도진입 매수청산이 되도록 부탁드려봅니다. var string calcGroup = 'Calculation' length = input.int(title='ATR Period', defval=22, group=calcGroup) mult = input.float(title='ATR Multiplier', step=0.1, defval=3.0, group=calcGroup) useClose = input.bool(title='Use Close Price for Extremums', defval=true, group=calcGroup) var string visualGroup = 'Visuals' showLabels = input.bool(title='Show Buy/Sell Labels', defval=true, group=visualGroup) highlightState = input.bool(title='Highlight State', defval=true, group=visualGroup) var string alertGroup = 'Alerts' awaitBarConfirmation = input.bool(title="Await Bar Confirmation", defval=true, group=alertGroup) atr = mult * ta.atr(length) longStop = (useClose ? ta.highest(close, length) : ta.highest(length)) - atr longStopPrev = nz(longStop[1], longStop) longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop shortStop = (useClose ? ta.lowest(close, length) : ta.lowest(length)) + atr shortStopPrev = nz(shortStop[1], shortStop) shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop var int dir = 1 dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir var color longColor = color.green var color shortColor = color.red var color longFillColor = color.new(color.green, 90) var color shortFillColor = color.new(color.red, 90) var color textColor = color.new(color.white, 0) longStopPlot = plot(dir == 1 ? longStop : na, title='Long Stop', style=plot.style_linebr, linewidth=2, color=color.new(longColor, 0)) buySignal = dir == 1 and dir[1] == -1 plotshape(buySignal ? longStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(longColor, 0)) plotshape(buySignal and showLabels ? longStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=textColor) shortStopPlot = plot(dir == 1 ? na : shortStop, title='Short Stop', style=plot.style_linebr, linewidth=2, color=color.new(shortColor, 0)) sellSignal = dir == -1 and dir[1] == 1 plotshape(sellSignal ? shortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(shortColor, 0)) plotshape(sellSignal and showLabels ? shortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=textColor) midPricePlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false) longStateFillColor = highlightState ? dir == 1 ? longFillColor : na : na shortStateFillColor = highlightState ? dir == -1 ? shortFillColor : na : na fill(midPricePlot, longStopPlot, title='Long State Filling', color=longStateFillColor) fill(midPricePlot, shortStopPlot, title='Short State Filling', color=shortStateFillColor) await = awaitBarConfirmation ? barstate.isconfirmed : true alertcondition(dir != dir[1] and await, title='Alert: CE Direction Change', message='Chandelier Exit has changed direction!') alertcondition(buySignal and await, title='Alert: CE Buy', message='Chandelier Exit Buy!') alertcondition(sellSignal and await, title='Alert: CE Sell', message='Chandelier Exit Sell!')