Strategi ini adalah sistem perdagangan otomatis yang menggabungkan momentum adaptif dan manajemen posisi Martingale. Sistem ini menggunakan beberapa indikator teknis untuk analisis pasar, termasuk penghalusan autoencoder, ekstraksi fitur momentum simulasi CNN, dan penyaringan sinyal perdagangan berbasis volatilitas.
Strategi ini beroperasi pada tiga modul inti:
Strategi ini menggabungkan teknik perdagangan kuantitatif modern dengan metode Martingale klasik untuk menciptakan sistem perdagangan dengan dasar teoritis dan kepraktisan.
/*backtest start: 2024-12-06 00:00:00 end: 2025-01-04 08:00:00 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Adaptive Crypto Trading Strategy with Martingale", shorttitle = "ACTS_w_MG_V1",overlay=true) // Inputs smoothing_length = input.int(14, title="Smoothing Length (Autoencoder)") momentum_window = input.int(21, title="Momentum Window (CNN)") volatility_threshold = input.float(0.02, title="Volatility Threshold (GAN Simulation)") take_profit = input.float(0.05, title="Take Profit (%)") stop_loss = input.float(0.02, title="Stop Loss (%)") // Martingale Inputs base_lot_size = input.float(1, title="Base Lot Size") // Initial trade size multiplier = input.float(2, title="Martingale Multiplier") // Lot size multiplier after a loss max_lot_size = input.float(2, title="Maximum Lot Size") // Cap on lot size var float lot_size = base_lot_size // Initialize the lot size // Step 1: Data Smoothing (Autoencoder) smoothed_price = ta.sma(close, smoothing_length) // Step 2: Feature Extraction (Momentum - CNN Simulation) momentum = ta.sma(close, momentum_window) - close volatility = ta.stdev(close, momentum_window) // Step 3: Entry Conditions (GAN-Inspired Pattern Detection) long_condition = (momentum > 0 and volatility > volatility_threshold) short_condition = (momentum < 0 and volatility > volatility_threshold) // Martingale Logic if (strategy.closedtrades > 0) if (strategy.closedtrades.profit(strategy.closedtrades - 1) < 0) lot_size := math.min(lot_size * multiplier, max_lot_size) // Increase lot size after a loss, but cap it else lot_size := base_lot_size // Reset lot size after a win or on the first trade // Step 4: Take Profit and Stop Loss Management long_take_profit = close * (1 + take_profit) long_stop_loss = close * (1 - stop_loss) short_take_profit = close * (1 - take_profit) short_stop_loss = close * (1 + stop_loss) // Execute Trades if (long_condition) strategy.entry("Long", strategy.long, qty=lot_size, stop=long_stop_loss, limit=long_take_profit) if (short_condition) strategy.entry("Short", strategy.short, qty=lot_size, stop=short_stop_loss, limit=short_take_profit)