INVITE-ONLY SCRIPT

Smart DCA Strategy

INSPIRATION

While Dollar Cost Averaging (DCA) is a popular and stress-free investment approach, I noticed an opportunity for enhancement. Standard DCA involves buying consistently, regardless of market conditions, which can sometimes mean missing out on optimal investment opportunities. This led me to develop the Smart DCA Strategy – a 'set and forget' method like traditional DCA, but with an intelligent twist to boost its effectiveness.

The goal was to build something more profitable than a standard DCA strategy so it was equally important that this indicator could backtest its own results in an A/B test manner against the regular DCA strategy.

WHY IS IT SMART?

The key to this strategy is its dynamic approach: buying aggressively when the market shows signs of being oversold, and sitting on the sidelines when it's not. This approach aims to optimize entry points, enhancing the potential for better returns while maintaining the simplicity and low stress of DCA.

WHAT THIS STRATEGY IS, AND IS NOT

This is an investment style strategy. It is designed to improve upon the common standard DCA investment strategy. It is therefore NOT a day trading strategy. Feel free to experiment with various timeframes, but it was designed to be used on a daily timeframe and that's how I recommend it to be used.

You may also go months without any buy signals during bull markets, but remember that is exactly the point of the strategy - to keep your buying power on the sidelines until the markets have significantly pulled back. You need to be patient and trust in the historical backtesting you have performed.

HOW IT WORKS

The Smart DCA Strategy leverages a creative approach to using Moving Averages to identify the most opportune moments to buy. A trigger occurs when a daily candle, in its entirety including the high wick, closes below the threshold line or box plotted on the chart. The indicator is designed to facilitate both backtesting and live trading.

HOW TO USE

Settings:

The input parameters for tuning have been intentionally simplified in an effort to prevent users falling into the overfitting trap.

The main control is the Buying strictness scale setting. Setting this to a lower value will provide more buying days (less strict) while higher values mean less buying days (more strict). In my testing I've found level 9 to provide good all round results.

Validation days is a setting to prevent triggering entries until the asset has spent a given number of days (candles) in the overbought state. Increasing this makes entries stricter. I've found 0 to give the best results across most assets.

In the backtest settings you can also configure how much to buy for each day an entry triggers. Blind buy size is the amount you would buy every day in a standard DCA strategy. Smart buy size is the amount you would buy each day a Smart DCA entry is triggered.

You can also experiment with backtesting your strategy over different historical datasets by using the Start date and End date settings. The results table will not calculate for any trades outside what you've set in the date range settings.

Backtesting:

When backtesting you should use the results table on the top right to tune and optimise the results of your strategy. As with all backtests, be careful to avoid overfitting the parameters. It's better to have a setup which works well across many currencies and historical periods than a setup which is excellent on one dataset but bad on most others. This gives a much higher probability that it will be effective when you move to live trading.

The results table provides a clear visual representation as to which strategy, standard or smart, is more profitable for the given dataset. You will notice the columns are dynamically coloured red and green. Their colour changes based on which strategy is more profitable in the A/B style backtest - green wins, red loses. The key metrics to focus on are GOA (Gain on Account) and Avg Cost.

Live Trading:

After you've finished backtesting you can proceed with configuring your alerts for live trading.

But first, you need to estimate the amount you should buy on each Smart DCA entry. We can use the Total invested row in the results table to calculate this. Assuming we're looking to trade on BTCUSD
  1. Decide how much USD you would spend each day to buy BTC if you were using a standard DCA strategy. Lets say that is $5 per day
  2. Enter that USD amount in the Blind buy size settings box
  3. Check the Blind Buy column in the results table. If we set the backtest date range to the last 10 years, we would expect the amount spent on blind buys over 10 years to be $18,250 given $5 each day
  4. Next we need to tweak the value of the Smart buy size parameter in setting to get it as close as we can to the Total Invested amount for Blind Buy


By following this approach it means we will invest roughly the same amount into our Smart DCA strategy as we would have into a standard DCA strategy over any given time period.

After you have calculated the Smart buy size, you can go ahead and set up alerts on Smart DCA buy triggers.

BOT AUTOMATION

In an effort to maintain the 'set and forget' stress-free benefits of a standard DCA strategy, I have set my personal Smart DCA Strategy up to be automated. The bot runs on AWS and I have a fully functional project for the bot on my GitHub account. Just reach out if you would like me to point you towards it. You can also hook this into any other 3rd party trade automation system of your choice using the pre-configured alerts within the indicator.

PLANNED FUTURE DEVELOPMENTS

Currently this is purely an accumulation strategy. It does not have any sell signals right now but I have ideas on how I will build upon it to incorporate an algorithm for selling. The strategy should gradually offload profits in bull markets which generates more USD which gives more buying power to rinse and repeat the same process in the next cycle only with a bigger starting capital. Watch this space!

MARKETS

Crypto:
This strategy has been specifically built to work on the crypto markets. It has been developed, backtested and tuned against crypto markets and I personally only run it on crypto markets to accumulate more of the coins I believe in for the long term. In the section below I will provide some backtest results from some of the top crypto assets.

Stocks:
I've found it is generally more profitable than a standard DCA strategy on the majority of stocks, however the results proved to be a lot more impressive on crypto. This is mainly due to the volatility and cycles found in crypto markets. The strategy makes its profits from capitalising on pullbacks in price. Good stocks on the other hand tend to move up and to the right with less significant pullbacks, therefore giving this strategy less opportunity to flourish.

Forex:
As this is an accumulation style investment strategy, I do not recommend that you use it to trade Forex.

STRATEGY IN ACTION

Here you see the indicator running on the BTCUSD pair. You can read the indicator as follows:
  • Vertical green bands on historical candles represents where buy signals triggered in the past
  • Table on the top right represents the results of the A/B backtest against a standard DCA strategy
  • Green Smart Buy column shows that Smart DCA was more profitable than standard DCA on this backtest. That is shown by the percentage GOA (Gain on Account) and the Avg Cost
  • Smart Buy Zone label marks the threshold which the entire candle must be below to trigger a buy signal (line can be changed to a box under plotting settings)
  • Green color of Smart Buy Zone label represents that the open candle is still valid for a buy signal. A signal will only be generated if the candle closes while this label is still green

ảnh chụp nhanh

Below is the same BTCUSD chart a couple of days later. Notice how the threshold has been broken and the Smart Buy Zone label has turned from green to red. No buy signal can be triggered for this day - even if the candle retraced and closed below the threshold before daily candle close.
ảnh chụp nhanh

Notice how the green vertical bands tend to be present after significant pullbacks in price. This is the reason the strategy works! Below is the same BTCUSD chart, but this time zoomed out to present a clearer picture of the times it would invest vs times it would sit out of the market. You will notice it invests heavily in bear markets and significant pullbacks, and does not buy anything during bull markets.
ảnh chụp nhanh

Finally, to visually demonstrate the indicator on an asset other than BTC, here is an example on ETHUSD. In this case the current daily high has not touched the threshold so it is still possible for this to be a valid buy trigger on daily candle close. The vertical green band will not print until the buy trigger is confirmed.
ảnh chụp nhanh

BACKTEST RESULTS

Now for some backtest results to demonstrate the improved performance over a standard DCA strategy using all non-stablecoin assets in the top 30 cryptos by marketcap.

I've used the TradingView ticker (exchange name denoted as CRYPTO in the symbol search) for every symbol tested with the exception of BTCUSD because there was some dodgy data at the beginning of the TradingView BTCUSD chart which overinflated the effectiveness of the Smart DCA strategy on that ticker. For BTCUSD I've used the BITSTAMP exchange data. The symbol links below will take you to the correct chart and exchange used for the test.

I'm using the GOA (Gain on Account) values to present how each strategy performed.

The value on the left side is the standard DCA result and the right is the Smart DCA result.

✅ means Smart DCA strategy outperformed the standard DCA strategy
❌ means standard DCA strategy outperformed the Smart DCA strategy

To avoid overfitting, and to prove that this strategy does not suffer from overfitting, I've used the exact same input parameters for every symbol tested below. The settings used in these backtests are:

  • Buying strictness scale: 9
  • Validation days: 0


You can absolutely tweak the values per symbol to further improve the results of each, however I think using identical settings on every pair tested demonstrates a higher likelihood that the results will be similar in the live markets.

I'm presenting results for two time periods:
  1. First price data available for trading pair -> closing candle on Friday 26th Jan 2024 (ALL TIME)
  2. Opening candle on Sunday 1st Jan 2023 -> closing candle on Friday 26th Jan 2024 (JAN 2023 -> JAN 2024)


ALL TIME:

BTCUSD 80,884% / 133,582% ✅
ETHUSD 17,231% / 36,146% ✅
BNBUSD 5,314% / 2,702% ❌
SOLUSD 1,745% / 1,171% ❌
XRPUSD 2,585% / 4,544% ✅
ADAUSD 338% / 353% ✅
AVAXUSD 130% / 160% ✅
DOGEUSD 13,690% / 16,432% ✅
TRXUSD 414% / 466% ✅
DOTUSD -16% / -7% ✅
LINKUSD 1,161% / 2,164% ✅
TONUSD 25% / 47% ✅
MATICUSD 1,769% / 1,587% ❌
ICPUSD 70% / 50% ❌
SHIBUSD -20% / -19% ✅
LTCUSD 486% / 718% ✅
BCHUSD -4% / 3% ✅
LEOUSD 102% / 151% ✅
ATOMUSD 46% / 91% ✅
UNIUSD -16% / 1% ✅
ETCUSD 283% / 414% ✅
OKBUSD 1,286% / 1,935% ✅
XLMUSD 1,471% / 1,592% ✅
INJUSD 830% / 1,035% ✅
OPUSD 138% / 195% ✅
NEARUSD 23% / 44% ✅

Backtest result analysis:

Assuming we have an initial investment amount of $10,000 spread evenly across each asset since the creation of each asset, it would have provided the following results.

Standard DCA Strategy results:
  • Average percent return: 4,998.65%
  • Profit: $499,865
  • Closing balance: $509,865


Smart DCA Strategy results:
  • Average percent return: 7,906.03%
  • Profit: $790,603
  • Closing balance: $800,603


JAN 2023 -> JAN 2024:

BTCUSD 47% / 66% ✅
ETHUSD 26% / 33% ✅
BNBUSD 15% / 17% ✅
SOLUSD 272% / 394% ✅
XRPUSD 7% / 12% ✅
ADAUSD 43% / 59% ✅
AVAXUSD 116% / 151% ✅
DOGEUSD 8% / 14% ✅
TRXUSD 48% / 65% ✅
DOTUSD 24% / 35% ✅
LINKUSD 83% / 124% ✅
TONUSD 7% / 21% ✅
MATICUSD -3% / 7% ✅
ICPUSD 161% / 196% ✅
SHIBUSD 1% / 8% ✅
LTCUSD -15% / -7% ✅
BCHUSD 47% / 68% ✅
LEOUSD 9% / 11% ✅
ATOMUSD 1% / 15% ✅
UNIUSD 9% / 23% ✅
ETCUSD 27% / 40% ✅
OKBUSD 21% / 30% ✅
XLMUSD 11% / 19% ✅
INJUSD 477% / 446% ❌
OPUSD 77% / 91% ✅
NEARUSD 78% / 95% ✅

Backtest result analysis:

Assuming we have an initial investment amount of $10,000 spread evenly across each asset for the duration of 2023, it would have provided the following results.

Standard DCA Strategy results:
  • Average percent return: 61.42%
  • Profit: $6,142
  • Closing balance: $16,142


Smart DCA Strategy results:
  • Average percent return: 78.19%
  • Profit: $7,819
  • Closing balance: $17,819
accumilationalertsignalsbacktestingBitcoin (Cryptocurrency)cryptomarketDCAdollarcostaverageExponential Moving Average (EMA)etheriuminvesting

Tập lệnh chỉ hiển thị cho người được mời

Quyền truy cập vào tập lệnh này bị hạn chế đối với người dùng được tác giả ủy quyền và thường yêu cầu thanh toán. Bạn có thể thêm nó vào mục yêu thích của mình, nhưng bạn sẽ chỉ có thể sử dụng nó sau khi yêu cầu sự cho phép từ tác giả. Liên hệ kevinmck100 để thêm thông tin, hoặc làm theo hướng dẫn của tác giả bên dưới.

TradingView gợi ý bạn không trả tiền để sử dụng tập lệnh trừ khi bạn tin tưởng 100% vào tác giả của tập lệnh và hiểu cách hoạt động của tập lệnh. Trong nhiều trường hợp, bạn có thể tìm thấy giải pháp thay thế nguồn mở tốt miễn phí trong Tập lệnh cộng đồng của chúng tôi.

Hướng dẫn của tác giả

Please DM me if you would like to be granted access for a 7 day free trial. After the trial, subscribers to the "Intelligent Investors" membership will be granted full access: https://www.buymeacoffee.com/alphatechtrades/membership

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Cảnh báo: vui lòng đọc trước khi yêu cầu quyền truy cập.

Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm