OPEN-SOURCE SCRIPT

atr stop loss for double SMA v6

428
Strategy Name
atr stop loss for double SMA v6
Credit: This v6 update is based on Daveatt’s “BEST ATR Stop Multiple Strategy.”
Core Logic

Entry: Go long when the 15-period SMA crosses above the 45-period SMA; go short on the inverse cross.

Stop-Loss: On entry, compute ATR(14)×2.0 and set a fixed stop at entry ± that amount. Stop remains static until hit.

Trend Tracking: Uses barssince() to ensure only one active long or short position; stop is only active while that trend persists.

Visualization

Plots fast/slow SMA lines in teal/orange.

On each entry bar, displays a label showing “ATR value” and “ATR×multiple” positioned at the 30-bar low (long) or high (short).

Draws an “×” at the stop-price level in green (long) or red (short) while the position is open.

Execution Settings

Initial Capital: $100 000, Size = 100 shares per trade.

Commission: 0.075% per trade.

Pyramiding: 1.

Calculations: Only on bar close (no intra-bar ticks).

Usage Notes

Static ATR stop adapts to volatility but does not trail.

Ideal for trending, liquid markets (stocks, futures, FX).

Adjust SMA lengths or ATR multiple for faster/slower signals.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.