흠 이 없는 승리 전략

저자:차오장, 날짜: 2022-05-25 17:08:13
태그:RMASMA

안녕하세요, 저는 트레이딩뷰에 머신러닝을 제공하는 무거운 파이썬 프로그래머입니다. 이 15분 비트코인 로그 전략은 머신러닝 라이브러리와 파이썬에서 1년 동안의 역사적 데이터를 사용하여 만들어졌습니다. 모든 매개 변수는 15분 차트에서 비트코인의 가장 수익성 있는 구매 및 판매 신호를 가져오기 위해 하이퍼 최적화되었습니다. 이 역사적인 비트코인 데이터는 바이낸스 API에서 수집되었습니다. 이 장기 전략을 사용하는 가장 좋은 거래소를 알고 싶다면 말이죠. 트레이딩뷰 설정에 포함된 두 가지 버전의 간단한 볼링거 밴드 및 RSI 전략입니다. 첫 번째 버전은 7.5의 샤프 비율이 놀랍고, 두 번째 버전은 2.5의 샤프 테스트 비율로 최고의 스톱 러스 및 수익 포지션을 포함합니다. 트레이딩 전략이 어떻게 작동하는지 조금 더 이야기해 보겠습니다. 하이퍼 테스트 신호는 EPO와 같은 Bollinger Band Devd 1의 마이너스 가격이 마이너스 가격보다 낮을 때 작동합니다. 이 머신러닝 머신에서는 어떤 전략이 더 수익성 높은지 또는 마이너스 가격보다 높은지 알고 싶습니다. 이 전략에 대해 항상 궁금한 질문이 있습니다

P.S. 당신은 항상 더 많은 이익을 위해 이 전략을 피라미드 할 수 있습니다! 나는 단지 나의 전략을 만들 때 피라미드를 추가하지 않습니다. 왜냐하면 나는 당신에게 진정한 승/패 비율을 보여주고 싶어하기 때문입니다. 한 번 구매하고 한 번 판매를 기반으로합니다.

백테스트

img


/*backtest
start: 2022-04-24 00:00:00
end: 2022-05-23 23:59:00
period: 2h
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/
// © Bunghole

//@version=4
strategy(overlay=true, shorttitle="Flawless Victory Strategy", default_qty_type = strategy.percent_of_equity, initial_capital = 100000, default_qty_value = 100, pyramiding = 0, title="Flawless Victory Strategy", currency = 'USD')

////////// ** Inputs ** //////////

// Stoploss and Profits Inputs

v1 = input(true, title="Version 1 - Doesn't Use SL/TP")
v2 = input(false, title="Version 2 - Uses SL/TP")
v3 = input(false, title="Version 3 - Uses SL/TP")
v2stoploss_input = input(6.604, title='Stop Loss %', type=input.float, minval=0.01)/100
v2takeprofit_input = input(2.328, title='Take Profit %', type=input.float, minval=0.01)/100
v2stoploss_level = strategy.position_avg_price * (1 - v2stoploss_input)
v2takeprofit_level = strategy.position_avg_price * (1 + v2takeprofit_input)

v3stoploss_input = input(8.882, title='Stop Loss %', type=input.float, minval=0.01)/100
v3takeprofit_input = input(2.317, title='Take Profit %', type=input.float, minval=0.01)/100
v3stoploss_level = strategy.position_avg_price * (1 - v3stoploss_input)
v3takeprofit_level = strategy.position_avg_price * (1 + v3takeprofit_input)

plot(v2 and v2stoploss_input and v2stoploss_level ? v2stoploss_level: na, color=color.red, style=plot.style_linebr, linewidth=2, title="v2 Stoploss")
plot(v2 and v2takeprofit_input ? v2takeprofit_level: na, color=color.green, style=plot.style_linebr, linewidth=2, title="v2 Profit")

plot(v3 and v3stoploss_input and v3stoploss_level ? v3stoploss_level: na, color=color.red, style=plot.style_linebr, linewidth=2, title="v3 Stoploss")
plot(v3 and v3takeprofit_input ? v3takeprofit_level: na, color=color.green, style=plot.style_linebr, linewidth=2, title="v3 Profit")

////////// ** Indicators ** //////////

// RSI

len = 14
src = close
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)

// MFI

MFIlength = 14
MFIsrc = hlc3
MFIupper = sum(volume * (change(MFIsrc) <= 0 ? 0 : MFIsrc), MFIlength)
MFIlower = sum(volume * (change(MFIsrc) >= 0 ? 0 : MFIsrc), MFIlength)
_rsi(MFIupper, MFIlower) =>
    if MFIlower == 0
        100
    if MFIupper == 0
        0
	100.0 - (100.0 / (1.0 + MFIupper / MFIlower))
mfi = _rsi(MFIupper, MFIlower)

// v1 Bollinger Bands

length1 = 20
src1 = close
mult1 = 1.0
basis1 = sma(src1, length1)
dev1 = mult1 * stdev(src1, length1)
upper1 = basis1 + dev1
lower1 = basis1 - dev1

// v2 Bollinger Bands

length2 = 17
src2 = close
mult2 = 1.0
basis2 = sma(src2, length2)
dev2 = mult2 * stdev(src2, length2)
upper2 = basis2 + dev2
lower2 = basis2 - dev2

////////// ** Triggers and Guards ** //////////

// v1 Strategy Parameters

RSILowerLevel1 = 42
RSIUpperLevel1 = 70
BBBuyTrigger1 = src1 < lower1
BBSellTrigger1 = src1 > upper1
rsiBuyGuard1 = rsi > RSILowerLevel1
rsiSellGuard1 = rsi > RSIUpperLevel1

// v2 Strategy Parameters

RSILowerLevel2 = 42
RSIUpperLevel2 = 76
BBBuyTrigger2 = src2 < lower2
BBSellTrigger2 = src2 > upper2
rsiBuyGuard2 = rsi > RSILowerLevel2
rsiSellGuard2 = rsi > RSIUpperLevel2

// v3 Strategy Parameters

MFILowerLevel3 = 60
RSIUpperLevel3 = 65
MFIUpperLevel3 = 64
BBBuyTrigger3 = src1 < lower1
BBSellTrigger3 = src1 > upper1
mfiBuyGuard3 = mfi < MFILowerLevel3
rsiSellGuard3 = rsi > RSIUpperLevel3
mfiSellGuard3 = mfi > MFIUpperLevel3 

//////////** Strategy Signals ** //////////

// v1 Signals

Buy_1 = BBBuyTrigger1 and rsiBuyGuard1
Sell_1 = BBSellTrigger1 and rsiSellGuard1

if v1 == true
    
    strategy.entry("Long", strategy.long, when = Buy_1, alert_message = "v1 - Buy Signal!")
    strategy.entry("Sell", when = Sell_1, alert_message = "v1 - Sell Signal!")

// v2 Signals

Buy_2 = BBBuyTrigger2 and rsiBuyGuard2
Sell_2 = BBSellTrigger2 and rsiSellGuard2

if v2 == true
    strategy.entry("Long", strategy.long, when = Buy_2, alert_message = "v2 - Buy Signal!")
    strategy.entry("Sell", when = Sell_2, alert_message = "v2 - Sell Signal!")
    strategy.exit("Stoploss/TP", "Long", stop = v2stoploss_level, limit = v2takeprofit_level)

// v3 Signals

Buy_3 = BBBuyTrigger3 and mfiBuyGuard3
Sell_3 = BBSellTrigger3 and rsiSellGuard3 and mfiSellGuard3

if v3 == true
    strategy.entry("Long", strategy.long, when = Buy_3, alert_message = "v2 - Buy Signal!")
    strategy.entry("Sell", when = Sell_3, alert_message = "v2 - Sell Signal!")
    strategy.exit("Stoploss/TP", "Long", stop = v3stoploss_level, limit = v3takeprofit_level)



관련

더 많은