该策略结合了移动平均线,幅度指标和抛物线转向指标,实现了对趋势的判断和突破点的确认,属于典型的趋势追踪策略。当判断到处于上升趋势且价格突破最高点时会建立做多头寸,实现趋势追踪;当判断趋势反转时会平仓止损。
该策略使用双EMA判断价格趋势,使用SMA辅助判断。当快线EMA在慢线EMA之上,并且快线SMA在慢线SMA之上时,认为处于上升趋势。
使用抛物线转向指标PSAR判断价格反转点。当PSAR下穿价格最高点时,说明价格可能反转下跌,此时平仓止损。
当判断为上升趋势且PSAR上穿价格最高点时,说明价格继续上涨,此时做多追踪趋势。
解决方法:
该策略整体来说属于较为典型的趋势追踪策略。优点是规则较为清晰简单,能够识别趋势转折;缺点是对参数比较敏感,存在一定的 chasing risk。总体来说值得进一步优化和调整后实盘验证,主要优化方向在于参数优化、止损策略加入等。
/*backtest
start: 2023-11-27 00:00:00
end: 2023-12-27 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("Buy Dip MA & PSAR", overlay=true)
PSAR_start = input(0.02)
PSAR_increment = input(0.02)
PSAR_maximum = input(0.2)
EMA_fast = input(20)
EMA_slow = input(40)
SMA_fast = input(100)
SMA_slow = input(200)
emafast = ema(close, EMA_fast)
emaslow = ema(close, EMA_slow)
smafast = sma(close, SMA_fast)
smaslow = sma(close, SMA_slow)
psar = sar(PSAR_start, PSAR_increment, PSAR_maximum)
uptrend = emafast > emaslow and smafast > smaslow
breakdown = not uptrend
if (psar >= high and uptrend)
strategy.entry("Buy", strategy.long, stop=psar, comment="Buy")
else
strategy.cancel("Buy")
if (psar <= low)
strategy.exit("Close", "Buy", stop=psar, comment="Close")
else
strategy.cancel("Close")
if (breakdown)
strategy.close("Buy")
plot(emafast, color=blue)
plot(emaslow, color=red)