This strategy identifies bitcoin market trends by calculating the True Strength Index (TSI) and enters long/short positions filtered by RSI indicator to implement algorithmic trading of bitcoin. It suits investors who want to trade bitcoin tick data programmatically.
The core of this strategy is the True Strength Index (TSI). TSI measures the absolute magnitude and direction of price changes by double smoothing the percentage price change, thereby identifying the absolute strength of price up and down moves. The specific calculation is as follows:
When TSI crosses over its signal line tsi2, a long signal is generated. When TSI crosses below tsi2, a short signal is generated. In addition, the strategy filters TSI signals with RSI - only taking long signals when RSI is above 50 and short signals when RSI is below 50, to avoid some false signals.
The advantages of this strategy include:
The risks of this strategy include:
The lagging issue and filter effect can be reduced by relaxing RSI filter rules and shortening EMA periods. Proper stop loss strategy should be used to strictly control per trade risks.
The strategy can be optimized in the following aspects:
Optimize TSI and RSI parameters to find the best combination. Tuning long/short EMA periods, RSI parameters etc.
Introduce more technical indicators to build a multifactor model. MA, KD etc can be added to take advantage of each indicator.
Optimize entry rules to avoid long in downtrend and short in uptrend. Judge direction based on higher timeframe trends.
Optimize stop loss strategies like trailing stop loss, time-based stop loss, breakout stop loss etc.
Optimize exit rules to avoid premature or late exits. Volatility indicators can help determine proper exit points.
Optimize trading products, trading sessions to focus on the most effective ones.
This strategy identifies bitcoin short-term trends with True Strength Index and filters signals with RSI for algorithmic bitcoin trading. It has the advantage of sensitively capturing trends and filtering noise, but also has some lagging issues and trading risks. Multi-faceted optimizations can further improve strategy performance to develop a reliable bitcoin trading expert advisor.
/*backtest start: 2022-09-30 00:00:00 end: 2023-10-06 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // strategy("True Strength Indicator BTCUSD 15p", shorttitle="TSI BTCUSD 15p",initial_capital=1000, commission_value=0.15, commission_type =strategy.commission.percent, default_qty_value=100 , overlay = false, pyramiding=10, default_qty_type=strategy.percent_of_equity) //BASED ON True Strength Indicator MTF resCustom = input(title="Timeframe", defval="15" ) long = input(title="Long Length", defval=25) short = input(title="Short Length", defval=13) signal = input(title="Signal Length", defval=13) price = request.security(syminfo.tickerid,resCustom,close) double_smooth(src, long, short) => fist_smooth = ta.ema(src, long) ta.ema(fist_smooth, short) pc = ta.change(price) double_smoothed_pc = double_smooth(pc, long, short) double_smoothed_abs_pc = double_smooth(math.abs(pc), long, short) tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc) tsi2=ta.ema(tsi_value, signal) plot(tsi_value, color=color.lime,linewidth=2) plot(tsi2, color=color.red,linewidth=2) rsiserie = ta.rsi(price,7) cciserie = ta.cci(price,14) stochserie = ta.stoch(price,14,3,3) plot(rsiserie,color=color.purple) hline(30, title="Zero") hline(50, title="Zero",linestyle=hline.style_solid, linewidth=2) hline(70, title="Zero") buy = ta.crossover(tsi_value, tsi2) //and rsiserie[1]<25 //and cciserie<-100 and stochserie<20 sell = ta.crossunder(tsi_value, tsi2) //and rsiserie[1]>85 //and cciserie>100 and stochserie>80 alertcondition(buy, title='TSI system', message='Buy signal at!' ) alertcondition(sell, title='TSI system', message='Sell signal at!' ) strategy.entry("BUY", strategy.long, 1, when = buy) strategy.entry("SELL", strategy.short, 1, when = sell ) greentsi =tsi_value redtsi = tsi2 bgcolor( greentsi>redtsi and rsiserie > 50 ? color.lime : na, transp=90) bgcolor( greentsi<redtsi and rsiserie < 50 ? color.red : na, transp=90) yellow1= redtsi > greentsi and rsiserie > 50 yellow2 = redtsi < greentsi and rsiserie < 50 bgcolor( yellow1 ? yellow : na, transp=80) bgcolor( yellow2 ? yellow : na, transp=50) bgcolor( yellow1 and yellow1[1] ? yellow : na, transp=70) bgcolor( yellow2 and yellow2[2] ? yellow : na, transp=70) bgcolor( rsiserie > 70 ? color.lime : na, transp=60) bgcolor( rsiserie < 30 ? color.red : na, transp=60)