This strategy combines moving average, amplitude index and parabolic SAR indicator to judge the trend and confirm breakthrough points. It belongs to a typical trend following strategy. It will establish long position to track the trend when identifying an uptrend and price breakthrough. It will close position for stop loss when judging trend reversal.
The strategy uses double EMA to judge price trend and uses SMA as assistance. When fast EMA is above slow EMA and fast SMA is above slow SMA, it considers there is an uptrend.
It uses parabolic SAR indicator to judge price reversal points. When PSAR goes below the highest price, it means price may reverse downwards. At this time it will close position for stop loss.
When judging an uptrend and PSAR goes above highest price, it means price keeps going up. At this time it will long to track the trend.
Solutions:
The strategy belongs to a typical trend following strategy. The advantages are clear and simple rules and ability to identify trend reversal for timely position opening. The disadvantages are sensitivity to parameters and certain chasing risk. Overall it is worth further optimization and adjustment for live trading verification. The main optimization directions are parameter optimization, adding stop loss strategy etc.
/*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)