This is a long-term cryptocurrency trend following strategy that combines moving average, relative strength index (RSI) and market correlation to identify mid-to-long term price trends, establish positions when trends start, pyramiding along the trends, and take profit when trend reversal signals are spotted.
The strategy is mainly based on three indicators:
Relative Strength Index (RSI): To identify overbought and oversold conditions. Above 51 is considered overbought and below 49 oversold.
Simple Moving Average (SMA): 9-day SMA of close price to determine trend direction.
Market Correlation: Use total cryptocap as benchmark to calculate correlation with trading instrument, replacing original bars with correlation bars to improve signal quality.
Specifically, the trading rules are:
Long entry: When RSI crosses above 51 and close price is above 9-day SMA.
Short entry: When RSI crosses below 49 and close price is below 9-day SMA.
Take profit/Stop loss: 1%/0.1% for longs, 0.05%/0.03% for shorts.
There is also a time condition limiting the trading period.
Combining trend and overbought/oversold indicators effectively tracks mid-to-long term trends.
Market correlation improves signal quality, avoiding false trends.
Reasonable profit taking and stop loss prevents enlarged losses.
Customizable trading period adapts to different market conditions.
Ineffective in whipsaw or short-term volatile markets.
Benchmark reversal may cause lagging exits in trading instruments.
Potentially misses reversal opportunities when only doing longs/shorts.
Solutions:
Add short-term indicators e.g. KC, BOLL for market regime detection and stops.
Enhance benchmark analysis for timely exits.
Trade double-sided instruments to capture reversals.
Parameter tuning on RSI, SMA, profit taking/stop loss based on market statistics.
Evaluate more benchmark/trading combinations with higher correlation and liquidity.
Combine with other strategies, using this one for mid-to-long term holdings.
This is an optimized and widely-adaptable mid-to-long term cryptocurrency trend following strategy. It effectively combines trend, momentum and correlation analysis to improve trade decisions. Proper parameter tuning and composite usage can greatly enhance its stability and profitability. The long holding periods also suit the high-volatile and hard-to-precisely-capture nature of crypto markets.
/*backtest start: 2022-12-04 00:00:00 end: 2023-12-10 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © exlux99 //@version=4 strategy(title = "Crypto swing correlation", overlay = true, pyramiding=1,initial_capital = 1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.03) //time fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31) fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12) fromYear = input(defval = 2010, title = "From Year", minval = 1970) //monday and session // To Date Inputs toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31) toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12) toYear = input(defval = 2021, title = "To Year", minval = 1970) startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00) finishDate = timestamp(toYear, toMonth, toDay, 00, 00) time_cond = true useCorrelation = input(true, title="Use Correlation candles?") symbol = input("BTC_USDT:swap", type=input.symbol) haClose = useCorrelation ? security(symbol, timeframe.period, close) : close haOpen = useCorrelation ? security(symbol, timeframe.period, open) : open haHigh = useCorrelation ? security(symbol, timeframe.period, high) : high haLow = useCorrelation ? security(symbol, timeframe.period, low) : low length = input( 50 ) overSold = input( 51 ) overBought = input( 49 ) s = input(title="Source", defval="haClose", options=["haClose", "haOpen", "haHigh", "haLow"]) price = s == "haClose" ? haClose: s == "haOpen" ? haOpen : s == "haHigh" ? haHigh : s == "haLow" ? haLow : na len = input(8, "Length Moving average", minval=1) src = price ma = sma(src, len) vrsi = rsi(price, length) long = crossover(vrsi, overSold) and time_cond and price > ma short = crossunder(vrsi, overBought) and time_cond and price < ma takeProfit_long=input(1.0, step=0.005) stopLoss_long=input(0.1, step=0.005) takeProfit_short=input(0.05, step=0.005) stopLoss_short=input(0.03, step=0.005) strategy.entry("long",1,when=long) strategy.entry("short",0,when=short) strategy.exit("short_tp/sl", "long", profit=close * takeProfit_long / syminfo.mintick, loss=close * stopLoss_long / syminfo.mintick, comment='LONG EXIT', alert_message = 'closeshort') strategy.exit("short_tp/sl", "short", profit=close * takeProfit_short / syminfo.mintick, loss=close * stopLoss_short / syminfo.mintick, comment='SHORT EXIT', alert_message = 'closeshort')