RSI и стратегия прорыва скользящей средней

Автор:Чао Чжан, Дата: 2024-01-24 14:31:01
Тэги:

img

Обзор

Стратегия RSI и Moving Average Breakout - это количественная стратегия, которая использует как индикатор RSI, так и линии движущейся средней для определения торговых возможностей.

Логика стратегии

  1. Расчет показателя RSI и простых скользящих средних линий на основе параметров, определенных пользователем.

  2. Когда RSI пересекает линию перепроданности (по умолчанию 30), генерируется длинный сигнал, если цена ниже Длинного выхода.

  3. Когда RSI пересекает линию перекупленности (70 по умолчанию), генерируется короткий сигнал, если цена выше скользящей средней выхода SHORT.

  4. Пользователи могут выбрать фильтр сигналов на основе линии движущегося среднего тренда.

  5. Выходы определяются линиями ДЛОГО и КОРТОГО выхода скользящей средней.

Анализ преимуществ

  1. Дизайн с двумя индикаторами повышает точность, включая два основных фактора рынка.

  2. Эффективно использует характеристику среднего отклонения RSI для определения поворотных точек.

  3. Дополнительный фильтр с скользящими средними увеличивает логическую строгость, чтобы избежать погони за вершинами и дном.

  4. Настраиваемые параметры позволяют оптимизировать различные продукты и сроки.

  5. Простая логика делает его легким для понимания и изменения.

Анализ рисков

  1. С РСИ часто бывают сбивания, индикатор плотности может помочь.

  2. RSI, как правило, терпит неудачу в более длительные периоды времени, параметры могут быть скорректированы или могут помочь дополнительные индикаторы.

  3. Движущиеся средние имеют эффект отставания, длины могут быть сокращены или такие индикаторы, как MACD, могут помочь.

  4. В связи с основной логикой необходимо ввести больше показателей для проверки сигналов.

Руководство по оптимизации

  1. Оптимизировать параметры RSI или ввести индикатор плотности для уменьшения ложных сигналов.

  2. Включайте индикаторы тренда и волатильности, такие как DMI и BOLL, чтобы определить тенденции и поддержку.

  3. Введение MACD для замены или дополнения оценок скользящей средней.

  4. Добавьте больше логических условий на входные сигналы, чтобы избежать неблагоприятных прорывов.

Заключение

Стратегия RSI и Moving Average Breakout сочетает в себе обнаружение перекупленности RSI и определение тренда Moving Averages, чтобы теоретически извлечь выгоду из возможностей реверсии среднего. Стратегия интуитивна и проста в использовании для новичков и может быть оптимизирована для разных продуктов, что делает ее рекомендуемой количественной стартовой стратегией.


/*backtest
start: 2024-01-16 00:00:00
end: 2024-01-23 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Global Market Signals: RSI Strategy.
//@version=4
strategy("GMS: RSI Strategy", overlay=true)

LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
RSILength = input(title="RSI Length", type = input.integer ,defval=14)
RSIUpper = input(title="Upper Threshold", type = input.float ,defval=70)
RSILower = input(title="Lower Threshold", type = input.float ,defval=30)
LongExit = input(title="Long Exit SMA Length", type = input.integer ,defval=5)
ShortExit = input(title="Short Exit SMA Length", type = input.integer ,defval=5)
AboveBelow = input(title="Trend SMA Filter?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
TrendLength = input(title="Trend SMA Length", type = input.integer ,defval=200)


//Long Side

if LongShort =="Long Only" and AboveBelow == "Above"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Long Only" and AboveBelow == "Below"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Both" and AboveBelow == "Above"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Both" and AboveBelow == "Below"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Both" and AboveBelow == "Don't Include"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
    
//SHORT SIDE

if LongShort =="Short Only" and AboveBelow == "Above"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Short Only" and AboveBelow == "Below"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Both" and AboveBelow == "Above"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Both" and AboveBelow == "Below"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Both" and AboveBelow == "Don't Include"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
    
    
    
    
    
   





Больше