
Ini adalah strategi pelacakan tren cerdas yang didasarkan pada sinyal silang dari beberapa indikator teknis. Strategi ini mengintegrasikan tiga indikator teknis utama, yaitu Moving Average (EMA), Relative Strength Index (RSI) dan Moving Average Trend Scatter (MACD), untuk mengidentifikasi tren pasar melalui konfirmasi sinyal multi-dimensi, dan untuk manajemen risiko dengan stop loss yang dinamis. Strategi ini dirancang dengan cara perdagangan otomatis, terutama untuk perdagangan dalam sehari.
Logika inti dari strategi ini didasarkan pada tiga lapisan penyaringan indikator teknis:
Produksi sinyal masuk harus memenuhi persyaratan berikut:
Strategi ini menggunakan modal persentase kepemilikan mode, setiap perdagangan menggunakan 10% dari ekuitas akun, dan bekerja dengan 2% stop dan 1% stop loss untuk pengendalian risiko.
Saran pengendalian risiko:
Strategi ini dengan sinergi dari beberapa indikator teknis, membangun sistem pelacakan tren yang relatif sempurna. Keuntungan dari strategi ini adalah keandalan sinyal yang tinggi, manajemen risiko yang sempurna, tetapi ada juga keterbelakangan dan ketergantungan pada lingkungan pasar. Dengan arah optimasi yang direkomendasikan, strategi dapat meningkatkan lebih lanjut adaptasi dan stabilitasnya.
/*backtest
start: 2024-02-22 00:00:00
end: 2025-02-19 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © egidiopalmieri
//@version=5
strategy("BTCUSD Intraday - AI-like Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.1)
// ==========================
// Risk and Strategy Parameters
// ==========================
takeProfitPerc = input.float(2.0, "Take Profit (%)", step=0.1) / 100.0 // Target profit: 2%
stopLossPerc = input.float(1.0, "Stop Loss (%)", step=0.1) / 100.0 // Stop loss: 1%
// ==========================
// Technical Indicators
// ==========================
emaShortPeriod = input.int(9, "Short EMA (period)", minval=1)
emaLongPeriod = input.int(21, "Long EMA (period)", minval=1)
emaShort = ta.ema(close, emaShortPeriod)
emaLong = ta.ema(close, emaLongPeriod)
// RSI Indicator
rsiPeriod = input.int(14, "RSI (period)", minval=1)
rsiValue = ta.rsi(close, rsiPeriod)
// MACD Indicator
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
// ==========================
// Entry Conditions
// ==========================
// LONG entry: short EMA crosses above long EMA, RSI not in overbought zone, MACD in bullish trend
longCondition = ta.crossover(emaShort, emaLong) and (rsiValue < 70) and (macdLine > signalLine)
// SHORT entry: short EMA crosses below long EMA, RSI not in oversold zone, MACD in bearish trend
shortCondition = ta.crossunder(emaShort, emaLong) and (rsiValue > 30) and (macdLine < signalLine)
// ==========================
// Signal Visualization
// ==========================
plotshape(longCondition, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Long")
plotshape(shortCondition, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Short")
// ==========================
// Entry Logic
// ==========================
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// ==========================
// Stop Loss and Take Profit Management
// The levels are calculated dynamically based on the average entry price
// ==========================
if strategy.position_size > 0
// For long positions
longSL = strategy.position_avg_price * (1 - stopLossPerc)
longTP = strategy.position_avg_price * (1 + takeProfitPerc)
strategy.exit("Exit Long", from_entry="Long", stop=longSL, limit=longTP)
if strategy.position_size < 0
// For short positions
shortSL = strategy.position_avg_price * (1 + stopLossPerc)
shortTP = strategy.position_avg_price * (1 - takeProfitPerc)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL, limit=shortTP)
// ==========================
// Final Notes
// ==========================
// This script uses rules based on technical indicators to generate signals
// "AI-like". The integration of actual AI algorithms is not natively supported in PineScript.
// It is recommended to customize, test, and validate the strategy before using it in live trading.