INVITE-ONLY SCRIPT

3Commas DCA Bot Strategy v1.0

Updated
Introduction

The strategy attempts to implement a majority all of the settings found on the 3Commas DCA Bot setting page that can be implemented within a TradingView indicator. Specifically, it will implement the "Open new trade ASAP" and "Trading View Custom Signal" deal start conditions. In this way, you can leverage the power of TradingView's backtester to model your settings and analysis past performance as well as leverage TradingView's alert notification subsystem to send Deal Start and Close signals to 3Commas using almost any of the thousands of scripts found in the Public Library (see "What does it do and how does it do it?" section below for more information on how to do this using the RSI indicator as an example).


How is it original and useful?

This strategy is unique in that it's the only one (as of the initial publications) that can handle 28 out of 32 bot settings (88% coverage) that are found on the 3Commas bot settings page. In addition, because it is a TradingView script, you will benefit from the following:

  • Model your bot's configuration using the backtester on any timeframe and evaluate its performance using the chart's history.
  • View a table of detailed statistics pertaining to deals started and completed, win/loss rates, daily P&L, true max drawdown, and detailed statistics on bars in deal along with safety orders filled.
  • View a table of "Used amount for each step" as presented in 3Commas as well.
  • Ability to link to almost any TradingView chart indicator that provides a single data point for buy/sell signals.
  • Make use of the 3Commas TA Start Conditions indicator to emulate the 3Commas built-in indicators for further performance evaluation with the backtester.



How does it compare to other scripts in the Public Library?

This strategy offers a very detailed, comprehensive settings and maybe the only one (as of the initial publication) that can handle 28 out of the 32 bot settings that are found on the 3Commas bot settings page (that can be handled within TradingView, because some cannot be modeled due to chart and language constraints). Specifically, the following 3Commas bot settings and inputs are addressed with asterisks denoting specific limitation due to TradingView's platform architecture and/or constraints:

Main settings
  • ✅ Name
  • ❌ Exchange* (Not handled since it is inherited from chart)
  • ⚠ Bot type* (Only Single-pair because you simply apply the indicator to as many pairs you desire in separate charts to simulate a Multi-pair setting)


Pairs
  • ❌ Pairs* (Not handled since it is inheriting the symbol from the chart)


Strategy
  • ✅ Strategy
  • ❌ Profit currency* (Not handled since there is no equivalence in TradingView)
  • ✅ Base order size / unit
  • ✅ Safety order size / unit
  • ✅ Start order type


Deal start condition


Take profit
  • ✅ Take profit (%)
  • ✅ Take profit type
  • ✅ Trailing
  • ⚠ Trailing deviation* (modified to handle TradingView's broker emulator properly)


Stop loss
  • ✅ Stop Loss (%)
  • ✅ Stop Loss action
  • ⚠ Stop Loss timeout* (modified to use "bars" as the unit of measure)


Safety orders
  • ✅ Max safety trades count (a total of 100 safety orders are supported!)
  • ⚠ Max active safety trades count* (Not handled since there is no equivalence in TradingView)
  • ✅ Price deviation to open safety orders (% from initial order)
  • ✅ Safety order volume scale
  • ✅ Safety order step scale


Advanced settings
  • ✅ Don't start deal(s) if the daily volume is less than
  • ✅ Minimum price to open deal
  • ✅ Maximum price to open deal
  • ⚠ Deal start delay (QFL and standard TV signals only)* (modified to use "bars" as the unit of measure)
  • ✅ Cooldown between deals
  • ✅ Open deals & stop


Close deal after timeout
  • ⚠ The time after which, deal will be closed automatically* (modified to use "bars" as the unit of measure)


In addition to the above inputs, the script will also support the same output data points that are found on the bot settings page, which are:

Assistant
  • ✅ Balance
  • ✅ Max amount for bot usage (Based on current rate)
  • ✅ Max safety order price deviation
  • ✅ % of available balance to be used by the bot


Table (Used amount for each step)
  • ✅ Order No.
  • ✅ Deviation %
  • ✅ Order Size (Base currency)
  • ✅ Order Volume (Quote currency)
  • ✅ Price
  • ✅ Average price
  • ✅ Required price
  • ✅ Required change
  • ✅ Total Size (Base currency)
  • ✅ Total Volume (Quote currency)



What does it do and how does it do it?

When applied to the chart for the first time, the default settings will work to execute the "Open new trade asap" deal start condition using a take profit of 4%, a base order size of 1.335% of equity (initial capital + net profit), a safety order size of 2.003% of equity (initial capital + net profit), a safety order volume scale of 1.5, a safety order step scale of 1.21, and a max safety trades count of 8. With these settings, as you scroll through the chart's history you should see price action crossing the DCA layers (denoted with blue triangles), and a green take-profit price line will render (with green triangle denoting the crossings). Lastly, in the upper-right corner of the chart the table of DCA statistics will render showing you all the gathered data that took place since the chart's starting history until the current time.

Using the "TV Custom Signal" section will allow you to "link" other chart indicators to supply "Start" and "Close" signals for the script. For example, here's how you can use the standard RSI indicator to generate an entry signal:

1) Add the stock RSI indicator and configure it to your desire.
2) Select the "RSI" indicator in the "Chart/Indicator Data Point" input.
3) Select "Chart/Indicator Data Point" in the "Start Deal When" input.
4) Select "Less Than" in the "Is" input.
5) Select "Custom Value(s)" in the "The Value Of" input.
6) Enter "25" in the "Custom Value 1 (Single or Lower Bound)" input.
7) Select "Trading View Custom Signal" in the "Open new trade" input (in the DEAL START CONDITION section).
8) Lastly, check the checkbox with a horizontal straight line above the "Start Deal When" input.

This means that the indicator will start a deal when the "RSI indicator" is "Less Than" the value of "25".


Strategy Results

The default settings are designed to ensure that the indicator will render chart elements when first loaded as well as to allow the backtester to gather order executions and display performance summary. The chart above is is using $10,000 initial capital, a commission rate of 0.1% for both entries and exits, and a 1 tick slippage setting. It is also using 3.22581% of the equity for the Base Order Size, 6.45161% of equity for the first Safety Order Size. The Maximum Safety Trade Count is 4 with a Safety Order Volume Scale of 2, a Safety Order Step Scale of 1.53, Price Deviation To Option Safety Orders at 5.3, and a take profit of 4.5% with Trailing turned on at a deviation of 1.5%. All other settings are defaults.

It is recommended that the indicator be "tuned" for your specific market in order to best implement the strategy and obtain better desirable results. You do so by using the backtester and statistics table and observe the output values and learn how the indicator is performing in the chart history. Using this information, you can adjust the settings accordingly until you find the settings acceptable to your trading goals and risk tolerance.

Always keep in mind that past performance may not be indicative of future results. Settings that seem favorable for one market may be found to be disastrous in another. Therefore, do take the time needed to understand how the settings will behave with the given chart symbol.

Enjoy! 😊👍


How to obtain access to the script?

You have two choices:

  • Use the "Website" link below to obtain access to this indicator, or
  • Send us a private message (PM) in TradingView itself.
Release Notes
v1.0.5 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added labels to the checkbox above the "Start Deal When" and "Close Deal When" inputs to make it more clear on how to enable the feature.
  • Added "Position" drop-downs to control the placement of the Statistics table on the chart.
  • Added validation logic to layer position size and price to avoid runtime errors when the safety order configuration is calculating extremely high sizes and negative prices.
  • Added "Stop Loss Timeout Activated" and "Stoploss Timeout Bar Count" data point to the Data Window.
  • Added minor enhancements to the settings UI and table styling.
  • Combined several statistic data point together to keep the Statistics table as short as possible.
  • Fixed a defect where enabling the "Stop Loss Timeout (bars)" feature was not working properly.
  • Fixed a defect where using a "Safety Order Volume Scale" value of 1 was not working properly.
  • Replaced TP, TTP, and SL label shapes with plot shapes in order to avoid the 500 labels limit and improve readability in these events in the chart history.
Release Notes
v1.0.6 - Patch Release

New fix in this release for both Indicator and Strategy:

  • Fixed a defect where the Win/Loss Rate % was not being calculated for Stop Loss Timeouts and when using Close Deal Signal providers.
Release Notes
v1.0.7 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added the "Trigger" inputs to the "Start Deal Signal" and "Close Deal Signal" sub-sections to control when to accept the signal of either "Once Per Bar" or "Once Per Bar Close".
  • Added the "Closed Deal By Custom Signal" X-Cross shape on the chart when the "Close Deal Signal" is provided by another indicator.
  • Fixed a defect where using the "Stop Loss Timeout (bars)" with a "Stop Loss Action" of "Close Deal & Stop Bot" was not stopping trading.
  • Updated the "Equal" and "Not Equal" options in the "Is" inputs in the "TV CUSTOM SIGNAL" section to "Equal To" and "Not Equal To"
Release Notes
v1.0.8 - Patch Release

New fix for the Strategy version only:

  • Fixed a defect where the Strategy Tester was showing a 2nd safety order entry but the total volume size for the safety order was unevenly split between the two. The fix involved implementing a workaround with the strategy.exit() function by supplying a value for the 'from_entry' argument instead of omitting it to handle all the orders.
Release Notes
v1.0.9 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added the "Timeframe" data point to the "3C-DCA STATISTICS" table.
  • Added more abbreviation settings (MAD & SDSP) to the "Summary" data point in the "3C-DCA STATISTICS" table.
  • Added show/hide input controls for the various sections of the "3C-DCA STATISTICS" table.
  • Added "Show Profit/Loss Zones" and "Show Unrealized Profit/Loss Label" inputs to show or hide these new chart features.
  • Added a "Warning" input to the "ALERT SETTINGS" section to explain the use of the `barstate` variables causing a repaint warning when creating alerts. (Indicator version only)
  • Fixed a defect where the strategy would submit multiple limit orders on the real-time bar as it is crossing a Safety Order layer when "Recalculate On Every Tick" is checked in the Properties tab. (Strategy version only)
  • Fixed a defect where the deviation from the base order for the first safety order was not being inverted correctly for the "Short" strategy setting.
  • Fixed a defect where the first safety order was being considered crossed when the candle that started the deal was also exceeding the deviation percentage from the base order.
  • Updated the "Daily P&L" data point in the "3C-DCA STATISTICS" table to display the calculated daily P & L in deals and for the entire lookback period (in total).
  • Updated the safety order lines to place the price label at the real-time bar instead of the entry bar to improve readability.
  • Updated the inputs in the STRATEGY and SAFETY ORDERS section to match the new UI changes on 3Commas. Also updated tooltip content.
Release Notes
v1.0.10 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Updated the default value of the "Stop Date/Time" input to 2030-01-01.
Release Notes
v1.0.11 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added new "Ignore Value" inputs for the Start and Close Deal Signal sections.
  • Added new "Link to TradingView Script" and "Link to Documentation" inputs to the "GENERAL INFO" section.
  • Added the "No. of Single-Bar Entries & Exits" data point to the "3C-DCA STATISTICS" table.
  • Added new "Stat Label Font Weight" input to change the font labels to bold or normal for the "3C-DCA STATISTICS" table.
  • Removed almost all tooltip icons and text due to the 60K compiled tokens limitation and tooltips consume a lot of these tokens.
  • Updated the Statistics table rendering criteria to draw the table during Replay mode of the chart.
Release Notes
v1.0.12 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Fixed a defect where using the "Percentage from base order" option for the "Take Profit Type" input was not calculating the Take Profit price correctly.
Release Notes
v1.0.13 - Patch Release

New fixes in this release for both Indicator and Strategy:

  • Fixed a defect where a single candle will cross a safety layer and the take profit price and not close the deal.
Release Notes
v1.0.14 - Patch Release

New features in this release for both Indicator and Strategy:

  • Added new "Crossing", "Crossing over", and "Crossing under" options to the "Is" inputs for the Start and Close Deal Signal sections.
Release Notes
v1.0.15 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added support for a comma-delimited list of values for the "Bot ID" input with placeholders "{{bot_id_1}}", "{{bot_id_2}}"..."{{bot_id_10}}", etc. (Indicator Only)
  • Fixed a defect where the "Errors Found" table would disappear when the current bar would complete, and a new bar would begin.
Release Notes
v1.0.16 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added the "in Deal ##" values for the "Min Bars in Deals" and "Max Bars in Deals" data point in the statistics table.
  • Updated the "Pair" data point in the Statistics table to show the 3Commas formatted symbol instead of the TradingView ticker ID in order to know if you should use the "Use Custom Symbol" input or not.
  • Fixed a defect where setting the "Max Safety Trades Count" to zero would cause a fatal error of "Study Error, Index 1 is out of bounds, array size is 1."
Release Notes
v1.0.17 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added "No. of Base Order-Only Deals" data point to the 3C-DCA Statistics table.
  • Converted the "Open Deal Signal Message" and "Close Deal Signal Message" inputs to text area to support multi-line messages.
  • Fixed a defect where checking the "Open Deal Signal Message" and "Close Deal Signal Message" checkboxes when the "Bot ID" input was blank would cause a "Index 1 is out of bounds" fatal error.
  • Moved the "Base & Safety Order Size Unit" drop-down into it's own row instead of next to the "Base Order Size" input.
  • Updated the JSON messages in the "Open Deal Signal Message" and "Close Deal Signal Message" inputs to contain the newline character ("\n") due to some users needing it for a successful signal to be accepted by 3Commas.
  • Upgraded to source code to version 5 of Pine Script.
Release Notes
v1.0.18 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added the "Verify Price For Limit Orders (ticks)" input to the "ADVANCED SETTINGS" section. (Indicator only)
  • Added the "Total Volume" data point to the 3C-DCA Statistics table that reports all the base & quote volume used in all the deals.
  • Fixed a defect with the Profit/Loss Zones background color not having any transparency and added the color settings to the Style tab for customization.
Release Notes
v1.0.19 - Patch Release

New features and fixes in this release for both Indicator and Strategy:

  • Added the "close_entries_rule" argument to the "strategy()" function in order to eliminate single limit orders being broken out to multiples in the Strategy Tester. (Strategy only)
  • Updated the drop-down inputs that have a blank value to a single dash (-) in order to better support the Optimiser plugin's ability to read the values.
Release Notes
v1.0.20 - Patch Release

New features/fixes in this release:

  • Implementing a workaround to avoid a defect with the Strategy Tester where calling "strategy.close_all()" function twice will open a short position in the List of Trades table. (Strategy only)
Release Notes
v1.0.21 - Patch Release

New features/fixes in this release:

  • Fixed a defect caused by implementing the workaround in the previous release where the limit orders were not being canceled when the Stoploss timeout was reached. (Strategy only)
Release Notes
v1.0.22 - Patch Release

New features/fixes in this release:

  • Fixed a defect where there was a missing comma in the "Close Deal Signal Message" text area after the 0 value for the "delay_seconds" property. (Indicator only)
Release Notes
v1.0.23 - Patch Release

New features/fixes in this release:

  • Added the "Set to Breakeven after Safety Order No." input to the "ADVANCED SETTINGS" section.
Release Notes
v1.0.24 - Patch Release

New features/fixes in this release:

  • Added the ability to set the Take Profit % after a given number of bars in a deal has been reached as a result of the following:
  • Added the "Set TP to [X]%, on bars in deal [Y]" input to the "TAKE PROFIT" section.
  • Added the "When price is beyond new TP price, then [choice]" input to the "TAKE PROFIT" section.
  • Moved the "Set TP to Breakeven, after Safety Order No." input to the "TAKE PROFIT" section.
  • Reordered the "STRATEGY" and "SAFETY ORDERS" sections to match the Advanced user interface for improved efficiency when comparing settings between 3Commas and the script settings.
Release Notes
v1.0.25 - Patch Release

New features/fixes in this release:

  • Fixed a defect where using the "Cooldown Between Deals (bars)" input was only working for the ASAP Deal Start Condition.
Release Notes
v1.0.26 - Patch Release

New features/fixes in this release:

  • Added the "Override Minimum Tick Precision", "Custom Minimum Tick Precision", and "Method To Adjust Prices To Minimum Tick Precision" inputs to the "ADVANCED SETTINGS" section to handle exchanges that require a specific precision in prices.
  • Added the "Safety Order Filled" alert condition.
  • Added the "Safety Order Filled Signal Message" checkbox and text area to support the "add_funds_in_quote" or "add_funds_in_base" messages that are found on the bot Information page.
  • Added new placeholders for the "Safety Order Filled Signal Message" alerts message. (Indicator version only)
    New placeholders are: {{event_name}}, {{break_even_price}}, {{stop_loss_price}}, {{take_profit_price}}, {{base_order_price}}, {{count_of_filled_safety_orders}}, {{safety_order_quote_volume}}, {{safety_order_base_amount}}
  • Fixed a defect where TV no longer supports line breaks in the "stepline" line style that is used for the "Breakeven", "Take Profit", and "Stoploss" price lines.
  • Reordered the "Max Active Safety Trades Count" and "Max Safety Trades Count" inputs to match the order with 3Commas Bot Settings page.
  • Reordered the "Stat Label Font Weight" input to be above the "Cell Text Size" input for the Statistics Table settings since it really is not related to the Custom theme color inputs that were surrounding it.
  • Reordered the data points in the Data Window to move the price values at the top because TV's will only allow the first 19 data points to be resolved using placeholders in alert condition messages.
  • Renamed the "Open Deals & Stop" input to "Open X Deals & Stop" to match the label for the input on the 3Commas Bot Settings page.
  • Renamed the "ALERT SETTINGS" section to "ANY ALERT() FUNCTION CALL" to make it more clear about the type of alert that must be used for the inputs in the section.
Release Notes
v1.0.28 - Patch Release

New features and fixes in this release:

  • Reverted the changes in v1.0.27 because TradingView has resolved the compiler issues that was preventing the indicator from being added to the chart for the first time.
  • Added the "Take Profit set to Breakeven" alert condition.
  • Added the "TP set to Breakeven after Safety Order No. Signal Message" checkbox and text area to support custom signals for informational use only.
  • Replaced the "Link to TradingView Script" and "Link to Documentation" inputs with the "Links to TradingView Script & Documentation" text area to make it easier to read the information.
3commasbacktestingbottradingDCARelative Strength Index (RSI)signalsstatisticsstoplosstrailingtakeprofit

Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact prosum_solutions for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases, you can find a good open-source alternative for free in our Community Scripts.

Author's instructions

To request access to this script, either use the "Website" link below or send us a private message (PM) in TradingView. We will respond as soon as possible.

Want to use this script on a chart?

Warning: please read before requesting access.

Contact Us on our Website: prosum-solutions.store/contact-us/
Documentation for Indicators: prosum-solutions.store/documentation/
Discord Server: discord.com/invite/Zuf9MyKmfW
Also on:

Disclaimer