This strategy calculates the rate of change over time to determine buy/sell signals. It can help traders capture opportunities in short-term price fluctuations.
The strategy is mainly based on the following indicators:
Specific entry rules:
Specific exit rules:
Position size is percentage (default 96%) of total equity for leverage.
The strategy has the following advantages:
Using ROC to detect swings allows capturing upside/downside moves for higher returns.
Combining fast/slow SMA helps more accurately identify low/high points.
Reference SMA provides overall direction to avoid distraction from short-term noise.
Trailing stop loss locks in profits and reduces downside risk.
Leverage from position sizing amplifies profits.
Overall, the strategy utilizes ROC, SMA and other tools effectively to capitalize on price oscillations. It can achieve good results in volatile markets.
The strategy also has the following risks:
Incorrect ROC and SMA parameters may cause missed signals or bad trades. Optimization is needed for different markets.
Excessive position size increases risk. Order percentage should be tested and tuned.
Trailing stop loss may exit prematurely in choppy markets. Stop loss percentage can be adjusted.
Prone to whipsaws in ranging markets. Should incorporate trend filters and risk management.
Backtest overfitting risk. Robustness should be verified through live trading across markets.
Risks can be managed through parameter optimization, position sizing, stop loss adjustments, robustness testing etc.
The strategy can be improved in the following aspects:
Add other technical indicators like volatility, volume to improve signal accuracy.
Optimize number of trades by reducing trading frequency to minimize whipsaw impacts.
Incorporate breakout techniques around key price levels.
Use machine learning to auto optimize parameters.
Test robustness across different markets and time frames.
Tune specialized parameters for different products like stocks, forex etc.
Continuously refine signals and risk controls based on live results.
This strategy identifies trading opportunities around short-term oscillations using ROC and SMA analysis. It helps capitalize on quick swings but also requires proper risk controls. Fine tuning parameters, position sizing, stop losses and robustness testing can enhance its stability and adaptability. The strategy serves as a reference template for quantified trading but needs customization for different markets.
/*backtest start: 2022-09-21 00:00:00 end: 2023-09-27 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // @version=4 // Author: Sonny Parlin (highschool dropout) // Best if run on 5m timeframe strategy(shorttitle="ROC+Strategy", title="Rate of Change Strategy", overlay=true, currency=currency.USD, initial_capital=10000) // Inputs and variables ss = input(14, minval=10, maxval=50, title="SMA Fast (days)") ff = input(100, minval=55, maxval=200, title="SMA Slow (days)") ref = input(30, minval=20, maxval=50, title="SMA Reference (days)") lowOffset = input(0.023, "ROC Low (%)", minval=0, step=0.01) highOffset = input(0.047, "ROC High (%)", minval=0, step=0.01) orderStake = input(0.96, "Order Stake (%)", minval=0, step=0.01) lookback = input(12, "Lookback Candles", minval=1, step=1) // SMA smaFast = sma(close, ss) smaSlow = sma(close, ff) smaRef = sma(close, ref) ROC = (max(close[lookback],close) - min(close[lookback],close)) / max(close[lookback],close) // Set up SMA plot but don't show by default plot(smaFast, "smaFast", color=#00ff00, display = 0) plot(smaSlow, "smaSlow", color=#ff0000, display = 0) plot(smaRef, "smaRef", color=#ffffff, display = 0) // The buy stratey: // Guard that the low is under our SMA Reference line // Guard that the rate of change over the lookback period is greater than our // ROC lowOffset %, default is 0.023. (low < smaRef) and (ROC > lowOffset) // SMA fast is on the rise and SMA slow is falling and they are very likely // to cross. (rising(smaFast,1)) and (falling(smaSlow, 1)) enterLong = (low < smaRef) and (ROC > lowOffset) and (rising(smaFast,1)) and (falling(smaSlow,1)) // The sell Strategy: // Guard that close is higher than our SMA reference line and that the rate of // change over the lookback period is greater than our highOffset %, default // is 0.047. (close > smaRef) and (ROC > highOffset) // Guard that close has risen by 3 candles in a row (rising(close,3)) // Guard that we currently have profit (strategy.openprofit > 0) // Guard that SMA fast is higher than smaSlow (smaFast > smaSlow) // If it keeps going up past our close position the trailing stoploss will kick in! enterShort = (close > smaRef) and (ROC > highOffset) and (rising(close,3)) and (strategy.openprofit > 0) and (smaFast > smaSlow) // Order size is based on total equity // Example 1: // startingEquity = 2000 // close = 47434.93 // orderStake = 0.45 // (2,000 × orderStake) / close = orderSize = 0.0189733599 = approx $900 // Example 2: // startingEquity = 2000 // close = 1.272 // orderStake = 0.45 // (startingEquity × orderStake) / close = orderSize = 707.5471698113 = approx $900 orderSize = (strategy.equity * orderStake) / close // Trailing Stoploss // I'm using 2.62 as my default value, play with this for different results. longTrailPerc = input(title="Trailing Stoploss (%)", type=input.float, minval=0.0, step=0.1, defval=3.62) * 0.01 longStopPrice = 0.0 longStopPrice := if (strategy.position_size > 0) stopValue = close * (1 - longTrailPerc) max(stopValue, longStopPrice[1]) else 0 if (enterLong) strategy.entry("Open Long Position", strategy.long, orderSize, when=strategy.position_size <= 0) if (enterShort) strategy.exit(id="Close Long Position", stop=longStopPrice) //plot(strategy.equity)