Strategy Description: Linear EDCA (Linear Enhanced Dollar Cost Averaging) is an enhanced version of the DCA fixed investment strategy. It has the following features: 1. Take the 1100-day SMA as a reference indicator, enter the buy range below the moving average, and enter the sell range above the moving average 2. The order to buy and sell is carried out at different "speed", which are set with two linear functions, and you can change the slope of the linear function to achieve different trading position control purposes 3. This fixed investment is a low-frequency strategy and only works on a daily level cycle
---------------- Strategy backtest performance: BTCUSD (September 2014~September 2022): Net profit margin 26378%, maximum floating loss 47.12% (2015-01-14) ETHUSD (August 2018~September 2022): Net profit margin 1669%, maximum floating loss 49.63% (2018-12-14)
---------------- How the strategy works: Buying Conditions: The closing price of the day is below the 1100 SMA, and the ratio of buying positions is determined by the deviation of the closing price from the moving average and the buySlope parameter
Selling Conditions: The closing price of the day is above the 1100 SMA, and the ratio of the selling position is determined by the deviation of the closing price and the moving average and the sellSlope parameter
special case: When the sellOffset parameter>0, it will maintain a small buy within a certain range above the 1100 SMA to avoid prematurely starting to sell The maximum ratio of a single buy position does not exceed defInvestRatio * maxBuyRate The maximum ratio of a single sell position does not exceed defInvestRatio * maxSellRate
---------------- Version Information: Current version v1.2 (the first officially released version)
v1.2 version setting parameter description: defInvestRatio: The default fixed investment ratio, the strategy will calculate the position ratio of a single fixed investment based on this ratio and a linear function. The default 0.025 represents 2.5% of the position buySlope: the slope of the linear function of the order to buy, used to control the position ratio of a single buy sellSlope: the slope of the linear function of the order to sell, used to control the position ratio of a single sell sellOffset: The offset of the order to sell. If it is greater than 0, it will keep a small buy within a certain range to avoid starting to sell too early
maxSellRate: Controls the maximum sell multiple. The maximum ratio of a single sell position does not exceed defInvestRatio * maxSellRate maxBuyRate: Controls the maximum buy multiple. The maximum ratio of a single buy position does not exceed defInvestRatio * maxBuyRate
maPeriod: the length of the moving average, 1100-day MA is used by default smoothing: moving average smoothing algorithm, SMA is used by default
useDateFilter: Whether to specify a date range when backtesting settleOnEnd: If useDateFilter==true, whether to close the position after the end date startDate: If useDateFilter==true, specify the backtest start date endDate: If useDateFilter==true, specify the end date of the backtest investDayofweek: Invest on the day of the week, the default is to close on Monday intervalDays: The minimum number of days between each invest. Since it is calculated on a weekly basis, this number must be 7 or a multiple of 7
The v1.2 version data window indicator description (only important indicators are listed): MA: 1100-day SMA RoR%: floating profit and loss of the current position maxLoss%: The maximum floating loss of the position. Note that this floating loss represents the floating loss of the position, and does not represent the floating loss of the overall account. For example, the current position is 1%, the floating loss is 50%, the overall account floating loss is 0.5%, but the position floating loss is 50% maxGain%: The maximum floating profit of the position. Note that this floating profit represents the floating profit of the position, and does not represent the floating profit of the overall account. positionPercent%: position percentage positionAvgPrice: position average holding cost
--------------------------------
策略说明: Linear EDCA(Linear Enhanced Dollar Cost Averaging)是一个DCA定投策略的增强版本,它具有如下特性: 1. 以1100日SMA均线作为参考指标,在均线以下进入定买区间,在均线以上进入定卖区间 2. 定买和定卖以不同的“速率”进行,它们用两条线性函数设定,并且你可以通过改变线性函数的斜率,以达到不同的买卖仓位控制的目的 3. 本定投作为低频策略,只在日级别周期工作
Add parameters: minPositionSize: Controls the minimum number of positions for a single transaction, if it is less than this number, skip this investment
Release Notes
-------- version 1.2.2 changelog: add orderQty and closeOrderQty to data window for debug
Release Notes
-------- version 1.2.3 changelog: add max drawdown histogram to all window
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
Want to use this script on a chart?
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.