Chiến lược kiểm tra ngược chính

Tác giả:ChaoZhang
Tags:

img

Tổng quan

Chiến lược kiểm tra ngược đảo chiều chính xác định các tín hiệu đảo ngược chính trong giá cổ phiếu để xác định xem xu hướng hiện tại có đang đảo ngược hay không, để nắm bắt hướng chuyển động giá sau khi đảo ngược xu hướng. Chiến lược dựa trên lý thuyết "ngày đảo ngược chính".

Nguyên tắc chiến lược

Phân tích lợi thế

  1. Các tiêu chí để xác định ngày đảo ngược chính rất rõ ràng, với giá cao / thấp mới đảo ngược giá đóng cửa của ngày trước. Điều này làm cho chiến lược dễ dàng kiểm tra lại và giúp tránh đánh giá sai.

Phân tích rủi ro

Hướng dẫn tối ưu hóa

Tóm lại


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 21/01/2020
//
// A key reversal is a one-day trading pattern that may signal the reversal of a trend. 
// Other frequently-used names for key reversal include "one-day reversal" and "reversal day."
// How Does a Key Reversal Work?
// Depending on which way the stock is trending, a key reversal day occurs when:
// In an uptrend -- prices hit a new high and then close near the previous day's lows.
// In a downtrend -- prices hit a new low, but close near the previous day's highs
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Key Reversal Up Backtest", shorttitle="KRU Backtest", overlay = true) 
nLength = input(1, minval=1, title="Enter the number of bars over which to look for a new low in prices.")
input_takeprofit = input(20, title="Take Profit pip", step=0.01)
input_stoploss = input(10, title="Stop Loss pip", step=0.01)
xLL = lowest(low[1], nLength)
C1 = iff(low < xLL and close > close[1], true, false)
plotshape(C1, style=shape.triangleup, size = size.small, color=color.green, location = location.belowbar )
posprice = 0.0
pos = 0
barcolor(nz(pos[1], 0) == -1 ? color.red: nz(pos[1], 0) == 1 ? color.green : color.blue ) 
posprice := iff(C1== true, close, nz(posprice[1], 0)) 
pos := iff(posprice > 0, 1, 0)
if (pos == 0) 
    strategy.close_all()
if (pos == 1)
    strategy.entry("Long", strategy.long)
posprice := iff(low <= posprice - input_stoploss and posprice > 0, 0 ,  nz(posprice, 0))
posprice := iff(high >= posprice + input_takeprofit and posprice > 0, 0 ,  nz(posprice, 0))

Thêm nữa