
Chiến lược này là một chiến lược theo dõi xu hướng dựa trên các chỉ số SSL Channel. Nó kết hợp với quản lý dừng lỗ và dừng để khóa lợi nhuận để đạt được sự tăng trưởng vốn ổn định.
Lập luận chính của mã là sử dụng đường giao thoa vàng giữa đường SSL trên và đường SSL dưới để đánh giá xu hướng. Cụ thể, khi đường SSL trên vượt qua đường SSL dưới từ phía dưới, hãy làm nhiều; khi đường SSL dưới vượt qua đường SSL trên từ phía trên xuống, hãy làm trống.
Sau khi vào vị trí, chiến lược sẽ sử dụng chỉ số ATR nhân với hệ số để thiết lập giá dừng lỗ và giá dừng. Ví dụ: giá dừng lỗ là giá trừ ATR * 1.5, giá dừng là giá cộng với ATR * 1. Điều này có thể kiểm soát hiệu quả lỗ đơn và khóa lợi nhuận.
Khi một kênh SSL bị bịt, nó sẽ được cân bằng để có thể theo dõi các điểm biến của xu hướng và dừng lỗ.
Các giải pháp tương ứng:
Chiến lược này có tư duy tổng thể rõ ràng, sử dụng SSL để đánh giá xu hướng và thiết lập các trạm dừng hợp lý. Tuy nhiên, vẫn cần thử nghiệm và tối ưu hóa thêm, kết hợp với các chỉ số khác để lọc các tín hiệu giả, tìm ra sự kết hợp tham số tốt nhất. Đồng thời, điều chỉnh các tham số cho các thị trường khác nhau, làm cho chiến lược trở nên linh hoạt hơn.
/*backtest
start: 2022-11-26 00:00:00
end: 2023-05-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Designed per No Nonsense Forex VP rules
//For testing your individual indicators before the full system
//Originated from causecelebre
//Tried to put in as much VP rules as possible
///////////////////////////////////////////////////
//Rules Implemented:
///////////////////////////////////////////////////
// - SL 1.5 x ATR
// - TP 1 x ATR
//
// - Entry conditions
//// - Entry from 1 x confirmation
// - Exit conditions
//// - Exit on confirmation flip
///////////////////////////////////////////////////
//Trades entries
///////////////////////////////////////////////////
// - First entry L1 or S1 with standard SL and TP
///////////////////////////////////////////////////
//Included Indicators and settings
///////////////////////////////////////////////////
// - Confirmtion = SSL 10
///////////////////////////////////////////////////
//Credits
// Strategy causecelebre https://www.tradingview.com/u/causecelebre/
// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Change log
//First release. Testing of indicators
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
strategy(title="NNFX Strategy Indicator | jh", overlay = true )
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// **** Set the main stuff ****
///////////////////////////////////////////////////
//Price
price = close
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ATR stuff
///////////////////////////////////////////////////
slMultiplier = input(1.5, "SL")
tpMultiplier = input(1, "TP")
atrlength = input(title="ATR Length", defval=14, minval=1)
atrsmoothing = input(title="Smoothing", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"])
ma_function(source, atrlength) =>
if atrsmoothing == "RMA"
rma(source, atrlength)
else
if atrsmoothing == "SMA"
sma(source, atrlength)
else
if atrsmoothing == "EMA"
ema(source, atrlength)
else
wma(source, atrlength)
//plot(ma_function(tr(true), atrlength), title = "ATR", color=#991515, transp=0)
atr = ma_function(tr(true), atrlength)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// **** Confirmation ****
///////////////////////////////////////////////////
ssllen=input(title="SSL Length Period", defval=10)
smaHigh=sma(high, ssllen)
smaLow=sma(low, ssllen)
Hlv = na
Hlv := close > smaHigh ? 1 : close < smaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? smaHigh: smaLow
sslUp = Hlv < 0 ? smaLow : smaHigh
plot(sslDown, "SSL Down", linewidth=1, color=red)
plot(sslUp, "SSL Up", linewidth=1, color=lime)
///////////////////////////////////////////////////
//Confirm Signals
///////////////////////////////////////////////////
c_Up = sslUp
c_Down = sslDown
//Signals based on crossover
c_Long = crossover(c_Up, c_Down)
c_Short = crossover(c_Down, c_Up)
//Signals based on signal position
trendLong = c_Up > c_Down ? 1 : 0
trendShort = c_Down > c_Up ? 1 : 0
confirmLong = c_Long
confirmShort = c_Short
plotshape(trendLong, color = green, style=shape.triangleup, location=location.bottom)
plotshape(trendShort, color = red, style=shape.triangledown, location=location.bottom)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Entries and Exits
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (year>2009)
//Long entries with standard 1.5 ATR for SL, 1 ATR for TP
long_sl = price - (atr * slMultiplier)
long_tp = price + (atr * tpMultiplier)
strategy.order("L1", strategy.long, when = confirmLong)
strategy.close("L1", when = confirmShort)
strategy.exit("L Limit Exit", "L1", stop = long_sl, limit = long_tp)
//Short entries with standard 1.5 ATR for SL, 1 ATR for TP
short_sl = price + (atr * slMultiplier)
short_tp = price - (atr * tpMultiplier)
strategy.order("S1", strategy.short, when = confirmShort)
strategy.close("S1", when = confirmLong)
strategy.exit("S Limit Exit", "S1", stop = short_sl, limit = short_tp)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//End
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////