资源加载中... loading...

JMA Crossing RSI Trading Strategy

Author: ChaoZhang, Date: 2023-09-18 21:42:50
Tags:

Overview

This strategy generates trading signals by crossing of Jurik Moving Average (JMA) and RSI indicator. It goes long when JMA crosses above RSI and goes short when crossing below. The strategy attempts to filter false signals by combining two indicators, and trade when trend is more apparent.

Principles

The strategy mainly utilizes two types of indicators:

  1. JMA indicator: A smoothed moving average using power multipliers, with lower lag and quicker in capturing price changes.

  2. RSI indicator: A common strength indicator reflecting buying/selling momentum.

When JMA crosses above RSI, it indicates stronger short-term uptrend over long term trend and generates buy signal. When crossing below RSI, it prompts sell signal.

Upon signal, the strategy enters trade in corresponding direction. Exits when price reaches predetermined profit ratio or indicators cross reverse direction.

Advantages

  1. Adjustable JMA parameters adaptable to different periods.

  2. RSI filters false breakouts.

  3. Dual indicator combination reduces false signals.

  4. Built-in stop loss controls loss.

  5. Customizable profit ratio for profit targeting.

Risks and Mitigations

  1. Dual indicators combo may generate too few signals. Can tweak parameters for sensitivity.

  2. JMA still has lag, may miss turning points. Can optimize with leading indicators.

  3. Improper stop loss placement may be hit for greater loss. Should backtest for suitable placement.

  4. Overreliance on indicators can produce false signals. Can add volume or volatility filters.

Enhancement Opportunities

  1. Test JMA parameters to find optimal settings.

  2. Try different RSI parameters for better performance.

  3. Add trailing stop mechanism for adaptive stops.

  4. Optimize entry position sizing like adding to winning trades.

  5. Research additional filters like KD, MACD.

Summary

The strategy enables trend following with JMA and RSI crossovers and limits risk via stops. But false signals remain probable, requiring further optimization on parameters and filters. Stop loss also needs backtest validation. It provides a basic framework for dual indicator crossing system with room for improvements.


/*backtest
start: 2023-01-01 00:00:00
end: 2023-03-15 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// Stratégie marche le mieux sur du 2 jours
strategy("JMA(7,50,RSI) crossing RSI(14,close)", overlay=false, currency=currency.EUR, default_qty_type=strategy.cash, default_qty_value=5000)

// Strategy Tester Start Time
sYear = input(2019, title = "Start Year")
sMonth = input(06, title = "Start Month", minval = 01, maxval = 12)
sDay = input(01, title = "Start Day", minval = 01, maxval = 31)
sHour = input(00, title = "Start Hour", minval = 00, maxval = 23)
sMinute = input(00, title = "Start Minute", minval = 00, maxval = 59)
startTime = true

// Strategy Tester End Time
eYear = input(2019, title = "End Year")
eMonth = input(12, title = "End Month", minval = 01, maxval = 12)
eDay = input(01, title = "End Day", minval = 01, maxval = 31)
eHour = input(00, title = "End Hour", minval = 00, maxval = 23)
eMinute = input(00, title = "End Minute", minval = 00, maxval = 59)
endTime = true

// === RSI ===
src = close, len = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=color.purple)
band1 = hline(70)
band0 = hline(30)

// === JMA ===
_length = input(7, title="Length")
_phase = input(50, title="Phase")
_power = input(2, title="Power")
highlightMovements = input(true, title="Highlight Movements ?")

// srcJMA = input(rsi, title="Source")
srcJMA = rsi

phaseRatio = _phase < -100 ? 0.5 : _phase > 100 ? 2.5 : _phase / 100 + 1.5
beta = 0.45 * (_length - 1) / (0.45 * (_length - 1) + 2)
alpha = pow(beta, _power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * srcJMA + alpha * nz(e0[1])
e1 = 0.0
e1 := (srcJMA - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
// === End of JMA def ===

jmaColor = highlightMovements ? (jma > jma[1] ? color.green : color.red) : #6d1e7f
plot(jma, title="JMA switch", linewidth=2, color=jmaColor, transp=0)

// === Inputs ===
// risk management
useStop = input(true, title = "Use Initial Stop Loss?")

goLong() => crossover(rsi, jma)
killLong() => crossunder(rsi, jma)

// ======= DEBUGGGGGGGG ============
long_price = 0.0
short_price = 0.0

if(startTime and endTime)
    if(goLong())
        long_price := close
    strategy.entry("Buy", strategy.long, when = goLong())
    strategy.close("Buy", when = killLong() and close > long_price)

// Shorting if using
goShort() => killLong()
killShort() => goLong()

if(startTime and endTime)
    if(goShort())
        short_price := close
    strategy.entry("Sell", strategy.short, when = goShort() and close < short_price)
    strategy.close("Sell", when = killShort())
// =========================

if (useStop)
    strategy.exit("XLS", from_entry ="Buy", stop = strategy.position_avg_price / 1.08)
    strategy.exit("XSS", from_entry ="Sell", stop = strategy.position_avg_price * 1.08)



More