Home » Posts » Documentation » 3Commas DCA Bot Indicator & Strategy v1

3Commas DCA Bot Indicator & Strategy v1

Table of Contents

Overview

This TradingView (TV) indicator attempt to implement the ASAP deal start condition found in the 3Commas DCA trading bot settings.

YouTube Video Overview

Indicator Anatomy

Figure 1 – Indicator Anatomy

Indicator Settings

General Info

Figure 2 – General Info Section

Version

The version input is for displaying the published version of the indicator. It is intended to be for informational use only.

Main Settings

Figure 3 – Main Settings Section

Name

This field is equivalent to the “Name” field of the 3Commas Bot Settings page. It can be used to contain the value of the same input on the bot settings page to help correlate the indicator settings to bot settings when dealing with multiple bots.

Bot Type

This field is equivalent to the “Bot Type” field of the 3Commas Bot Settings page. It is reproduced in the indicator in order to help communicate that the script is not designed for composite bots.

Exchange Buy Fee (%) & Sell Fee (%)

These fields do not have any equivalent fields on the 3Commas Bot Settings page because they already have the fee schedule integrated into their platform and also TradingView does not make available the fee schedule for a given symbol on the chart.

The value represents the exchange fee that is applied when the limit or market order(s) to buy or sell the asset is filled. The value of this field will be used to offset the Break-Even price on the chart, which the Take Profit and Stop Loss prices are relatively calculated against.

Deal Start Condition

Figure 4 – Deal Start Condition: Open New Trade ASAP

Open New Trade

This field is equivalent to the “Open new trade asap” field of the 3Commas Bot Settings page. Possible values are:

  • ASAP – This option will simulate the ASAP start condition in 3Commas.
  • Trading View Custom Signal – This option will enable the use of the settings in the TV CUSTOM SIGNAL section.

Start Date/Time

The value of this field will set the date and time when the indicator will begin a deal as soon as possible. Nothing will be plotted to the chart before this time frame. When the input is used to specify a date/time that is within the chart’s time range, it will display a label and colored column to visualize the starting point…

Figure 5 – Start Date/Time Label

Stop Date/Time

The value of this field will set the date and time when the indicator will close the active deal as soon as possible. Nothing will be plotted to the chart after this time frame. When the input is used to specify a date/time that is within the chart’s time range, it will display a label and colored column to visualize the ending point…

Figure 6 – Stop Date/Time Label

TV Custom Signal

Figure 7 – TV Custom Signal Section

Chart/Indicator Data Point

Use this input to link to a specific data point on an existing indicator on the chart or any OHLC data point. The value is then used for the ‘Start Deal When‘, ‘Close Deal When‘ or ‘The Value Of‘ inputs in defining the eligibility condition.

Fix N/A Values

When checked, the indicator will get the last know value from the Chart/Indicator Data Point only when the current value n/a. This is useful when linking to existing indicators on the chart that are configured for a time frame that is higher than the current chart, thus it is possible that the current bar’s value is n/a.

[✓] ───────Enable Start Deal Signal───────

When checked, the start deal rules defined in the inputs below are active and will be used for determining if a Deal Start signal is to be executed.

Start Deal When

The value of this field will define what data point in the indicator or chart is to be used in the comparison condition. Possible values are:

  • Chart/Indicator Data Point
  • open
  • high
  • low
  • close
  • hl2
  • hlc3
  • ohlc4

Is

The value of this field will define the operator to use when comparing the data points in the indicator or chart. Possible values are:

  • Greater Than
  • Less Than
  • Between
  • Not Between
  • Equal
  • Not Equal

The Value Of

The value of this field will define the data point in the indicator or chart to use in the comparison condition. Possible values are:

  • Chart/Indicator Data Point
  • Custom Value(s)
  • open
  • high
  • low
  • close
  • hl2
  • hlc3
  • ohlc4

Custom Value 1 (Single or Lower Bound)

Defines the single or lower bound value (range comparison) to use as the criteria when testing the Chart/Indicator Data Point value. Only required when the The Value Of input value is “Custom Value(s)“.

Custom Value 2 (Upper Bound Only)

Defines the upper bound value (range comparison) to use as the criteria when testing the Chart/Indicator Data Point value. Only required when the The Value Of input value is “Custom Value(s)” AND the ‘Is‘ input value is set to “Between” or “Not Between“.

Trigger

Defines when to accept the signal from the provider. Possible values are:

  • Once Per Bar
  • Once Per Bar Close

Once Per Bar triggers an alert whenever conditions are met (no more than once per bar).

Once Per Bar Close is the same as above, but the bar is required to close for an signal to be accepted.

[✓] ───────Enable Close Deal Signal ───────

When checked, the close deal rules defined in the inputs below are active and will be used for determining if a Deal Close signal is to be executed.

Close Deal When

The value of this field will define what data point in the indicator or chart is to be used in the comparison condition. Possible values are:

  • Chart/Indicator Data Point
  • open
  • high
  • low
  • close
  • hl2
  • hlc3
  • ohlc4

Is

The value of this field will define the operator to use when comparing the data points in the indicator or chart. Possible values are:

  • Greater Than
  • Less Than
  • Between
  • Not Between
  • Equal
  • Not Equal

The Value Of

The value of this field will define the data point in the indicator or chart to use in the comparison condition. Possible values are:

  • Chart/Indicator Data Point
  • Custom Value(s)
  • open
  • high
  • low
  • close
  • hl2
  • hlc3
  • ohlc4

Custom Value 1 (Single or Lower Bound)

Defines the single or lower bound value (range comparison) to use as the criteria when testing the Chart/Indicator Data Point value. Only required when the The Value Of input value is “Custom Value(s)“.

Custom Value 2 (Upper Bound Only)

Defines the upper bound value (range comparison) to use as the criteria when testing the Chart/Indicator Data Point value. Only required when the The Value Of input value is “Custom Value(s)” AND the ‘Is‘ input value is set to “Between” or “Not Between“.

Trigger

Defines when to accept the signal from the provider. Possible values are:

  • Once Per Bar
  • Once Per Bar Close

Once Per Bar triggers an alert whenever conditions are met (no more than once per bar).

Once Per Bar Close is the same as above, but the bar is required to close for an signal to be accepted.

Strategy

Figure 7 – Strategy Section

Strategy

This field is equivalent to the “Strategy” field of the 3Commas Bot Settings page.

This field defines the strategy the bot is to use. Options include Long and Shorts.

Base Order Size

This field is equivalent to the “Base order size” field of the 3Commas Bot Settings page.

Define the size of the first starter order.

Safety Order Size

This field is equivalent to the “Safety order size” field of the 3Commas Bot Settings page.

The size of the following averaging orders.

Base & Safety Order Size Unit

This field will specify the unit for the “Base Order Size” and “Safety Order Size” inputs below. Given a symbol of BTC/USDT, BTC is considered the “Base“, USDT is considered the “Quote“.

A value of “% Quote” will treat the values as percentages (%) of the Initial Capital value plus the Net Profit value that is accumulated throughout the back testing (a.k.a. Compounding).

Start Order Type

Defines the order type to use for the base order.

This input is only here to echo the exact setting in the bot settings page for documentation purposes only. This input will not affect the indicator performance in any way

Safety Orders

Figure 8 – Safety Order Section

Max Safety Trades Count

This field is equivalent to the “Max safety trades count” field of the 3Commas Bot Settings page.

The maximum amount of safety orders the bot can use for one deal.

Max Active Safety Trades Count

This field is equivalent to the “Max active safety trades count” field of the 3Commas Bot Settings page.

Defines the amount of Safety Orders the bot is allowed to place in advance on the exchange’s order book for the asset being traded.

Note: This input is only here to echo the exact setting in the bot settings page for documentation purposes only. This input will not affect the indicator performance in any way.

Price Deviation To Open Safety Orders (% From Initial Order)

This field is equivalent to the “Price deviation to open safety orders (% from initial order)” field of the 3Commas Bot Settings page.

Defines the step in percentage between safety orders.

Safety Order Volume Scale

This field is equivalent to the “Safety order volume scale” field of the 3Commas Bot Settings page.

Defines the value of this field defines the volume of each next safety order will be multiplied by this value.

Safety Order Step Scale

This field is equivalent to the “Safety order step scale” field of the 3Commas Bot Settings page.

Defines the value of this field defines the step between each next safety order will be multiplied by this value.

Take Profit

Figure 9 – Take Profit Section

Take Profit (%)

This field is equivalent to the “Take profit (%)” field of the 3Commas Bot Settings page.

Defines how much profits the bot should make from each deal. All exchange fees are included automatically.

Take Profit Type

This field is equivalent to the “Take profit type” field of the 3Commas Bot Settings page.

With percentage from base order, the bot will ignore the total volume of the deal. With the base order size $100 and target profit 5%, the profit will always be $5. With percentage from total volume, the profit will grow as the volume grows.

Trailing Deviation

This field is equivalent to the “Trailing deviation” field of the 3Commas Bot Settings page.

When checked, the indicator will trail behind the price action at a specific deviation percentage once the “Take Profit %” is reached, which acts as a trigger. This value should not exceed the “Take Profit %“, otherwise it’s possible to close the deal in a loss.

Stop Loss

Figure 10 – Stop Loss Section

Stop Loss (%)

This field is equivalent to the “Stop Loss (%)” field of the 3Commas Bot Settings page.

When checked, the bot will close deals in a loss when the price drops to or more than configured level. The bot calculates stop loss level from the base order price, not average deal entry price.

Stop Loss Action

This field is equivalent to the “Stop Loss action” field of the 3Commas Bot Settings page.

The bot can do different actions when the stop loss is triggered. Changing this setting doesn’t affect already opened deals. You should edit active deals individually when want to change the stop loss action.

Stop Loss Timeout (bars)

This field is equivalent to the “Stop Loss timeout” field of the 3Commas Bot Settings page.

The bot will perform an additional check when the price reaches Stop Loss price. After the specified amount of bars passes, the bot will check if the price is still below Stop Loss price. If yes, the bot closes the deal by market order. If not, the deal remains active.

Note: 3Commas uses seconds as the unit for this input, but this cannot be simulated in TradingView because to do so will require code that will make the indicator susceptible to repainting.

Advanced Settings

Figure 11 – Advanced Settings Section

Don’t start deal if the daily volume is less than

This field is equivalent to the “Don’t start deal if the daily volume is less than” field of the 3Commas Bot Settings page.

When checked, the bot won’t open a new deal until the coin has more volume for the last 24 hours than entered here. Specified in Base units. Minimum value is 0 and the maximum unlimited.

Note: On charts with resolution times lower than one day, the indicator will calculate the number of historical bars to use to sum the volume to be roughly equal to 24 hours. On charts with resolutions times greater than or equal to one day, the indicator will simply use the previous bar’s volume value.

Minimum price to open deal

This field is equivalent to the “Minimum price to open deal” field of the 3Commas Bot Settings page.

When checked, the bot won’t open a new deal if the current price is lower than the value specified. Minimum value is 0 and the maximum unlimited.

Maximum price to open deal

This field is equivalent to the “Maximum price to open deal” field of the 3Commas Bot Settings page.

When checked, the bot won’t open a new deal if the current price is higher than the value specified. Minimum value is 0 and the maximum unlimited.

Cooldown between deals

This field is equivalent to the “Cooldown between deals” field of the 3Commas Bot Settings page. Instead of measuring seconds, it will count the number of bars on the chart.

When checked, the bot will wait this amount of bars after the deal is completed before starting a new trade. Minimum value is 0 and the maximum is 48.

Open deals & stop

This field is equivalent to the “Open deals & stop” field of the 3Commas Bot Settings page.

When checked, the bot will stop after completing the set number of deals. Minimum value is 0 and the maximum unlimited.

Verify Price For Limit Orders (ticks)

When checked, the indicator only considers limit orders filled when prices move a certain number of ticks past the limit price.

Close Deal After Timeout

Figure 12 – Close Deal After Timeout Section

Close Deal After Timeout

This field is equivalent to the “Close deal after timeout” field of the 3Commas Bot Settings page.

When checked, it will close the deal automatically, whether in profit or loss, if it hasn’t reached the Take Profit target configured.

The Time After Which, Deal Will Be Closed Automatically (In Bars)

This field is equivalent to the “The time after which, deal will be closed automatically” field of the 3Commas Bot Settings page.

Since the indicator cannot implement a timer like 3Commas (Min, Hrs, or Days), the unit is the number of bars for the current chart resolution that is allowed to elapse until the deal is closed automatically, whether in profit or loss, if it hasn’t reached the Take Profit target configured.

Chart Settings

Figure 13 – Chart Settings Section

Show Safety Order Lines, Prices, Fill Shapes, and Color

When checked, the safety order prices will appear on the DCA levels for the most recent open deal. Also, the triangle cross shapes will appear when price action crosses a safety order DCA level. You can also control the visibility of the price and triangle shapes as well as the color.

Show Used Amount For Each Step Table

When checked, the table will be made visible.

Figure 14 – Used Amount for Each Step Table

Show Statistics Table

When checked, the 3C-DCA-ASAP Statistic table will be made visible.

The following image demonstrates how the colors are applied to the table

Figure 15 – Statistics Table Colors

Table Color Theme

Changes the colors of the Statistics and Used Amount For Each Step tables. The following is the theme colors

Color NameTV DarkTV LightMS Blue MediumTheTradingParrot
Header Background#2A2E39#F0F3FA#4472C4#C9C19B
Header Text#D1D4DC#434651#F1F4F8#262626
Cell Background#131722#FFFFFF#FFFFFF (even)
#D9D9D9 (odd)
#999999 (even)
#CCCCCC (odd)
Cell Border#2A2E39#F0F3FA#2A2E39#2A2E39
Stat Label#D1D4DC#434651#262626#262626
Stat Value#2196F3#2196F3#262626#262626

Examples of theme colors:

Figure 16 – TV Dark Theme
Figure 17 – TV Light Theme
Figure 18 – MS Blue Medium Theme
Figure 19 – TheTradingParrot Theme

Data Window

Both the Indicator and Strategy versions will output series data values to the chart that are visible in the Data Window of TradingView. This section will describe each data point to help you understand the data conditions within the scripts logic.

Data Points

Figure 20 – Data Window

Bar Index

Each bar (or candle) on the chart is assigned an index number. This data point will display the current bar index. Numbering is zero-based, where the index of the first bar is 0.

24 Hr Volume

Displays the 24 hour volume value that is calculated for the current bar. This is useful for when you enable the “Don’t start deal if the daily volume is less than” input and supply a non-zero value.

The value will be “n/a” is the option is enabled in order to improve script execution performance.

Volume Filter Result

Displays the result of the 24 hour volume test for the current bar. A value of 0 is failed and 1 is success.

Minimum Price Filter Result

Displays the result of the minimum price test for the current bar when the “Minimum price to open deal” is enabled. A value of 0 is failed and 1 is success.

Maximum Price Filter Result

Displays the result of the maximum price test for the current bar when the “Maximum price to open deal” is enabled. A value of 0 is failed and 1 is success.

Cooldown Filter Result

Displays the result of the cooldown bar count test for the current bar when the “Cooldown between deals” is enabled. A value of 0 is failed and 1 is success.

Max Closed Deals Filter Result

Displays the result of the cooldown bar count test for the current bar when the “Open deals & stop” is enabled. A value of 0 is failed and 1 is success.

Stop Loss Timeout Bar Count

Displays the bar count since the stop loss timeout was activated. This is useful to see how the closing of the deal occurs when the Stop Loss Timeout feature is enabled. The chart will also display the count on the chart below each candle that is below the Stop Loss price line. When the candle closes above the Stop Loss price line, the count is set to 0.

Figure 21 – Stop Loss Timeout Count

Close Deals By Custom Signal

Displays the price at which the deal was forcefully closed by the “Close Deal When” condition rule set. In addition to the price, the chart will display a label with a “electric plug” icon (🔌) to indicate the event took place.

Figure 22 – Close Deals By Custom Signal Label

Close Deal After Timeout

Displays the price at which the deal was forcefully closed by the “Close Deal After Timeout” input is enabled. In addition to the price, the chart will display a label with a “hourglass done” icon (⌛) to indicate the event took place.

Figure 23 – Close Deal After Timeout Label

Stop Loss Timeout Reached

Displays the price at which the deal was forcefully closed by the “Stop Loss Timeout” input is enabled. In addition to the price, the chart will display a label with a “hourglass done” icon (⌛) to indicate the event took place.

Figure 24 – Stop Loss Timeout Label

Take Profit Cross (Long)

Displays the price where the triangle down shape (▼) is placed on the chart.

Take Profit Cross (Short)

Displays the price where the triangle up shape (▲) is placed on the chart.

Trailing Take Profit Activated

Displays the price where the x-cross shape (🞬) is placed on the chart.

Trailing Take Profit Cross (Long)

Displays the price where the triangle down shape (▼) is placed on the chart.

Trailing Take Profit Cross (Short)

Displays the price where the triangle up shape (▲) is placed on the chart.

Stop Loss Crossed (Long)

Displays the price where the triangle up shape (▲) is placed on the chart.

Stop Loss Crossed (Short)

Displays the price where the triangle down shape (▼) is placed on the chart.

Stop Loss Timeout Activated

Displays the price where the x-cross shape (🞬) is placed on the chart.

Close Deal By Custom Signal

Displays the price where the x-cross shape (🞬) is placed on the chart.

BE

Displays the Breakeven price for the current bar that is rendered on the chart.

TP

Displays the Take Profit price for the current bar that is rendered on the chart.

TTP

Displays the Trailing Take Profit price for the current bar that is rendered on the chart.

SL

Displays the Stop Loss price for the current bar that is rendered on the chart.

Using the Statistics Table

Both the Indicator and Strategy versions will display the Statistics table that summarizes statistical data points using the price action history of trades. This section will describe each section of the data points to help you understand the performance of the indicator.

Figure 25 – 3C-DCA Statistics Table

Data Points

Name

Displays the value of the Name input along with the Strategy option value in square brackets.

Summary

Displays a summary of the indicator configuration settings that have significant value. The following are the meaning of the abbreviation labels:

  • TP – Take profit (%)
  • BO – Base order size
  • SO – Safety order size
  • OS – Safety order volume scale
  • SS – Safety order step scale
  • SOS – Price deviation to open safety orders (% from initial order)
  • MTSC – Max safety trades count

Exchange / Pair

Display the exchange name and symbol for the chart. It uses the syminfo.prefix variable for the exchange name and the the syminfo.ticker variable for the symbol.

Balance

This field is equivalent to the “Balance” value on the 3Commas Bot Settings page. The value of this field is the same as the Initial Capital input from the Properties tab of the Strategy script and Initial Capital input from the Inputs tab of the Indicator script.

Max Amount for Usage (Based on current rate)

This field is equivalent to the “Max amount for bot usage (Based on current rate)” value on the 3Commas Bot Settings page.

It is an approximate calculation of the capital that is needed to support the Base Order Size and Safety Order Size along with the Max Count, Volume, and Scale setting values using the current market rates at the beginning of the chart. If the value exceeds the Balance value, the indicator will display a warning on the last bar on the chart, like this…

Figure 26 – Max Amount for Usage Warning table

Max Safety Order Price Deviation

This field is equivalent to the “Max safety order price deviation” value on the 3Commas Bot Settings page.

Displays the maximum deviation from the average buy price to the last safety order level. This value is useful to define the Stop Loss value when enabled.

% Of Available Balance To Be Used By The Bot

This field is equivalent to the “% of available balance to be used by the bot” value on the 3Commas Bot Settings page.

Displays the percent of the Balance value that will be needed to the bot to support the base and safety orders as configured.

No. Of Deals Started

Displays a count value of all the deals that were started on the chart.

No. Of Deals Completed

Displays a count value of all the deals that were closed at the Take Profit, Trailing Take Profit, or Stop Loss price points.

Win / Loss Rate %

Displays the result of the following equation: [No. Of Deals Completed In Profit] / [No. Of Deals Started] X 100

Displays the result of the following equation: [No. Of Deals Completed In Loss] / [No. Of Deals Started] X 100

Daily P&L

Displays the average profit or loss percentage per day.

Note: On charts with resolution times lower than one day, the indicator will calculate the number of historical bars to use to sum the profits and losses to be roughly equal to 24 hours. On charts with resolutions times greater than or equal to one day, the indicator will simply use the previous bar’s profit/loss value.

Max Drawdown

Displays the maximum drawdown percentage relative to the average buy price that a single deal experienced as well as the Deal # so that you can find the deal using the TradingView back tester since the order names contain the Deal # along with the Safety Order #.

Figure 27 – Deal Number in Signal Name in List of Trades Table

Mean, Median, Mode, Min, Max, Std. Dev., and Total Bars In Deals

Displays the mean (average), median (middle value), mode (most frequent value), minimum, maximum, standard deviation, and total of all the bar counts the indicator gathered when it was in a deal. The count will begin at the value of 1 (one) when the Base Order is filled. As each bar is completed, the count will increment by 1 (one) and be reset to zero when the deal is completed. These values will only update as soon as a deal is completed.

In addition, the value will display the number of years, months, weeks, days, hours, minutes, and seconds in parentheses.

Mean, Median, Mode, Min, Max, and Total of Safety Orders Filled

Displays the mean (average), median (middle value), mode (most frequent value), minimum, maximum, and total of all the Safety Orders that were filled. These values will only update as soon as a deal is completed.

No. of Safety Order # Filled

Displays a count value of all the Safety Orders that were filled by level index number. It will also show the ratio and percentage of the number of safety orders cracked to the sum of all safety orders cracked. These values will only update as soon as a deal is completed.

Using the 3C TA Starting Conditions Indicator

The 3Commas TA Start Conditions Indicator v1 indicator can be used to simulate 3Commas bot settings using the built-in indicators. This section will cover the details on how to use the TA Start Conditions indicator.

Setup the 3C TA Starting Conditions

In this example we will setup a Long DCA bot using the RSI-7 and ULT-7-14-28 standalone indicators with the 3C DCA bot to back test results on ETHUSD on a 10 minute chart.

The following are the 3C-TASC settings:

Figure 28 – 3C-TASC Settings

The indicator can be seen showing start deal signals below…

Figure 29 – Chart View with new 3C-TASC Settings

Setup 3C DCA Bot Indicator

Now that the 3C TASC indicator has been set up, we are ready to link it with the 3C DCA Bot indicator.

Open the settings and apply the following changes to the inputs…

Figure 30 – 3C DCA Settings with 3C TASC as a Custom Signal

Some of the values are not clearly seen because they get clipped due to the size of the input, but the following is a summary of the values:

Field NameValue
Open new tradeTrading View Custom Signal
Chart/Indicator Data Point3C-TASC: Start Condition Result
Start Deal WhenChart/Indicator Data Point
IsEqual
The Value OfCustom Value(s)
Custom Value 1 (Single or Lower Bound)1

With these new settings, you can now see the indicator will redraw and demonstrate that the signal is received and will start a new deal…

Figure 31 – Chart view with 3C-TASC sending Start Deal Signals to 3C-DCA

You can further adjust the settings in the 3C-TASC indicator to suit your needs before setting up the bot on 3Commas.

Send me an email when this page has been updated

Leave a Reply

Your email address will not be published. Required fields are marked *