
Đây là một chiến lược giao dịch định lượng dựa trên sự kết hợp của theo dõi xu hướng và phân tích động lực. Chiến lược này sử dụng chỉ số di chuyển trung bình ba lần (TEMA), chéo trung bình di chuyển nhiều lần và MACD biến thể để xác định xu hướng thị trường và thời gian vào. Chiến lược này áp dụng cơ chế kiểm soát rủi ro nghiêm ngặt, bao gồm mục tiêu dừng lỗ, lợi nhuận cố định và theo dõi dừng lỗ để đạt được sự cân bằng tối ưu giữa rủi ro và lợi nhuận.
Chiến lược này chủ yếu xác định tín hiệu giao dịch thông qua ba hệ thống chỉ số kỹ thuật cốt lõi:
Các tín hiệu giao dịch được kích hoạt khi các điều kiện sau cùng được đáp ứng:
Chiến lược này xây dựng một hệ thống giao dịch ổn định bằng cách kết hợp nhiều hệ thống chỉ số kỹ thuật. Ưu điểm cốt lõi của nó là cơ chế xác nhận nhiều lần và hệ thống kiểm soát rủi ro tốt. Mặc dù có một số rủi ro bị tụt hậu, chiến lược vẫn có nhiều chỗ cải thiện thông qua tối ưu hóa tham số và mở rộng chức năng.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("ITG Scalper Strategy", shorttitle="lokesh_ITG_Scalper_Strategy", overlay=true)
// General inputs
len = input(14, title="TEMA period")
FfastLength = input.int(13, title="Filter fast length")
FslowLength = input.int(18, title="Filter slow length")
FsignalLength = input.int(14, title="Filter signal length")
sl_points = 7 // 5 points stop loss
tp_points = 100 // 100 points target profit
trail_points = 15 // Trailing stop loss every 10 points
// Validate input
if FfastLength < 1
FfastLength := 1
if FslowLength < 1
FslowLength := 1
if FsignalLength < 1
FsignalLength := 1
// Get real close price
realC = close
// Triple EMA definition
ema1 = ta.ema(realC, len)
ema2 = ta.ema(ema1, len)
ema3 = ta.ema(ema2, len)
// Triple EMA trend calculation
avg = 3 * (ema1 - ema2) + ema3
// Filter formula
Fsource = close
FfastMA = ta.ema(Fsource, FfastLength)
FslowMA = ta.ema(Fsource, FslowLength)
Fmacd = FfastMA - FslowMA
Fsignal = ta.sma(Fmacd, FsignalLength)
// Plot EMAs for visual reference
shortema = ta.ema(close, 9)
longema = ta.ema(close, 15)
yma = ta.ema(close, 5)
plot(shortema, color=color.green)
plot(longema, color=color.red)
plot(yma, color=#e9f72c)
// Entry conditions
firstCrossover = ta.crossover(Fmacd, Fsignal) and avg > avg[1]
secondCrossover = ta.crossover(shortema, longema) // Assuming you meant to cross shortema with longema
thirdCrossover = ta.crossover(close, yma)
var bool entryConditionMet = false
if (firstCrossover)
entryConditionMet := true
longSignal = entryConditionMet and secondCrossover and thirdCrossover
// Strategy execution
if (longSignal)
strategy.entry("Long", strategy.long)
entryConditionMet := false // Reset the entry condition after taking a trade
// Calculate stop loss and take profit prices
var float long_sl = na
var float long_tp = na
if strategy.position_size > 0 // Long position
long_sl := close - sl_points
long_tp := close + tp_points
// Adjust stop loss with trailing logic
if (close - long_sl > trail_points)
long_sl := close - trail_points
strategy.exit("Exit Long", "Long", stop=long_sl, limit=long_tp)
// Plotting Buy signals
plotshape(series=longSignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
// Alerts
alertcondition(longSignal, title="Buy Signal", message="Buy Signal")