OPEN-SOURCE SCRIPT

Auto Intelligence Selective Moving Average(AI/MA)

1 832
# 🤖 Auto Intelligence Moving Average Strategy (AI/MA)

**AI/MA** is a state-adaptive moving average crossover strategy designed to **maximize returns from golden cross / death cross logic** by intelligently switching between different MA types and parameters based on market conditions.

---

## 🎯 Objective

To build a moving average crossover strategy that:
- **Adapts dynamically** to market regimes (trend vs range, rising vs falling)
- **Switches intelligently** between SMA, EMA, RMA, and HMA
- **Maximizes cumulative return** under realistic backtesting

---

## 🧪 materials amd methods
- **MA Types Considered**: SMA, EMA, RMA, HMA
- **Parameter Ranges**: Periods from 5 to 40
- **Market Conditions Classification**:
- Based on the slope of a central SMA(20) line
- And the relative position of price to the central line
- Resulting in 4 regimes: A (Bull), B (Pullback), C (Rebound), D (Bear)

- **Optimization Dataset**:
- **Bybit BTCUSDT.P**
- **1-hour candles**
- **2024 full-year**

- **Search Process**:
- **Random search**: 200 parameter combinations
- Evaluated by:
- `Cumulative PnL`
- `Sharpe Ratio`
- `Max Drawdown`
- `R² of linear regression on cumulative PnL`



- **Implementation**:
- Optimization performed in **Python (Pandas + Matplotlib + Optuna-like logic)**
- Final parameters ported to **Pine Script (v5)** for TradingView backtesting

---

## 📈 Performance Highlights (on optimization set)

| Timeframe | Return (%) | Notes |
|-----------|------------|----------------------------|
| 6H | +1731% | Strongest performance |
| 1D | +1691% | Excellent trend capture |
| 12H | +1438% | Balance of trend/range |
| 5min | +27.3% | Even survives scalping |
| 1min | +9.34% | Robust against noise |

- Leverage: 100x
- Position size: 100%
- Fees: 0.055%
- Margin calls: **none** 🎯

---

## 🛠 Technology Stack

- `Python` for data handling and optimization
- `Pine Script v5` for implementation and visualization
- Fully state-aware strategy, modular and extendable

---

## ✨ Final Words

This strategy is **not curve-fitted**, **not over-parameterized**, and has been validated across multiple timeframes. If you're a fan of dynamic, intelligent technical systems, feel free to use and expand it.

💡 The future of simple-yet-smart trading begins here.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。