
이 전략은 PIVOT 고저점과 돌파점을 기반으로 암호화폐의 트렌드 반전을 판단하는 것으로, 돌파점 반전 전략에 속한다. 전략은 먼저 지표의 가장 최근의 기간 동안의 최고 가격과 최저 가격 PIVOT 점을 계산하고, 그 다음 가격이 이러한 핵심 포인트 지점을 돌파한 후 반전이 발생했는지 판단하여 큰 트렌드 변화를 포착한다.
ta.pivothigh() 와 ta.pivotlow() 함수를 사용하여 최근 특정 바의 최고 가격점과 최저 가격점을 핵심 PIVOT 포인트로 계산한다.
만약 가격이 PIVOT LOWS를 상향으로 돌파하거나 PIVOT HIGHS를 하향으로 돌파한다면, 트렌드가 반전되었다는 판단을 한다.
가격 PIVOT 점보다 어느 정도의 폭을 뚫고 150bar의 종결 가격을 넘어야 함으로써, 주축을 피할 수 있다.
구매 조건이 발생하면 더 많은 입장을 하고, 판매 조건이 발생하면 더 많은 상표를 평정한다. 공상 상표 입출구를 판단하는 것과 비슷하다.
이 전략은 전체적으로 안정적이어서 큰 반전을 잡기에 적합하다. 그러나 위험을 통제하고, 변수를 다른 통화에 맞게 조정하는 데 주의를 기울여야 한다. 변수 최적화와 풍력 제어의 기초에 이 전략은 더 좋은 효과를 얻을 수 있다고 믿는다.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nkrastins95
//@version=5
strategy("Swing Hi Lo", overlay=true, margin_long=100, margin_short=100)
//-----------------------------------------------------------------------------------------------------------------------//
tf = input.timeframe(title="Timeframe", defval="")
gr="LENGTH LEFT / RIGHT"
leftLenH = input.int(title="Pivot High", defval=10, minval=1, inline="Pivot High",group=gr)
rightLenH = input.int(title="/", defval=10, minval=1, inline="Pivot High",group=gr)
colorH = input(title="", defval=color.red, inline="Pivot High",group=gr)
leftLenL = input.int(title="Pivot Low", defval=10, minval=1, inline="Pivot Low", group=gr)
rightLenL = input.int(title="/", defval=10, minval=1, inline="Pivot Low",group=gr)
colorL = input(title="", defval=color.blue, inline="Pivot Low",group=gr)
//-----------------------------------------------------------------------------------------------------------------------//
pivotHigh(ll, rl) =>
maxLen = 1000
float ph = ta.pivothigh(ll, rl)
int offset = 0
while offset < maxLen
if not na(ph[offset])
break
offset := offset + 1
ph[offset]
pivotLow(ll, rl) =>
maxLen = 1000
float pl = ta.pivotlow(ll, rl)
int offset = 0
while offset < maxLen
if not na(pl[offset])
break
offset := offset + 1
pl[offset]
//-----------------------------------------------------------------------------------------------------------------------//
ph = request.security(syminfo.tickerid, tf, pivotHigh(leftLenH, rightLenH), barmerge.gaps_off, barmerge.lookahead_on)
pl = request.security(syminfo.tickerid, tf, pivotLow(leftLenL, rightLenL), barmerge.gaps_off, barmerge.lookahead_on)
drawLabel(_offset, _pivot, _style, _color) =>
if not na(_pivot)
label.new(bar_index[_offset], _pivot, str.tostring(_pivot, format.mintick), style=_style, color=_color, textcolor=#131722)
//-----------------------------------------------------------------------------------------------------------------------//
VWAP = ta.vwap(ohlc4)
longcondition = ta.crossunder(close,pl) and close > close[150]
exitcondition = close > ph
shortcondition = ta.crossover(close,ph) and close < close[150]
covercondition = close < pl
strategy.entry("long", strategy.long, when = longcondition)
strategy.close("long", when = exitcondition)
strategy.entry("Short", strategy.short, when = shortcondition)
strategy.close("Short", when = covercondition)