← Script Vault

Strategy & Alerts | Published 2025-11-29

Super-AO with Risk Management

An open-source Super-AO strategy with a flexible risk-management engine. Use the strategy version for backtesting or the alerts version for automation.

Super-AO with Risk Management chart screenshot
Super-AO with Risk Management strategy performance screenshot
Historical backtest screenshot. Past performance doesn't guarantee future results.

Strategy

Super-AO Strategy with Advanced Risk Management Template Signal Lynx | Free Scripts supporting Automation for the Night-Shift Nation 🌙

1. Overview Welcome to the Super-AO Strategy. It combines Super-AO entry signals with an open-source risk-management template that you can adapt for your own Pine Script strategies.

At its core, this script implements a robust swing-trading strategy combining the SuperTrend (for macro direction) and the Awesome Oscillator (for momentum). However, the real power lies under the hood: a custom-built Risk Management Engine that handles trade states, prevents repainting, and manages complex exit conditions like Staged Take Profits and Advanced Adaptive Trailing Stops (AATS).

We're releasing this code to help traders transition from simple indicators to professional-grade strategy structures.

2. Quick Action Guide (TL;DR) Best Timeframe: 4 Hours (H4) and above. Designed for Swing Trading.

Best Assets: "Well-behaved" assets with clear liquidity (Major Forex pairs, BTC, ETH, Indices).

Strategy Type: Trend Following + Momentum Confirmation.

Key Feature: The Risk Management Engine is modular. You can strip out the "Super-AO" logic and insert your own strategy logic into the template easily.

Repainting: Strictly Non-Repainting. The engine calculates logic based on confirmed candle closes.

3. Detailed Report: How It Works A. The Strategy Logic: Super-AO The entry logic is based on the convergence of two classic indicators:

SuperTrend: Determines the overall trend bias (Green/Red).

Awesome Oscillator (AO): Measures market momentum.

The Signal:

LONG (+2): SuperTrend is Green AND AO is above the Zero Line AND AO is Rising.

SHORT (-2): SuperTrend is Red AND AO is below the Zero Line AND AO is Falling.

By requiring momentum to agree with the trend, this system filters out many false signals found in ranging markets.

B. The Risk Management (RM) Engine This script features a proprietary State Machine designed by Signal Lynx. Unlike standard strategies that simply fire orders, this engine separates the Signal from the Execution.

Logic Injection: The engine listens for a specific integer signal: +2 (Buy) or -2 (Sell). This makes the code a Template. You can delete the Super-AO section, write your own logic, and simply pass a +2 or -2 to the RM_EngineInput variable. The engine handles the rest.

Trade States: The engine tracks the state of the trade (Entry, In-Trade, Exiting) to prevent signal spamming.

Aggressive vs. Conservative:

Conservative Mode: Waits for a full trend reversal before taking a new trade.

Aggressive Mode: Allows for re-entries if the trend is strong and valid conditions present themselves again (Pyramiding Type 1).

C. Advanced Exit Protocols The strategy doesn't rely on a single exit point. It employs a "Layered Defense" approach:

Hard Stop Loss: A fixed percentage safety net.

Staged Take Profits (Scaling Out): The script allows you to set 3 distinct Take Profit levels. For example, you can close 10% of your position at TP1, 10% at TP2, and let the remaining 80% ride the trend.

Trailing Stop: A standard percentage-based trailer.

Advanced Adaptive Trailing Stop (AATS): This is a highly sophisticated volatility stop. It calculates market structure using Hirashima Sugita (HSRS) levels and Bollinger Bands to determine the "floor" and "ceiling" of price action.

If volatility is high: The stop loosens to prevent wicking out.

If volatility is low: The stop tightens to protect profit.

D. Repainting Protection Many Pine Script strategies look great in backtesting but fail in live trading because they rely on "real-time" price data that disappears when the candle closes.

This Risk Management engine explicitly pulls data from the previous candle close (close[1], high[1], low[1]) for its calculations. This ensures that the backtest results you see match the reality of live execution.

4. For Developers & Modders We encourage you to tear this code apart!

Look for the section titled // Super-AO Strategy Logic.

Replace that block with your own RSI, MACD, or Price Action logic.

Ensure your logic outputs a 2 for Buy and -2 for Sell.

Connect it to RM_EngineInput.

You now have a fully functioning Risk Management system for your custom strategy.

5. About Signal Lynx Automation for the Night-Shift Nation 🌙

This code has been in action since 2022 and is a known performer in PineScript v5. We provide this open source to help the community build better, safer automated systems.

If you're working on trade automation, take a look at what we're building at Signal Lynx.

License: Mozilla Public License 2.0 (Open Source). If you make beneficial modifications, please release them back to the community!

Alerts

Super-AO with Risk Management: ALERTS & AUTOMATION Edition Signal Lynx | Free Scripts supporting Automation for the Night-Shift Nation 🌙

1. Overview This is the indicator and alerts companion to the Super-AO strategy.

While the Strategy version is built for backtesting (verifying profitability and checking historical performance), this Indicator version is built for Live Execution.

Backtesting a strategy is one thing; getting useful signals into a trading bot is another. This alerts version helps bridge that gap. It contains the exact same "Super-AO" logic and "Risk Management Engine" as the strategy version, but it is optimized to send signals to automation platforms like Signal Lynx, 3Commas, or any Webhook listener.

2. Quick Action Guide (TL;DR) Purpose: Live Signal Generation & Automation.

Workflow:

Use the Strategy Version to find profitable settings.

Copy those settings into this Indicator Version.

Set a TradingView Alert using the "Any Alert() function call" condition.

Best Timeframe: 4 Hours (H4) and above.

Compatibility: Works with any webhook-based automation service.

3. Why Two Scripts? Pine Script operates in two distinct modes:

Strategy Mode: Calculates equity, drawdowns, and simulates orders. Great for research, but sometimes complex to automate.

Indicator Mode: Plots visual data on the chart. This is the preferred method for setting up robust alerts because it is lighter weight and plots specific values that automation services can read easily.

The Golden Rule: Always backtest on the Strategy, but trade on the Indicator. This ensures that what you see in your history matches what you execute in real-time.

4. How to Automate This Script This script uses a "Visual Spike" method to trigger alerts. Instead of drawing equity curves, it plots numerical values at the bottom of your chart when a trade event occurs.

The Signal Map:

Blue Spike (2 / -2): Entry Signal (Long / Short).

Yellow Spike (1 / -1): Risk Management Close (Stop Loss / Trend Reversal).

Green Spikes (1, 2, 3): Take Profit Levels 1, 2, and 3.

Setup Instructions:

Add this indicator to your chart.

Open your TradingView "Alerts" tab.

Create a new Alert.

Condition: Select SAO - RM Alerts Template.

Trigger: Select Any Alert() function call.

Message: Paste your JSON webhook message (provided by your bot service).

5. The Logic Under the Hood Just like the Strategy version, this indicator utilizes:

SuperTrend + Awesome Oscillator: High-probability swing trading logic.

Non-Repainting Engine: Calculates signals based on confirmed candle closes to ensure the alert you get matches the chart reality.

Advanced Adaptive Trailing Stop (AATS): Internally calculates volatility to determine when to send a "Close" signal.

6. About Signal Lynx Automation for the Night-Shift Nation 🌙

We're sharing this code to help traders connect backtesting with live automation. This code has been in action since 2022.

If you're working on trade automation, take a look at what we're building at Signal Lynx.

License: Mozilla Public License 2.0 (Open Source). If you make beneficial modifications, please release them back to the community!

Get the Pine Code

Copy the full Pine code or download the .pine file. You don't need an account.

Alerts (Pine Script v5)

Strategy (Pine Script v5)

The source files include their author credits and license notices. Please follow those terms when you reuse the code.