반전 촛불 역 테스트 전략

저자:차오장, 날짜: 2024-01-26 16:04:26
태그:

img

전반적인 설명

전략 논리

  1. 긴/단: 반전 촛불 패턴이 확인되면 2 일 전에 전에 닫았다면 긴, 2 일 전에 전에 닫았다면 짧은 이동합니다.

장점

  1. 이윤/손실 중지 메커니즘은 위험을 효과적으로 통제하고, 이윤을 차단하고, 손실을 늘리는 것을 피합니다.

  2. 수동 개입 없이 자동화 된 거래는 거래 비용을 줄이고 효율성을 향상시킵니다.

위험성

  1. 전략 매개 변수들은 끊임없이 테스트와 최적화를 필요로 합니다. 그렇지 않으면 과잉 적응이 필요합니다.

최적화 방향

  1. 다른 거래 도구에 테스트하고, 수익/손실 지점을 조정하고, 매개 변수를 최적화합니다.

  2. 더 많은 거래 신호를 식별하기 위해 알고리즘을 추가하여 전략 논리를 풍부하게하십시오.

  3. 위치 크기를 조정하는 모듈을 추가하여 참조 지표에 기반한 위치를 동적으로 조정합니다.

결론


/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-25 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 30/01/2019
//   This is a candlestick where the open and close are the same. 
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title = "Doji Backtest", overlay = true)
input_takeprofit = input(10, title="Take Profit pip", step=0.01)
input_stoploss = input(10, title="Stop Loss pip", step=0.01)
input_minsizebody = input(0.5, title="Min. Size Body pip", step=0.01)
barcolor(abs(close - open) <= input_minsizebody ? open == close ? yellow : na : na)
possell = 0.0
posbuy = 0.0
pospricebuy = 0.0
pospricesell = 0.0
barcolornow = blue
pospricesell := close< close[2] ? abs(close - open) <= input_minsizebody ? open == close ? close : nz(pospricesell[1], 0) : nz(pospricesell[1], 0) : nz(pospricesell[1], 0) 
possell := iff(pospricesell > 0 , -1, 0)
barcolornow := possell == -1 ? red: posbuy == 1 ? green : blue 
pospricesell := iff(low <= pospricesell - input_takeprofit and pospricesell > 0, 0 ,  nz(pospricesell, 0))
pospricesell := iff(high >= pospricesell + input_stoploss and pospricesell > 0, 0 ,  nz(pospricesell, 0))
pospricebuy := close > close[2] ? abs(close - open) <= input_minsizebody ? open == close ? close : nz(pospricebuy[1], 0) : nz(pospricebuy[1], 0) : nz(pospricebuy[1], 0) 
posbuy := iff(pospricebuy > 0 , 1, 0)
barcolornow := posbuy == 1 ? green: barcolornow
pospricebuy := iff(high >= pospricebuy + input_takeprofit and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
pospricebuy := iff(low <= pospricebuy - input_stoploss and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
barcolor(barcolornow)
if (posbuy == 0 and possell == 0) 
    strategy.close_all()
if (posbuy == 1)
    strategy.entry("Long", strategy.long)
if (possell == -1)
    strategy.entry("Short", strategy.short)	   	    
pospricebuy := iff(high <= pospricebuy + input_takeprofit and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
pospricebuy := iff(low >= pospricebuy - input_stoploss and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
pospricesell := iff(low <= pospricesell - input_takeprofit and pospricesell > 0, 0 ,  nz(pospricesell, 0))
pospricesell := iff(high >= pospricesell + input_stoploss and pospricesell > 0, 0 ,  nz(pospricesell, 0))


더 많은