20 / 200 SMA Strategy - by gpmpastorsc
By gpmpastorsc
Performance Metrics
- Author: gpmpastorsc
- Symbol: CME_MINI:MNQ1!
- Timeframe: 3 minutes
- Net P&L: +6,094.50 USD (+12.19%)
- Win Rate: 63.4%
- Profit Factor: 1.461
- Max Drawdown: 1,676.00 USD (3.14%)
- Total Trades: 153
Description
This Pine Script strategy is a 20 SMA / 200 SMA trend-following strategy designed for back testing and potential bot automation.The main idea is to identify market direction using the relationship between the 20 simple moving average and the 200 simple moving average. When the 20 SMA is above the 200 SMA, the strategy looks for buy opportunities. When the 20 SMA is below the 200 SMA, it looks for sell opportunities.The script includes three entry modes:Original Cross Entry waits for the 20 SMA to cross the 200 SMA, then looks for price to close on the correct side of the 20 SMA.Trend Pullback Entry allows entries after the market is already trending. For buys, the 20 SMA must be above the 200 SMA and price must cross back above the 20 SMA. For sells, the 20 SMA must be below the 200 SMA and price must cross back below the 20 SMA.Relaxed Testing Entry is a more flexible testing mode that enters when price is on the correct side of the 20 SMA while the 20 SMA is on the correct side of the 200 SMA. This mode is useful for confirming that the strategy is working and producing trades.The default risk management uses a 100-point take profit. The default stop loss is placed behind the last opposing candle beyond the 200 SMA. For a buy setup, the stop is placed below the last bearish candle below the 200 SMA. For a sell setup, the stop is placed above the last bullish candle above the 200 SMA. The user can also choose a fixed-point stop loss or recent swing stop.The strategy includes optional filters such as a 200 SMA slope filter, candle-color confirmation, and a distance filter to avoid entries that are too far from the 20 SMA. It also plots the 20 SMA, 200 SMA, buy/sell labels, debug markers, and stop-loss/take-profit lines on the chart.Overall, this script is built to help traders test a simple moving-average trend strategy while giving them flexibility to adjust entries, stops, profit targets, and filters based on the market or timeframe they are trading.