Deals Labelling with 3cBot+ BackTesting Studio

hBroker 3cBotPlus
4 min readMar 17, 2022

--

TradingView trades are not the same thing of 3Commas DCA bot deals. Here we will describe their differences and how 3cBot+ can help you to unfold the correct sequence of closed deals from a sequence of ordered trades in the TradingView Strategy Tester.

Difference between a trade and deal

A DCA bot deal, such as it works in 3Commas, is a sequence of one or more orders placed by the DCA bot to achieve a pre-configured take-profit. The first order of this sequence is named Base Order(BO) and the next orders of the sequence are named Safety Orders(SO). Depending on the bot configuration and the market conditions the same bot can close the deal just placing a Basic Order or it can requires one or more Safety Orders placements.

A TradingView trade, such as it shown in the Strategy Tester-> List Trades, is a sequence of just two orders: a buy and sell, or, a sell and a buy.

Figure 1 — Deal Structure

For example a Deal closed by a DCA bot by using two safety orders will be visualized by TradingView as sequence of 3 trades as shown in the Figure 1. Therefore, even if BackTesting Studio executes the logic of the DCA bot Deal, the TradingView Strategy Tester will show and list a sequence of trades. In order to make a correct evaluation of a closed deal, BackTesting Studio attach labels to each trade with its parent deal and keeps an internal counting of the order volume size.

Deal Labelling adopted by BackTesting Studio

Each trade processed by the BackTesting Studio is labelled with the numbered parent deal concatenated with the order placed from the Base Order to the last Safety Order executed. For example, considering the Deal in the Figure 1 as the first Deal started by a DCA bot, then the labels attached to each trade will be:

Deal#1.BO
Deal#1.SO#1
Deal#1.SO#2

Therefore when the deal will be closed a correct evaluation can be calculated from the entry order at Deal#1.BO to the final exit order at Deal#1.SO#2.

Figure 2 — List Trades from TradingView Strategy Tester

In the Figure 2, TradingView shows in the first column the number of trade, in the second the order placed(long in that case) to buy(entry) and to sell(exit), in the third column the 3Bot+ deal labelling. For example the first deal, Deal#1, includes a Base Oder placed at 15:00 and required one Safety Order at 21:00 to close the Deal#1.

How to use trades2deal command line tool on exported list trades

Read all deals labelled in the TradingView Strategy Tester is a quite long task when your bot backtesting cover many deals. For such reason the Deal Panel resumes the most info related to the backtesting: the total number of closed deal — detailing the required safety orders, the total profit — in volume or in dollar, and the mean of all deals duration time grouped by safety orders(for example as shown in Figure 3).

Figure 3 — Deal Panel detail

In addition to the visual tool, all TradingView paid members able to export the trade list as a .CSV file can use the 3cBot+ trades2deals free python script to create a batch processing and export the deals list to other platforms.

Figure 4 — trades2deals python script

In Figure 4, the trade2deals script execution. The script is free available at https://gist.github.com/3cBotPlus/f1a0e58a6c6211f91e1dcedec7d2900d

Final note. TradingView add automatically size order quantity using a logic different from the DCA bot logic.

Figure 5 — Hide TradingView Quantity

To hide these values you have to uncheck the quantity field in the Style Tab(Figure 5). Therefore ignore these ‘contracts’ quantity generated by TradingView Strategy Tester and use the Order Size Panel for DCA BackTesting.

--

--