이 글은 파동대역인식을 이용한 반전으로 긴줄을 양자화한 거래의 한 전략에 대해 자세히 소개한다. 이 전략은 가격의 파동대역을 뚫고 구매를 하는 것으로 진행 추세를 추적하는 작업을 수행한다.
1 전략
이 전략의 핵심 지표는 변동역이며, 구체적인 계산 단계는 다음과 같습니다.
중간, 상단, 하단의 이동 평균선을 계산합니다.
가격 하향에서 하향으로 하락할 때 구매 신호를 생성합니다.
“가격이 경로를 돌파할 때, 판매 신호가 발생한다.
신호를 팔 때 또는 경로를 돌파할 때 정지 탈퇴를 선택할 수 있다.
스톱 손실은 고정 비율 스톱 손실로 설정됩니다.
이렇게 하면, 가격이 하향 단계에 있을 때 구매할 수 있고, 그 다음에는 스톱 스톱 또는 스톱 로즈로 탈퇴하여 역전 동작을 구현할 수 있다.
2 전략적 장점
이 전략의 가장 큰 장점은 파동대를 이용한 반전점 지점을 식별하는 것으로, 이는 보다 성숙한 기술 분석 방법이다.
또 다른 장점은 단편 거래의 위험을 통제할 수 있는 스톱로스 메커니즘을 설정하는 것입니다.
마지막으로, 분량 매장도 회전 후 분량 매출을 올리는 데 도움이 됩니다.
그러나 이 전략에는 몇 가지 잠재적인 문제점이 있습니다.
우선, 이동평균 계산이 뒤쳐져 있고, 최적의 구매 시기를 놓칠 수도 있습니다.
두 번째, 정지점과 정지점의 설정은 세심한 테스트와 최적화를 필요로 합니다.
마지막으로, 긴 선의 포지션은 철수 압박을 받습니다.
네 가지 내용
이 글은 파동대 반전을 이용한 긴 선의 양적 거래 전략에 대해 자세히 소개한다. 이는 가격 반전 기회를 효과적으로 식별하고 긴 선의 보유를 실현할 수 있다. 그러나 이동 평균선 지연과 같은 문제를 방지하고 스톱 스톱 손실을 최적화해야 한다.
/*backtest
start: 2023-09-07 00:00:00
end: 2023-09-12 04:00:00
period: 14m
basePeriod: 1m
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/
// © ediks123
//strategy logic has been borrowed from ceyhun and tweaked the settings for back testing
//@version=4
//SPY 4 hrs settings 8, 13 , 3.33 , 0.9 on 4 hrs chart
//QQQ above settings is good , but 13, 13 has less number of bars
//QQQ 4 hrs settings 13, 13 , 3.33 , 0.9 on 4 hrs chart
strategy(title="Volatility Bands Reversal Strategy", shorttitle="VolatilityBandReversal" , overlay=true, pyramiding=2, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed,
av = input(8, title="Band Average")
vp = input(13, title="Volatility Period")
df = input(3.33,title="Deviation Factor",minval=0.1)
lba = input(0.9,title="Lower Band Adjustment",minval=0.1)
riskCapital = input(title="Risk % of capital", defval=10, minval=1)
stopLoss=input(6,title="Stop Loss",minval=1)
exitOn=input(title="Exit on", defval="touch_upperband", options=["Sell_Signal", "touch_upperband"])
src = hlc3
typical = src >= src[1] ? src - low[1] : src[1] - low
deviation = sum( typical , vp )/ vp * df
devHigh = ema(deviation, av)
devLow = lba * devHigh
medianAvg = ema(src, av)
emaMediaAvg=ema(medianAvg, av)
upperBandVal= emaMediaAvg + devHigh
lowerbandVal= emaMediaAvg - devLow
MidLineVal=sma(medianAvg, av)
UpperBand = plot ( upperBandVal, color=#EE82EE, linewidth=2, title="UpperBand")
LowerBand = plot ( lowerbandVal , color=#EE82EE, linewidth=2, title="LowerBand")
MidLine = plot (MidLineVal, color=color.blue, linewidth=2, title="MidLine")
buyLine = plot ( (lowerbandVal + MidLineVal )/2 , color=color.blue, title="BuyLine")
up=ema(medianAvg, av) + devHigh
down=ema(medianAvg, av) - devLow
ema50=ema(hlc3,50)
plot ( ema50, color=color.orange, linewidth=2, title="ema 50")
//outer deviation
//deviation1 = sum( typical , vp )/ vp * 4
//devHigh1 = ema(deviation, av)
//devLow1 = lba * devHigh
//medianAvg1 = ema(src, av)
//UpperBand1 = plot (emaMediaAvg + devHigh1, color=color.red, linewidth=3, title="UpperBand1")
//LowerBand1 = plot (emaMediaAvg - devLow1, color=color.red, linewidth=3, title="LowerBand1")
//
///Entry Rules
//1)First candle close below the Lower Band of the volatility Band
//2)Second candle close above the lower band
//3)Third Candle closes above previous candle
Buy = close[2] < down[2] and close[1]>down[1] and close>close[1]
//plotshape(Buy,color=color.blue,style=shape.arrowup,location=location.belowbar, text="Buy")
//barcolor(close[2] < down[2] and close[1]>down[1] and close>close[1] ? color.blue :na )
//bgcolor(close[2] < down[2] and close[1]>down[1] and close>close[1] ? color.green :na )
///Exit Rules
//1)One can have a static stops initially followed by an trailing stop based on the risk the people are willing to take
//2)One can exit with human based decisions or predefined target exits. Choice of deciding the stop loss and profit targets are left to the readers.
Sell = close[2] > up[2] and close[1]<up[1] and close<close[1]
//plotshape(Sell,color=color.red,style=shape.arrowup,text="Sell")
barcolor(close[2] > up[2] and close[1]<up[1] and close<close[1] ? color.yellow :na )
bgcolor(close[2] > up[2] and close[1]<up[1] and close<close[1] ? color.red :na )
//Buyer = crossover(close,Buy)
//Seller = crossunder(close,Sell)
//alertcondition(Buyer, title="Buy Signal", message="Buy")
//alertcondition(Seller, title="Sell Signal", message="Sell")
//Entry--
//Echeck how many units can be purchased based on risk manage ment and stop loss
qty1 = (strategy.equity * riskCapital / 100 ) / (close*stopLoss/100)
//check if cash is sufficient to buy qty1 , if capital not available use the available capital only
qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1
strategy.entry(id="vbLE", long=true, qty=qty1, when=Buy)
bgcolor(strategy.position_size>=1 ? color.blue : na)
// stop loss exit
stopLossVal = strategy.position_size>=1 ? strategy.position_avg_price * ( 1 - (stopLoss/100) ) : 0.00
//draw initil stop loss
plot(strategy.position_size>=1 ? stopLossVal : na, color = color.purple , style=plot.style_linebr, linewidth = 2, title = "stop loss") //, trackprice=true)
strategy.close(id="vbLE", comment="SL exit Loss is "+tostring(close - strategy.position_avg_price, "###.##") , when=abs(strategy.position_size)>=1 and close < stopLossVal )
//close on Sell_Signal
strategy.close(id="vbLE", comment="Profit is : "+tostring(close - strategy.position_avg_price, "###.##") , when=strategy.position_size>=1 and exitOn=="Sell_Signal" and Sell)
//close on touch_upperband
strategy.close(id="vbLE", comment="Profit is : "+tostring(close - strategy.position_avg_price, "###.##") , when=strategy.position_size>=1 and exitOn=="touch_upperband" and (crossover(close, up) or crossover(high, up)))