커뮤니티

문의드립니다.

프로필 이미지
천외일성
2021-02-25 22:20:39
701
글번호 146659
답변완료
아래수식을 예스로 부탁합니다. amplitude = input(title="Amplitude", defval=2) channelDeviation = input(title="Channel Deviation", defval=2) showArrows = input(title="Show Arrows", defval=true) showChannels = input(title="Show Channels", defval=true) var int trend = 0 var int nextTrend = 0 var float maxLowPrice = nz(low[1], low) var float minHighPrice = nz(high[1], high) var float up = 0.0 var float down = 0.0 float atrHigh = 0.0 float atrLow = 0.0 float arrowUp = na float arrowDown = na atr2 = atr(100) / 2 dev = channelDeviation * atr2 highPrice = high[abs(highestbars(amplitude))] lowPrice = low[abs(lowestbars(amplitude))] highma = sma(high, amplitude) lowma = sma(low, amplitude) if nextTrend == 1 maxLowPrice := max(lowPrice, maxLowPrice) if highma < maxLowPrice and close < nz(low[1], low) trend := 1 nextTrend := 0 minHighPrice := highPrice else minHighPrice := min(highPrice, minHighPrice) if lowma > minHighPrice and close > nz(high[1], high) trend := 0 nextTrend := 1 maxLowPrice := lowPrice if trend == 0 if not na(trend[1]) and trend[1] != 0 up := na(down[1]) ? down : down[1] arrowUp := up - atr2 else up := na(up[1]) ? maxLowPrice : max(maxLowPrice, up[1]) atrHigh := up + dev atrLow := up - dev else if not na(trend[1]) and trend[1] != 1 down := na(up[1]) ? up : up[1] arrowDown := down + atr2 else down := na(down[1]) ? minHighPrice : min(minHighPrice, down[1]) atrHigh := down + dev atrLow := down - dev ht = trend == 0 ? up : down var color buyColor = color.blue var color sellColor = color.red htColor = trend == 0 ? buyColor : sellColor htPlot = plot(ht, title="HalfTrend", linewidth=2, color=htColor) atrHighPlot = plot(showChannels ? atrHigh : na, title="ATR High", style=plot.style_circles, color=sellColor) atrLowPlot = plot(showChannels ? atrLow : na, title="ATR Low", style=plot.style_circles, color=buyColor) fill(htPlot, atrHighPlot, title="ATR High Ribbon", color=sellColor) fill(htPlot, atrLowPlot, title="ATR Low Ribbon", color=buyColor) buySignal = not na(arrowUp) and (trend == 0 and trend[1] == 1) sellSignal = not na(arrowDown) and (trend == 1 and trend[1] == 0) plotshape(showArrows and buySignal ? atrLow : na, title="Arrow Up", style=shape.triangleup, location=location.absolute, size=size.tiny, color=buyColor) plotshape(showArrows and sellSignal ? atrHigh : na, title="Arrow Down", style=shape.triangledown, location=location.absolute, size=size.tiny, color=sellColor) alertcondition(buySignal, title="Alert: HalfTrend Buy", message="HalfTrend Buy") alertcondition(sellSignal, title="Alert: HalfTrend Sell", message="HalfTrend Sell")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-02-26 13:14:27

안녕하세요 예스스탁입니다. 1 지표 input : amplitude(2),channelDeviation(2); var : trend(0),nextTrend(0),maxLowPrice(0),minHighPrice(0); var : up(0),down(0),atrHigh(0),atrLow(0),arrowUp(0),arrowDown(0); var : atr2(0),dev(0),highPrice(0),lowPrice(0),highma(0),lowma(0),ht(0); maxLowPrice = iff(isnan(low[1]) == true,Low,Low[1]); minHighPrice = iff(isnan(high[1]) == true,high,high[1]); atr2 = atr(100) / 2; dev = channelDeviation * atr2; highPrice = Highest(H,amplitude); lowPrice = Lowest(L,amplitude); highma = ma(high, amplitude); lowma = ma(low, amplitude); if nextTrend == 1 Then { maxLowPrice = max(lowPrice, maxLowPrice); if highma < maxLowPrice and close < maxLowPrice Then { trend = 1; nextTrend = 0; minHighPrice = highPrice; } } else { minHighPrice = min(highPrice, minHighPrice); if lowma > minHighPrice and close > minHighPrice Then { trend = 0; nextTrend = 1; maxLowPrice = lowPrice; } } if trend == 0 Then { if IsNaN(trend[1]) == False and trend[1] != 0 Then { up = iff(IsNaN(down[1]) == true,down,down[1]); arrowUp = up - atr2; } else { up = iff(IsNan(up[1]) == true, maxLowPrice , max(maxLowPrice, up[1])); } atrHigh = up + dev; atrLow = up - dev; } else { if isnan(trend[1]) == False and trend[1] != 1 Then { down = iff(IsNan(up[1]) == true, up , up[1]); arrowDown = down + atr2; } else { down = iff(IsNan(down[1]) == true, minHighPrice ,min(minHighPrice, down[1])); } atrHigh = down + dev; atrLow = down - dev; } ht = iff(trend == 0 , up , down); plot1(ht, "HalfTrend",iff(trend == 0 ,BLUE,RED)); plot2(atrHigh,"ATR High",RED); plot3(atrLow, "ATR Low", BLUE); 2 시스템 input : amplitude(2),channelDeviation(2); var : trend(0),nextTrend(0),maxLowPrice(0),minHighPrice(0); var : up(0),down(0),atrHigh(0),atrLow(0),arrowUp(0),arrowDown(0); var : atr2(0),dev(0),highPrice(0),lowPrice(0),highma(0),lowma(0),ht(0); maxLowPrice = iff(isnan(low[1]) == true,Low,Low[1]); minHighPrice = iff(isnan(high[1]) == true,high,high[1]); atr2 = atr(100) / 2; dev = channelDeviation * atr2; highPrice = Highest(H,amplitude); lowPrice = Lowest(L,amplitude); highma = ma(high, amplitude); lowma = ma(low, amplitude); if nextTrend == 1 Then { maxLowPrice = max(lowPrice, maxLowPrice); if highma < maxLowPrice and close < maxLowPrice Then { trend = 1; nextTrend = 0; minHighPrice = highPrice; } } else { minHighPrice = min(highPrice, minHighPrice); if lowma > minHighPrice and close > minHighPrice Then { trend = 0; nextTrend = 1; maxLowPrice = lowPrice; } } if trend == 0 Then { if IsNaN(trend[1]) == False and trend[1] != 0 Then { up = iff(IsNaN(down[1]) == true,down,down[1]); arrowUp = up - atr2; } else { up = iff(IsNan(up[1]) == true, maxLowPrice , max(maxLowPrice, up[1])); } atrHigh = up + dev; atrLow = up - dev; } else { if isnan(trend[1]) == False and trend[1] != 1 Then { down = iff(IsNan(up[1]) == true, up , up[1]); arrowDown = down + atr2; } else { down = iff(IsNan(down[1]) == true, minHighPrice ,min(minHighPrice, down[1])); } atrHigh = down + dev; atrLow = down - dev; } ht = iff(trend == 0 , up , down); if IsNaN(arrowup) == False and trend == 0 and trend[1] == 1 then Buy(); if IsNaN(arrowDown) == False and trend == 1 and trend[1] == 0 Then Sell(); 즐거운 하루되세요 > 천외일성 님이 쓴 글입니다. > 제목 : 문의드립니다. > 아래수식을 예스로 부탁합니다. amplitude = input(title="Amplitude", defval=2) channelDeviation = input(title="Channel Deviation", defval=2) showArrows = input(title="Show Arrows", defval=true) showChannels = input(title="Show Channels", defval=true) var int trend = 0 var int nextTrend = 0 var float maxLowPrice = nz(low[1], low) var float minHighPrice = nz(high[1], high) var float up = 0.0 var float down = 0.0 float atrHigh = 0.0 float atrLow = 0.0 float arrowUp = na float arrowDown = na atr2 = atr(100) / 2 dev = channelDeviation * atr2 highPrice = high[abs(highestbars(amplitude))] lowPrice = low[abs(lowestbars(amplitude))] highma = sma(high, amplitude) lowma = sma(low, amplitude) if nextTrend == 1 maxLowPrice := max(lowPrice, maxLowPrice) if highma < maxLowPrice and close < nz(low[1], low) trend := 1 nextTrend := 0 minHighPrice := highPrice else minHighPrice := min(highPrice, minHighPrice) if lowma > minHighPrice and close > nz(high[1], high) trend := 0 nextTrend := 1 maxLowPrice := lowPrice if trend == 0 if not na(trend[1]) and trend[1] != 0 up := na(down[1]) ? down : down[1] arrowUp := up - atr2 else up := na(up[1]) ? maxLowPrice : max(maxLowPrice, up[1]) atrHigh := up + dev atrLow := up - dev else if not na(trend[1]) and trend[1] != 1 down := na(up[1]) ? up : up[1] arrowDown := down + atr2 else down := na(down[1]) ? minHighPrice : min(minHighPrice, down[1]) atrHigh := down + dev atrLow := down - dev ht = trend == 0 ? up : down var color buyColor = color.blue var color sellColor = color.red htColor = trend == 0 ? buyColor : sellColor htPlot = plot(ht, title="HalfTrend", linewidth=2, color=htColor) atrHighPlot = plot(showChannels ? atrHigh : na, title="ATR High", style=plot.style_circles, color=sellColor) atrLowPlot = plot(showChannels ? atrLow : na, title="ATR Low", style=plot.style_circles, color=buyColor) fill(htPlot, atrHighPlot, title="ATR High Ribbon", color=sellColor) fill(htPlot, atrLowPlot, title="ATR Low Ribbon", color=buyColor) buySignal = not na(arrowUp) and (trend == 0 and trend[1] == 1) sellSignal = not na(arrowDown) and (trend == 1 and trend[1] == 0) plotshape(showArrows and buySignal ? atrLow : na, title="Arrow Up", style=shape.triangleup, location=location.absolute, size=size.tiny, color=buyColor) plotshape(showArrows and sellSignal ? atrHigh : na, title="Arrow Down", style=shape.triangledown, location=location.absolute, size=size.tiny, color=sellColor) alertcondition(buySignal, title="Alert: HalfTrend Buy", message="HalfTrend Buy") alertcondition(sellSignal, title="Alert: HalfTrend Sell", message="HalfTrend Sell")