
यह रणनीति एक व्यापक मात्रात्मक व्यापार प्रणाली है जो T3 औसत, ट्रेंड ट्रैकिंग और मोबाइल स्टॉप तंत्र को जोड़ती है। रणनीति T3 मोबाइल औसत के माध्यम से बाजार की प्रवृत्ति की दिशा की पहचान करती है, जबकि लेमन ट्रेंड इंडिकेटर और टीडीएफआई इंडिकेटर का उपयोग करके सिग्नल की पुष्टि करती है, और मोबाइल स्टॉप और फिक्स्ड स्टॉप के संयोजन के साथ जोखिम प्रबंधन प्रणाली के साथ मिलकर प्रवृत्ति की समझ और जोखिम के प्रभावी नियंत्रण को प्राप्त करती है।
इस रणनीति के मूल में तीन मुख्य भाग होते हैंः प्रवृत्ति पहचान, संकेत की पुष्टि और जोखिम प्रबंधन। सबसे पहले, T3 चलती औसत का उपयोग मुख्य प्रवृत्ति पहचान उपकरण के रूप में किया जाता है, T3 औसत को छठे सूचकांक के माध्यम से चलती औसत की गणना के माध्यम से किया जाता है, जो प्रभावी रूप से विलंबता को कम करने और चिकनाई को बनाए रखने में सक्षम है। दूसरा, लेमन ट्रेंड इंडिकेटर के माध्यम से कीमतों के उतार-चढ़ाव की सीमा की गणना की जाती है, टीडीएफआई इंडिकेटर के साथ संयोजन में सिग्नल फ़िल्टर किया जाता है, और केवल तभी ट्रेड सिग्नल उत्पन्न होता है जब कीमतें उतार-चढ़ाव की सीमा को तोड़ती हैं और टीडीएफआई इंडिकेटर की पुष्टि होती है। अंत में, रणनीति को एक संयोजन के रूप में ले जाती है। जोखिम प्रबंधन, जिसमें एक चलती स्टॉप और एक फिक्स्ड स्टॉप शामिल हैं, जो कीमतों के सक्रिय स्तर तक पहुंचने के बाद चलती स्टॉप को ट्रैक करना शुरू करते हैं, जबकि एक सुरक्षा तंत्र के रूप में एक फिक्स्ड स्टॉप को बनाए रखते हैं।
यह एक व्यापक प्रवृत्ति ट्रैकिंग रणनीति है, जो कई तकनीकी संकेतकों के सह-उपयोग के माध्यम से व्यापारिक संकेतों की विश्वसनीयता की गारंटी देता है और प्रभावी जोखिम प्रबंधन को लागू करता है। रणनीति का मॉड्यूलर डिजाइन इसे अच्छी स्केलेबिलिटी और अनुकूलन के लिए जगह देता है, जो मध्यम और दीर्घकालिक प्रवृत्ति ट्रैकिंग सिस्टम के लिए एक बुनियादी ढांचे के रूप में उपयुक्त है। व्यावहारिक अनुप्रयोगों में, विशिष्ट व्यापारिक किस्मों और बाजार की स्थिति के अनुसार पैरामीटर के अनुकूलन को अनुकूलित करने की सिफारिश की जाती है।
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Lemon Trend Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Input parameters
lookbackPeriod = input.int(14, "Lookback Period")
t3Length = input.int(200, "T3 MA Length")
t3Factor = input.float(0.7, "T3 Factor", minval=0, maxval=1)
// 移动止损参数
trailingStopPct = input.float(1.5, "移动止损百分比", minval=0.1, step=0.1)
trailingStopActivationPct = input.float(1.0, "移动止损激活百分比", minval=0.1, step=0.1)
// === T3 Moving Average Function ===
t3(src, length, factor) =>
// First EMA
e1 = ta.ema(src, length)
// Second EMA
e2 = ta.ema(e1, length)
// Third EMA
e3 = ta.ema(e2, length)
// Fourth EMA
e4 = ta.ema(e3, length)
// Fifth EMA
e5 = ta.ema(e4, length)
// Sixth EMA
e6 = ta.ema(e5, length)
c1 = -factor * factor * factor
c2 = 3 * factor * factor + 3 * factor * factor * factor
c3 = -6 * factor * factor - 3 * factor - 3 * factor * factor * factor
c4 = 1 + 3 * factor + factor * factor * factor + 3 * factor * factor
t3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3
// Calculate T3 MA
t3ma = t3(close, t3Length, t3Factor)
plot(t3ma, "T3 MA", color=color.blue)
// === Lemon Trend Indicator ===
highLowDiff = high - low
normalizedDiff = ta.sma(highLowDiff, lookbackPeriod)
upperBand = ta.highest(high, lookbackPeriod)
lowerBand = ta.lowest(low, lookbackPeriod)
buySignal = ta.crossover(close, upperBand - normalizedDiff)
sellSignal = ta.crossunder(close, lowerBand + normalizedDiff)
// === TDFI Indicator ===
tdfiLength = input.int(14, "TDFI Length")
tdfi = ta.ema(close - close[1], tdfiLength)
tdfiSignal = ta.ema(tdfi, 9)
// Plot signals
plotshape(buySignal and tdfi > tdfiSignal and close > t3ma, "Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal and tdfi < tdfiSignal and close < t3ma, "Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// === Strategy Logic ===
longCondition = buySignal and tdfi > tdfiSignal and close > t3ma
shortCondition = sellSignal and tdfi < tdfiSignal and close < t3ma
// 计算移动止损价格
var float longTrailingStop = na
var float shortTrailingStop = na
// 更新移动止损价格
if (strategy.position_size > 0)
threshold = strategy.position_avg_price * (1 + trailingStopActivationPct / 100)
if (high > threshold)
stopPrice = high * (1 - trailingStopPct / 100)
if (na(longTrailingStop) or stopPrice > longTrailingStop)
longTrailingStop := stopPrice
if (strategy.position_size < 0)
threshold = strategy.position_avg_price * (1 - trailingStopActivationPct / 100)
if (low < threshold)
stopPrice = low * (1 + trailingStopPct / 100)
if (na(shortTrailingStop) or stopPrice < shortTrailingStop)
shortTrailingStop := stopPrice
// Entry orders
if (longCondition)
strategy.entry("Long", strategy.long)
longTrailingStop := na
if (shortCondition)
strategy.entry("Short", strategy.short)
shortTrailingStop := na
// Calculate stop loss and take profit levels
longStopLoss = ta.lowest(low, lookbackPeriod)
shortStopLoss = ta.highest(high, lookbackPeriod)
// Exit conditions with fixed R:R
fixedRR = input.float(1.8, "Fixed Risk:Reward Ratio")
partialExitPct = input.float(50.0, "Partial Exit Percentage", minval=0, maxval=100) / 100
// 综合移动止损和固定止损
if (strategy.position_size > 0)
longTakeProfit = strategy.position_avg_price + (strategy.position_avg_price - longStopLoss) * fixedRR
stopPrice = na(longTrailingStop) ? longStopLoss : math.max(longStopLoss, longTrailingStop)
strategy.exit("Long Exit", "Long", qty_percent=partialExitPct, stop=stopPrice, limit=longTakeProfit)
if (strategy.position_size < 0)
shortTakeProfit = strategy.position_avg_price - (shortStopLoss - strategy.position_avg_price) * fixedRR
stopPrice = na(shortTrailingStop) ? shortStopLoss : math.min(shortStopLoss, shortTrailingStop)
strategy.exit("Short Exit", "Short", qty_percent=partialExitPct, stop=stopPrice, limit=shortTakeProfit)
// 绘制移动止损线
plot(strategy.position_size > 0 ? longTrailingStop : na, "Long Trailing Stop", color=color.red, style=plot.style_linebr)
plot(strategy.position_size < 0 ? shortTrailingStop : na, "Short Trailing Stop", color=color.red, style=plot.style_linebr)