This strategy is designed for the spot trading platform BitMEX. By analyzing the fast RSI indicator and combining multiple technical indicators to screen signals, it realizes efficient trend tracking trading. The strategy also sets risk management and stop loss mechanisms to effectively control trading risks.
Calculate fast RSI with parameters of 7 days and overbought line 25, oversold line 75. When RSI crosses over overbought line, it is an overbought signal. When RSI crosses below oversold line, it is an oversold signal.
Set filter on candlestick body. Require opening as bearish candle with body length no less than 20% of yesterdayâ€™s average body length.
Set filter on candlestick color. Require last 4 candles as bearish when going short, and last 4 candles as bullish when going long.
Set stop loss logic. Close position when price moves in unfavorable direction.
Set anti-whipsaw mechanism. Only take signal when price recovers to stop loss level after initial move.
Set position sizing. Use fixed percentage of capital for each trade, and double position size after each loss.
Fast RSI parameters set reasonably can quickly capture trends. Combining with candlestick body and color filters can avoid false breakouts effectively.
Multi-layer filter enhances win rate by reducing number of trades.
Built-in stop loss mechanism limits per trade loss.
Dynamic position sizing realizes moderately aggressive capital management.
Customizable trading time frame avoids noise from major events.
High speed may miss some trading opportunities. Can relax parameters for more flexibility.
Hard to determine trend ending. Consider combining with other indicators to detect potential reversals.
Position sizing method too aggressive, can introduce locking position way.
Can optimize parameters for different markets to find better parameter combinations.
Overall this strategy is quite robust. By judging trend direction with fast RSI and filtering signals with multiple indicators, it can get good returns during trends. Also the strategy has room for optimization. By adjusting parameter combinations it can adapt to different market environments, thus having good practicality.
/*backtest start: 2023-11-05 00:00:00 end: 2023-11-12 00:00:00 period: 5m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //Noro //2018 //@version=2 strategy(title = "Robot BitMEX Fast RSI v1.0", shorttitle = "Robot BitMEX Fast RSI v1.0", overlay = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 10) //Settings needlong = input(true, defval = true, title = "Long") needshort = input(true, defval = true, title = "Short") usemar = input(true, defval = true, title = "Use Martingale") capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %") rsiperiod = input(7, defval = 7, minval = 2, maxval = 100, title = "RSI Period") rsilimit = input(25, defval = 25, minval = 1, maxval = 30, title = "RSI limit") rsibars = input(1, defval = 1, minval = 1, maxval = 20, title = "RSI Bars") useocf = input(true, defval = true, title = "Use Open Color Filter") useccf = input(true, defval = true, title = "Use Close Color Filter") openbars = input(4, defval = 4, minval = 1, maxval = 20, title = "Open Color Bars") closebars = input(1, defval = 1, minval = 1, maxval = 20, title = "Close Color Bars") useobf = input(true, defval = true, title = "Use Open Body Filter") usecbf = input(true, defval = true, title = "Use Close Body Filter") openbody = input(20, defval = 20, minval = 0, maxval = 1000, title = "Open Body Minimum, %") closebody = input(50, defval = 50, minval = 0, maxval = 1000, title = "Close Body Minimum, %") usecnf = input(true, defval = true, title = "Use Close Norma Filter") fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year") toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year") frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month") tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month") fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From Day") today = input(31, defval = 31, minval = 01, maxval = 31, title = "To Day") //RSI uprsi = rma(max(change(close), 0), rsiperiod) dnrsi = rma(-min(change(close), 0), rsiperiod) rsi = dnrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / dnrsi)) uplimit = 100 - rsilimit dnlimit = rsilimit rsidn = rsi < dnlimit ? 1 : 0 rsiup = rsi > uplimit ? 1 : 0 rsidnok = sma(rsidn, rsibars) == 1 rsiupok = sma(rsiup, rsibars) == 1 //Body Filter body = abs(close - open) abody = sma(body, 10) openbodyok = body >= abody / 100 * openbody or useobf == false closebodyok = body >= abody / 100 * closebody or usecbf == false //Color Filter bar = close > open ? 1 : close < open ? -1 : 0 gbar = bar == 1 ? 1 : 0 rbar = bar == -1 ? 1 : 0 opengbarok = sma(gbar, openbars) == 1 or useocf == false openrbarok = sma(rbar, openbars) == 1 or useocf == false closebarok = (strategy.position_size > 0 and bar == 1) or (strategy.position_size < 0 and bar == -1) or useccf == false //Norma Filter norma = (rsi > dnlimit and rsi < uplimit) or usecnf == false //Signals up = openrbarok and rsidnok and openbodyok and (strategy.position_size == 0 or close < strategy.position_avg_price) dn = opengbarok and rsiupok and openbodyok and (strategy.position_size == 0 or close > strategy.position_avg_price) exit = ((strategy.position_size > 0 and closebarok and norma) or (strategy.position_size < 0 and closebarok and norma)) and closebodyok //Indicator plot(rsi, color = blue, linewidth = 3, title = "Double RSI") plot(uplimit, color = black, title = "Upper Line") plot(dnlimit, color = black, title = "Lower Line") colbg = rsi > uplimit ? red : rsi < dnlimit ? lime : na bgcolor(colbg, transp = 20) //Trading profit = exit ? ((strategy.position_size > 0 and close > strategy.position_avg_price) or (strategy.position_size < 0 and close < strategy.position_avg_price)) ? 1 : -1 : profit[1] mult = usemar ? exit ? profit == -1 ? mult[1] * 2 : 1 : mult[1] : 1 lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 * mult : lot[1] if up if strategy.position_size < 0 strategy.close_all() strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))) if dn if strategy.position_size > 0 strategy.close_all() strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))) if time > timestamp(toyear, tomonth, today, 23, 59) or exit strategy.close_all()