Scale In : Scale OutScale In : Scale Out strategy is an adaptation and extension of dollar-cost-averaging.
As the name implies it not only scales in - allocates a given percentage of available capital to buy at each bar - it also scales out - sells a given percentage of holdings at each bar when a target profit level is reached.
The strategy can potentially mitigate risks associated with market timing.
Although dollar-cost-averaging is often recommended as a strategy for building a position, the management of taking and retaining profits is not often addressed. This strategy demonstrates the potential benefits of managing both the building and (full or partial) liquidation of an investment.
We do not provide any mechanism for managing stop losses. We assume a scale in/out strategy will typically be applied to investing in assets with a high conviction thesis based on criteria external to the strategy. If the strategy does not perform, then the thesis may need to be re-evaluated, and the position liquidated. Even in this case, scaling out should still be considered.
COST
TTP AbsolutnoAbsolutno is a pine script strategy for backtesting DCA bots with a different approach for placing both safety orders and take profit levels.
Motivation
Using DCA bots with safety orders most of the time is great during bull markets but in bear markets and strong downtrends it can be really challenging to close your deals only relying on safety orders placed based on percentages: price scale and volume scale.
In the past we introduced a script called "add funds simulator" that people used for sending alerts to bots to add funds and help closing deals in red.
We want to cross the use of TA with the safety orders with the intention of getting better results than statically placed safety orders.
What does Absolutno do?
Absolutno uses TA for safety orders, both for opening new safety orders and also to define how low they should be placed based on the volatility of the asset.
Main features
- ATR SO mode: Safety orders can be placed dynamically based on the general volatility of the asset plus the current volatility.
- TA based SO entries: Safety orders are only placed when the deal start condition is true not only when the price pulls back below the next safety order price level. This acts like a hybrid between "add funds simulator" and a traditional DCA bot. Once a safety order is filled, the next SO level gets active waiting for a DSC to trigger below the new entry level.
- Take profit scale: Traditional DCA bots offer a percentage or TA based exit conditions. Absolutno offers a new mode when you can decide to increase or decrease the TP level with each SO getting filled. For example a value of 1.1 TP scale will cause that each SO getting filled makes the TP% grow 10%. A value of 0.9% will reduce each SO by 10%. The lower the price goes you can "lower your expectation", or if you are filling bullish you can actually increase it.
External signal
It comes with a built-in deal start condition that uses RSI cross over 30 which is used only for illustration purposes since Absolutno is designed to be used with external signals.
Use any external signal to enter a new deal and for adding new safety orders.
You can also activate external take profit signal.
When external TP is enabled, all TP features from the bot are disabled to only react to what the external signal instructs the bot.
Bot integration and alerts
Three type of alerts will be sent to the bot: open deal, add funds and close deal.
You will need to enter your bot id and email token in the settings.
Since this strategy uses add funds: you must be aware that the alerts sent from this strategy will contain the amount of funds to add and therefore the bot receiving these alerts will respect them EVEN if the bot was defined with different SO sizes.
Please make sure you fully understand this before using this signal.
The base order alerts don't contain funds information so the bot will always use the base order size as defined in its own settings.
AlgoTrade DCA Bot Backtester█ OVERVIEW
This script can be used to backtest DCA Bots. It draws inspiration from 3Commas and has most settings that are available on 3Commas. It contains a few popular DCA Bot Presets that are well known in the community for you to test out! Preset used here: Kirigakure V4
█ FEATURES
DCA Preset (Custom, Standard TA,Urma Lite V3,Kirigakure V1,Kirigakure V3,Kirigakure V4)
Order Size Type (Fixed/% of equity to simulate compounding)
Base Order Size
Safety Order Size
Max Safety Trades Count
Price Deviation to open safety order %
Safety Order Volume Scale
Safety Order Step Scale
Take Profit %
Use ADR (Average Daily Range) as Take Profit
ADR length (if ADR as take profit is enabled)
Take Profit Type (% from total volume / % from base order)
Trailing Take Profit
Stop Loss
Deal Start Condition (Start ASAP) ▶ More Deal Starting Conditions will be added in the future
Bot Direction (Long / Short)
Start Time ▶ 1999-01-01 (Use this to always backtest the entire history)
End Time
This strategy also allows you to plot the Average Price and Take Profit of each trade, so it's easier to follow the trade and understand what's happening.
█ HOW TO USE
1. Select a DCA Preset and change the initial capital to the exact amount that is required (seen in the error message on top of the table). When using a Preset the following settings will be locked, meaning if you change them in the script's settings it won't have any effect:
Base Order Size
Safety Order Size
Max Safety Trades Count
Price Deviation to open safety order %
Safety Order Volume Scale
Safety Order Step Scale
Use ADR (Average Daily Range) as Take Profit
1.1 When using Presets you can choose the Order Size Type of Fixed or % of equity which simulates compounding
1.2 Choose a Direction and a Start and End Time
2. To backtest customized settings choose the preset "Custom"
2.1 All other settings are now "unlocked" and can be used
█ LIMITATIONS
Whenever a DCA preset is changed the initial_capital needs to be changed to the exact amount the settings require. If the initial_capital is not the same there will be an error of top of the table. To fix this error navigate to the Script's Settings and Properties and change the initial_capital to the same amount that is stated in the error.
DCA Bots with a high number of safety orders, e.g. 100, can run into an error that says "Maximum number of orders (9000) reached". If this error happens change the backtesting time to a shorter timeframe.
Using % of equity simulates compounding but is unrealistic because you cannot re-invest every single dollar
█ THANKS
This script in insipred by rouxam's "Backtesting 3commas DCA Bot v2" script
TTP Gavin's DCA BacktestPurpose:
The DCA Backtest script was designed to backtest the performance of any indicator using DCA bots.
"Open Deal ASAP" Deal Start Condition:
This script offers "open deal ASAP" deal start condition which will continuously open new deals. IT will wait for the current deal to close before opening a new one.
"Script" Deal Start Condition:
If you select the "Script" deal start condition we provide Bollinger Bands as an example. You can tweak the BB parameters from the indicator settings menu.
"Indicator" Deal Start Condition:
The third option is "Indicator". For this option to work you must have an indicator that plots a unique value that can be recognised as a BUY signal.
We recommend that your indicator plots 1 when it should buy and 0 when there's no signal.
Once you have in the same chart your indicator and your DCA backtest it's time to hook them up. For that follow these steps:
1) select "Indicator" as deal start condition
2) select your indicator from the list as "deal start source"
3) If you are following our recommendation then use 1 as "deal start value" so it can tell the DCA backtest when to open a deal. Make sure that your indicator only plots 0 or 1 so the DCA backtest can distinguish the BUY signal appropriately.
Limitations:
Each time you make changes and save your external indicator while you are backtesting, you will have to hook up the indicator again with the DCA backtest in the settings.
To avoid this, add as many parameters as you need to change in the external indicator so in that way you won't need to save changes to it and therefore will manage to avoid having to hook up the indicator with the DCA backtest.
ETF / Stocks / Crypto - DCA Strategy v1Simple "benchmark" strategy for ETFs, Stocks and Crypto! Super-easy to implement for beginners, a DCA (dollar-cost-averaging) strategy means that you buy a fixed amount of an ETF / Stock / Crypto every several months. For instance, to DCA the S&P 500 (SPY), you could purchase $10,000 USD every 12 months, irrespective of the market price. Assuming the macro-economic conditions of the underlying country remain favourable, DCA strategies will result in capital gains over a period of many years, e.g. 10 years. DCA is the safest strategy that beginners can employ to make money in the markets, and all other types of strategies should be "benchmarked" against DCA; if your strategy cannot outperform DCA, then your strategy is useless.
Recommended Chart Settings:
Asset Class: ETF / Stocks / Crypto
Time Frame: H1 (Hourly) / D1 (Daily) / W1 (Weekly) / M1 (Monthly)
Necessary ETF Macro Conditions:
1. Country must have healthy demographics, good ratio of young > old
2. Country population must be increasing
3. Country must be experiencing price-inflation
Necessary Stock Conditions:
1. Growing revenue
2. Growing net income
3. Consistent net margins
4. Higher gross/net profit margin compared to its peers in the industry
5. Growing share holders equity
6. Current ratios > 1
7. Debt to equity ratio (compare to peers)
8. Debt servicing ratio < 30%
9. Wide economic moat
10. Products and services used daily, and will stay relevant for at least 1 decade
Necessary Crypto Conditions:
1. Honest founders
2. Competent technical co-founders
3. Fair or non-existent pre-mine
4. Solid marketing and PR
5. Legitimate use-cases / adoption
Default Robot Settings:
Contribution (USD): $10,000
Frequency (Months): 12
*Robot buys $10,000 worth of ETF, Stock, Crypto, regardless of the market price, every 12 months since its founding time.*
*Equity curve can be seen from the bottom panel*
Risk Warning:
This strategy is low-risk, however it assumes you have a long time horizon of at least 5 to 10 years. The longer your holding-period, the better your returns. The only thing the user has to keep-in-mind are the macro-economic conditions as stated above. If unsure, please stick to ETFs rather than buying individual stocks or cryptocurrencies.