피보나치 리트레이싱 동적 스톱 로스 전략

저자:차오장, 날짜: 2024-02-06 14:33:06
태그:

img

전반적인 설명

이 전략은 피보나치 리트레이싱 레벨을 사용하여 자동으로 스톱 로스를 설정하고 포지션 관리를 위해 수익 가격을 취합니다. 통합 과정에서 손실을 완화하면서 더 큰 이익을위한 트렌드를 탈 수 있습니다.

전략 논리

이 전략의 핵심은 피보나치 리트레이스먼트 지표에 의존하여 주요 지원 및 저항 수준을 결정합니다. 최근 최고와 최하위를 추적하여 10 개의 피보나치 가격 영역을 그래프합니다. 구성에 따라 피보나치 레벨 중 하나를 엔트리 트리거로 선택합니다. 가격이 그 수준을 넘으면 구성 된 레버리지를 기반으로 긴 주문이 제공됩니다. 동시에 엔트리 가격보다 특정 비율로 수익을 취하는 가격을 설정합니다.

입점 후, 전략은 업데이트 된 피보나치 수준을 추적합니다. 잠재적인 반전을 나타내는 낮은 Fib 수준이 나타나면 전략은 기존 주문을 취소하고 Stop Loss 메커니즘으로 낮은 가격으로 주문을 다시 배치합니다. 가격이 결국 이윤을 취하는 가격 이상으로 넘어지면, 포지션은 이익을 위해 폐쇄됩니다.

장점

이 전략의 가장 큰 장점은 동적으로 중지 손실을 조정하고 트렌딩 시장에 대한 수익 가격을 취할 수있는 능력입니다. 주요 특징:

  1. 진입 가격에 기반한 트레일링 스톱을 통해 트렌드 조건에서 더 큰 이익을 얻습니다.

  2. 고집합에서 손실을 완화하기 위해 낮은 FIB 수준에서 중단합니다.

  3. 피라미딩을 허용합니다. 마지막 진입 가격에서 가격이 특정 비율로 떨어지면 포지션에 추가합니다.

  4. 자동으로 주문을 할 수 있습니다.

위험성

여전히 주의해야 할 몇 가지 위험 요소가 있습니다.

  1. 시장을 가로질러 반복적으로 정지하는 경향이 있고, 수수료를 올리는 경향이 있습니다.

  2. 고정된 스톱 로스 메커니즘이 없어 큰 마감 위험이 있습니다.

  3. 피라미드 조립은 손실을 악화시킬 수 있습니다.

대응 솔루션:

  1. 가격 범위에서 변동할 때 거래를 중지합니다.

  2. 수동으로 시장을 감시하고 필요한 경우 포지션을 닫습니다.

  3. 피라미드 명령에 한계를 두세요.

더 나은 기회

최적화 할 여지가 있습니다.

  1. EMA, MACD와 같은 추가 지표를 추가로 추가로 입력 확인을 위해 추가로 추가로 입력하여 가짜 브레이크오웃을 피합니다.

  2. 극한 조건에서 손실을 제한하기 위해 고정/추적 스톱 손실 메커니즘을 포함합니다.

  3. 시장 체제에 기반한 피라미드 논리를 정비하여 과잉 지분을 방지하기 위해서입니다.

  4. LSTM와 같은 기계 학습 모델을 사용하여 가격을 예측하고 더 나은 입출구를 식별합니다.

결론

요약하자면, 이 전략은 트렌드 퇴색 시나리오에 적합합니다. 끊임없이 정지 조정함으로써 트렌드를 효과적으로 탈 수 있습니다. 더 까다로운 시장 조건을 처리하는 데 적절한 최적화와 보호 경로가 필요합니다.


/*backtest
start: 2024-01-06 00:00:00
end: 2024-02-05 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CryptoRox

//@version=4
//Paste the line below in your alerts to run the built-in commands.
//{{strategy.order.alert_message}}
strategy(title="Fibs limit only", shorttitle="Strategy", overlay=true, precision=8, pyramiding=1000, commission_type=strategy.commission.percent, commission_value=0.04)

//Settings 
testing = input(false, "Live")
//Use epochconverter or something similar to get the current timestamp.
starttime = input(1600976975, "Start Timestamp") * 1000
//Wait XX seconds from that timestamp before the strategy starts looking for an entry.
seconds = input(60, "Start Delay") * 1000
testPeriod = true


leverage = input(1, "Leverage")
tp = input(1.0, "Take Profit %") / leverage
dca = input(-1.0, "DCA when < %") / leverage *-1
fibEntry = input("1", "Entry Level", options=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"])

//Strategy Calls
equity = strategy.equity
avg = strategy.position_avg_price
symbol = syminfo.tickerid
openTrades = strategy.opentrades
closedTrades = strategy.closedtrades
size = strategy.position_size

//Fibs
lentt = input(60, "Pivot Length")
h = highest(lentt)
h1 = dev(h, lentt) ? na : h
hpivot = fixnan(h1)
l = lowest(lentt)
l1 = dev(l, lentt) ? na : l
lpivot = fixnan(l1)
z = 400
p_offset= 2
transp = 60
a=(lowest(z)+highest(z))/2
b=lowest(z)
c=highest(z)

fib0 = (((hpivot - lpivot)) + lpivot)
fib1 = (((hpivot - lpivot)*.21) + lpivot)
fib2 = (((hpivot - lpivot)*.3) + lpivot)
fib3 = (((hpivot - lpivot)*.5) + lpivot)
fib4 = (((hpivot - lpivot)*.62) + lpivot)
fib5 = (((hpivot - lpivot)*.7) + lpivot)
fib6 = (((hpivot - lpivot)* 1.00) + lpivot)
fib7 = (((hpivot - lpivot)* 1.27) + lpivot)
fib8 = (((hpivot - lpivot)* 2) + lpivot)
fib9 = (((hpivot - lpivot)* -.27) + lpivot)
fib10 = (((hpivot - lpivot)* -1) + lpivot)

notna = nz(fib10[60])
entry = 0.0
if fibEntry == "1"
    entry := fib10
if fibEntry == "2"
    entry := fib9
if fibEntry == "3"
    entry := fib0
if fibEntry == "4"
    entry := fib1
if fibEntry == "5"
    entry := fib2
if fibEntry == "6"
    entry := fib3
if fibEntry == "7"
    entry := fib4
if fibEntry == "8"
    entry := fib5
if fibEntry == "9"
    entry := fib6
if fibEntry == "10"
    entry := fib7
profit = avg+avg*(tp/100)
pause = 0
pause := nz(pause[1])
paused = time < pause

fill = 0.0
fill := nz(fill[1])
count = 0.0
count := nz(fill[1])

filled = count > 0 ? entry > fill-fill/100*dca : 0
signal = testPeriod and notna and not paused and not filled ? 1 : 0

neworder = crossover(signal, signal[1])
moveorder = entry != entry[1] and signal and not neworder ? true : false
cancelorder = crossunder(signal, signal[1]) and not paused
filledorder = crossunder(low[1], entry[1]) and signal[1]

last_profit = 0.0
last_profit := nz(last_profit[1])

if neworder and signal
    strategy.order("New", 1, 0.0001, alert_message='New Order|e=binancefuturestestnet s=btcusdt b=long q=0.0011 fp=' + tostring(entry)) 
if moveorder
    strategy.order("Move", 1, 0.0001, alert_message='Move Order|e=binancefuturestestnet s=btcusdt b=long c=order|e=binancefuturestestnet s=btcusdt b=long q=0.0011 fp=' + tostring(entry))
if filledorder and size < 1
    fill := entry
    count := count+1 
    pause := time + 60000
    p = close+close*(tp/100)
    strategy.entry("Filled", 1, 1,  alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + tostring(p))
if filledorder and size >= 1
    fill := entry
    count := count+1 
    pause := time + 60000
    strategy.entry("Filled", 1, 1,  alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + tostring(profit))

if cancelorder and not filledorder
    pause := time + 60000
    strategy.order("Cancel", 1, 0.0001,  alert_message='Cancel Order|e=binancefuturestestnet s=btcusdt b=long c=order')

if filledorder
    last_profit := profit

closeit = crossover(high, profit) and size >= 1
if closeit
    strategy.entry("Close ALL", 0, 0, alert_message='Profit')
    count := 0
    fill := 0.0
    last_profit := 0.0
    
//Plots
bottom = signal ? color.green : filled ? color.red : color.white
plot(entry, "Entry", bottom)

더 많은