Linear EDCA v1.2 — Strategy by stephan8306

By stephan8306

Performance Metrics

Description

Nov 5, 2022Strategy 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 average2. 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 purposes3. 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 parameterSelling 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 parameterspecial 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 sellThe maximum ratio of a single buy position does not exceed defInvestRatio * maxBuyRateThe 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 positionbuySlope: the slope of the linear function of the order to buy, used to control the position ratio of a single buysellSlope: the slope of the linear function of the order to sell, used to control the position ratio of a single sellsellOffset: 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 earlymaxSellRate: Controls the maximum sell multiple. The maximum ratio of a single sell position does not exceed defInvestRatio * maxSellRatemaxBuyRate: Controls the maximum buy multiple. The maximum ratio of a single buy position does not exceed defInvestRatio * maxBuyRatemaPeriod: the length of the moving average, 1100-day MA is used by defaultsmoothing: moving average smoothing algorithm, SMA is used by defaultuseDateFilter: Whether to specify a date range when backtestingsettleOnEnd: If useDateFilter==true, whether to close the position after the end datestartDate: If useDateFilter==true, specify the backtest start dateendDate: If useDateFilter==true, specify the end date of the backtestinvestDayofweek: Invest on the day of the week, the default is to close on MondayintervalDays: 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 7The v1.2 version data window indicator description (only important indicators are listed):MA: 1100-day SMARoR%: floating profit and loss of the current positionmaxLoss%: 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 percentagepositionAvgPrice: position average holding cost--------------------------------策略说明:Linear EDCA(Linear Enhanced Dollar Cost Averaging)是一个DCA定投策略的增强版本,它具有如下特性:1. 以1100日SMA均线作为参考指标,在均线以下进入定买区间,在均线以上进入定卖区间2. 定买和定卖以不同的“速率”进行,它们用两条线性函数设定,并且你可以通过改变线性函数的斜率,以达到不同的买卖仓位控制的目的3. 本定投作为低频策略,只在日级别周期工作----------------策略回测表现:BTCUSD(2014年09月~2022年09月):净利润率26378%,最大浮亏47.12%(2015-01-14)ETHUSD(2018年08~2022年09月):净利润率1669%,最大浮亏49.63%(2018-12-14)----------------策略工作原理:买入条件:当日收盘价在 1100 SMA 之下,由收盘价和均线的偏离度,以及buySlope参数决定买入仓位比例卖出条件:当日收盘价在 1100 SMA之上,由收盘价和均线的偏离度,以及sellSlope参数决定卖出仓位比例特例:当sellOffset参数>0,则在 1100 SMA以上一定范围内还会保持小幅买入,避免过早开始卖出单次买入仓位比例最大不超过 defInvestRatio * maxBuyRate单次卖出仓位比例最大不超过 defInvestRatio * maxSellRate----------------版本信息:当前版本v1.2(第一个正式发布的版本)v1.2版本设置参数说明:defInvestRatio: 默认定投比例,策略会根据此比例和线性函数计算得出单次定投的仓位比例。默认0.025代表2.5%仓位buySlope: 定买的线性函数斜率,用来控制单次买入的仓位倍率sellSlope: 定卖的线性函数斜率,用来控制单次卖出的仓位倍率sellOffset: 定卖的偏移度,如果大于0,则在一定范围内还会保持小幅买入,避免过早开始卖出maxSellRate: 控制最大卖出倍率。单次卖出仓位比例最大不超过 defInvestRatio * maxSellRatemaxBuyRate: 控制最大买入倍率。单次买入仓位比例最大不超过 defInvestRatio * maxBuyRatemaPeriod: 均线长度,默认使用1100日MAsmoothing: 均线平滑算法,默认使用SMAuseDateFilter: 回测时是否要指定日期范围settleOnEnd: 如果useDateFilter==true,在结束日之后是否平仓所持有的仓位平仓startDate: 如果useDateFilter==true,指定回测开始日期endDate: 如果useDateFilter==true,指定回测结束日期investDayofweek: 每次在周几定投,默认在每周一收盘intervalDays: 每次定投之间的最小间隔天数,由于是按周计算,所以此数字必须是7或7的倍数v1.2版本数据窗口指标说明(只列出重要指标):MA:1100日SMARoR%: 当前仓位的浮动盈亏maxLoss%: 仓位曾经的最大浮动亏损,注意此浮亏代表持仓仓位的浮亏情况,并不代表整体账户浮亏情况。例如当前仓位是1%,浮亏50%,整体账户浮亏是0.5%,但仓位浮亏是50%maxGain%: 仓位曾经的最大浮动盈利,注意此浮盈代表持仓仓位的浮盈情况,并不代表整体账户浮盈情况。positionPercent%: 仓位持仓占比positionAvgPrice: 仓位平均持仓成本Nov 7, 2022Release NotesAdd parameters:minPositionSize: Controls the minimum number of positions for a single transaction, if it is less than this number, skip this investmentNov 10, 2022Release Notes-------- version 1.2.2 changelog:add orderQty and closeOrderQty to data window for debugNov 12, 2022Release Notes-------- version 1.2.3 changelog:add max drawdown histogram to all window

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView