0bps

Strategy vault / Trend following

RSI and WMA Crossover Strategy

This article mainly introduces a quantitative trading strategy based on RSI and WMA. The strategy generates buy and sell signals by calculating the values of RSI and WMA to discover reversal points of stock prices…

Author
ChaoZhang
Complexity
Starter · 42 lines
Parameters
2
Backtest bar
1h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

This article mainly introduces a quantitative trading strategy based on RSI and WMA. The strategy generates buy and sell signals by calculating the values of RSI and WMA to discover reversal points of stock prices, aiming to buy low and sell high.

Strategy Logic

The core indicators of this strategy include RSI and WMA. RSI (Relative Strength Index) is a volatility indicator used to measure the change in the speed of recent price rises and falls. WMA (Weighted Moving Average) is a weighted moving average.

The buy signal of the strategy is generated when the RSI crosses above the WMA, indicating a price reversal and a possible start of an upward trend. The sell signal is generated when the RSI crosses below the WMA, implying a price reversal and a possible start of a downward trend.

Specifically, the strategy first calculates the 14-day RSI, then calculates the 45-day WMA. If the RSI crosses above the WMA, a buy signal is generated. If the RSI crosses below the WMA, a sell signal is generated. The combination of RSI and WMA can capture price reversal points more accurately.

Advantages

This strategy has the following advantages:

  1. Clear signals and easy rules facilitate implementation.
  2. RSI and WMA verifies each other to reduce false signals.
  3. Adjustable RSI parameters suit stocks with different cycles.
  4. Adjustable WMA parameters capture trends at different levels.
  5. Simple and clean code for easy optimization.

Risks

The risks include:

  1. Extreme price swings may trigger stop loss.
  2. Inappropriate RSI and WMA parameters lead to failure.
  3. High trading frequency increases costs and slippage.
  4. Unable to filter systemic risks effectively.

These risks can be mitigated by parameter tuning, stop loss, filtering market risks etc.

Enhancement Opportunities

The strategy can be optimized from the following aspects:

  1. Test RSI and WMA parameters for optimal values.
  2. Add volume filter to avoid false signals.
  3. Set variable stop loss lines against adverse price moves.
  4. Integrate other indicators like MACD and BOLL for filtering.
  5. Improve entry and exit logic for timing optimization.

Conclusion

This strategy integrates RSI and WMA to capture crossovers for trade signals, enabling simple and effective algo trading. It is easy to implement and profitable in bull markets. Further parameter testing, tuning, and proper stop loss mechanisms can enhance its stability and profitability.

Parameters

NameDefaultWhat it controls
v_input_114RSI Length
v_input_245WMA Length

Source Pine Script

/*backtest
start: 2024-01-05 00:00:00
end: 2024-02-04 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("RSI WMA Strategy", overlay=true)

// Input parameters
rsiLength = input(14, title="RSI Length")
wmaLength = input(45, title="WMA Length")

// Calculate RSI and WMA
rsiValue = ta.rsi(close, rsiLength)
wmaValue = ta.wma(rsiValue, wmaLength)

// Define overbought and oversold levels for RSI
overboughtLevel = 70
oversoldLevel = 30

// Strategy logic
longCondition = ta.crossover(rsiValue, wmaValue)
shortCondition = ta.crossunder(rsiValue, wmaValue)

// Execute trades
if (longCondition)
    strategy.entry("Long", strategy.long, comment="BUY")
if (shortCondition)
    strategy.entry("Short", strategy.short, comment="SELL")

// Plotting for visualization
plot(rsiValue, title="RSI", color=color.blue)
plot(wmaValue, title="WMA", color=color.orange)
hline(overboughtLevel, "Overbought Level", color=color.red)
hline(oversoldLevel, "Oversold Level", color=color.green)

// Plot buy and sell signals on the chart
plotshape(series=longCondition, title="Buy Signal", color=color.green, style=shape.labelup, location=location.belowbar)
plotshape(series=shortCondition, title="Sell Signal", color=color.red, style=shape.labeldown, location=location.abovebar)

Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-05. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/RSI-and-WMA-Crossover-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open