asami.Multifactor + Supertrend AutoTrade

The Pine Script strategy **“Multifactor + Supertrend AutoTrade”** combines the Supertrend indicator as a dynamic trend filter (using ATR to measure volatility) with a multifactor filter—short-term vs. long-term EMAs, MACD crossover, RSI overbought/oversold levels, and Bollinger Bands extremes—to suppress false signals and capture trend continuations. Buy signals trigger when all multifactor conditions are met **and** price crosses above the Supertrend line; similarly, sell signals trigger when the inverse multifactor conditions are met **and** price crosses below the Supertrend line. Webhook alerts make it ready for seamless automated trading integration.
---
## Component Breakdown
### Supertrend
* Uses ATR to draw a volatility-adjusted trend line on the chart.
* When the line is green and below price → bullish trend; when red and above price → bearish trend.
### EMA (Exponential Moving Average)
* Places more emphasis on recent price data for quicker trend response.
* A crossover of the fast EMA above the slow EMA signals bullish momentum, and vice versa.
### MACD (Moving Average Convergence Divergence)
* Calculates the difference between two EMAs (default 12 and 26) and compares it to a 9-period signal EMA.
* A bullish signal is when the MACD line crosses above its signal line; bearish when it crosses below.
### RSI (Relative Strength Index)
* Oscillator measuring the speed and change of price movements on a 0–100 scale.
* Readings above 70 indicate overbought conditions; below 30 indicate oversold.
### ATR (Average True Range)
* Quantifies market volatility by averaging true price ranges over a set period.
* Often used to size stops or gauge how far price may move.
### Bollinger Bands
* Plots an SMA (default 20) with upper and lower bands offset by ±2 × standard deviation.
* Bands widen during high volatility and contract during low; price touches can indicate extremes.
---
## Signal Logic
1. **Multifactor Filters**
* **`mfBuy`**: Fast EMA > Slow EMA **AND** MACD > Signal **AND** RSI < 30 **AND** Close < Lower BB
* **`mfSell`**: Fast EMA < Slow EMA **AND** MACD < Signal **AND** RSI > 70 **AND** Close > Upper BB
2. **Supertrend Crossover**
* **Buy** when `mfBuy` is true **AND** `ta.crossover(close, st)`
* **Sell** when `mfSell` is true **AND** `ta.crossunder(close, st)`
3. **Automated Orders**
```pine
strategy.entry("Long", strategy.long, comment="Long", alert_message="LONG_SIGNAL")
strategy.entry("Short", strategy.short, comment="Short", alert_message="SHORT_SIGNAL")
```
4. **Alerts**
```pine
alertcondition(buyCond, title="Long Alert", message="{{strategy.order.alert_message}}")
alertcondition(sellCond, title="Short Alert", message="{{strategy.order.alert_message}}")
```
---
## Key Advantages
* **Robust Filtering**: Combining multiple indicators greatly reduces whipsaws compared to single-indicator systems.
* **Dynamic Trend Detection**: Supertrend adapts to changing volatility, helping to enter only in genuine trends.
* **Highly Customizable**: All lookback periods, thresholds, and multipliers are exposed as inputs for fine-tuning.
---
## Parameter Tuning Tips
* **Supertrend ATR & Factor**: Shorter ATR or smaller factor → more frequent signals but potentially more noise; longer/slower for fewer, smoother signals.
* **EMA Periods**: Adjust fast/slow EMA lengths (e.g. 5/20, 10/50) to match the time horizon of your chosen market.
* **RSI Thresholds**: You can shift from classic 70/30 to tighter bands (e.g. 60/40) if you want earlier signals.
* **Bollinger Settings**: Tweaking the standard-deviation multiplier (1.5–2.5) changes how “extreme” price must be to qualify.
---
## Risk Management & Best Practices
* **Backtest & Forward Test**: Validate on both historical data and live demo before going live.
* **Latency Considerations**: Account for webhook and broker execution delays—consider external order management logic if needed.
* **Position Sizing**: Use the built-in `% of equity` sizing (`default_qty_type=strategy.percent_of_equity`) or your preferred money-management rules.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Penafian
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.