3Commas Bot
Aug 25, 2021

The 3Commas Bot indicator provides a comprehensive strategy template designed for automated trading with risk-defined positions, featuring integrated stop-loss, limit orders, and trailing stop logic. It serves as a foundational framework for users to deploy algorithmic strategies on TradingView with seamless compatibility for 3rd party execution platforms.
Usage
The Usage section describes how the script can be used, particularly as a template for automating trades via webhooks.
To deploy the strategy for automated execution:
- Copy the script code and input your bot identifiers in the "3Comma Keys" section within the script.
- Set an alert on your desired asset and select "Order fills and alert() function calls" in the alert settings.
- Configure your webhook URL provided by your automated trading service.
- Set the alert message to
{{strategy.order.alert_message}}to ensure the strategy correctly transmits order strings.
The indicator uses a Moving Average (MA) crossover as its default entry signal. Users can adjust the MA types (e.g., SMA, EMA, HEMA) and lengths to fit specific market conditions. Risk management is handled through swing-based calculations, where the script identifies local highs or lows to set stop levels, further adjusted by an Average True Range (ATR) multiplier.
Details
The script is constructed to solve common issues in automated trading, such as risk mitigation and order management. It calculates position sizing and exit levels based on a user-defined Reward to Risk (RnR) ratio.
A key feature is the ATR Trailing Stop. When enabled, the stop price ratchets behind the price action based on volatility. Users can define a "Trigger Exit" level (expressed as a decimal of the target distance); once price reaches this threshold, the trailing mechanism activates. This allows for locking in profits while giving the trade room to breathe during initial volatility.
The strategy also includes backtesting filters such as commission settings (defaulted at 0.05% to reflect crypto exchange fees), slippage, and time/date filters to ensure performance results are as realistic as possible.
Settings
Trade Variables
- Detect Long/Short Trades: Enables or disables the strategy's ability to take specific trade directions.
- Use Limit exit: Toggles the use of profit targets.
- Use ATR Trailing Stop: Activates the volatility-based trailing stop mechanism.
- Allow Reversal Trades: Determines if the strategy can flip directly from long to short.
- Set Max Total DrawDown: Protects equity by halting trades if a specific loss threshold is met.
Risk Management
- Reward to Risk Ratio: Sets the distance of the limit order relative to the stop loss.
- Risk Adjustment: An ATR-based multiplier to buffer stop losses away from pivot points.
- Swing Lookback: The number of bars used to determine local highs and lows for stop placement.
- Max Drawdown (%): The percentage of equity loss allowed before the bot stops trading.
Trailing Stop
- ATR Trailing Stop Multiplier: Determines the sensitivity of the trailing stop.
- ATR Trailing Stop Source: Selects the price data (High/Low, Close, or Open) used for the trail calculation.
- R:R To Trigger Exit: The percentage of the profit target required to activate the trailing stop.
MA Settings
- MA Type #1 / #2: Selection of various moving average types including EMA, HEMA, SMA, HMA, etc.
- MA Length #1 / #2: The lookback periods for the crossover signal.
FAQ
How do I connect this to my 3Commas bot?
You must input your specific bot "Start" and "Stop" deal commands into the script's alert message fields and use the {{strategy.order.alert_message}} placeholder in the TradingView alert box.
What is the "Trigger Exit" setting? This setting defines how far toward your profit target the price must move before the trailing stop becomes active. For example, a value of 0.5 means the trail starts once 50% of the profit target is reached.
How can I access the 3Commas Bot indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

