Bitlinc MARSI Estratégia de negociação

Autora:ChaoZhang, Data: 2024-02-29 10:54:45
Tags:

img

Resumo

Esta estratégia é uma estratégia de rastreamento de oscilação do RSI baseada em ajustes anuais.

Princípio da estratégia

  1. Defina os parâmetros para o comprimento de MA, RSI, faixa superior/inferior, take profit/stop loss, intervalo do ciclo de negociação.
  2. Calcular o valor do RSI, RSI = (Mudança média ascendente) / ((Mudança média ascendente + Mudança média descendente) *100)
  3. Linha e bandas do gráfico RSI
  4. O cruzamento do RSI abaixo da faixa inferior é um sinal longo, o cruzamento acima da faixa superior é um sinal curto
  5. Posições abertas com ordens OCO
  6. Executar stop loss e take profit com base nas configurações

Análise das vantagens

  1. A fixação do ciclo anual de negociação evita ambientes externos inadequados.
  2. O RSI reflete a sobrecompra/supervenda de forma eficiente.
  3. As ordens OCO + configurações stop loss/profit permitem um controlo de risco eficiente.

Análise de riscos

  1. A exatidão do julgamento do limiar RSI não pode ser garantida, podendo ocorrer erros de julgamento.
  2. As configurações inadequadas do ciclo anual podem perder melhores oportunidades ou entrar em ambientes inadequados.
  3. A definição de stop loss excessivamente grande pode conduzir a grandes perdas, enquanto a definição de lucro demasiado pequeno dá um pequeno lucro.

Métodos como ajustar os parâmetros do RSI, a faixa do ciclo de negociação, os rácios stop loss/profit podem ser usados para otimizar.

Orientações de otimização

  1. Teste de parâmetros de RSI ótimos para diferentes mercados e ciclos
  2. Analisar o padrão geral do ciclo de mercado, definir a melhor fase anual de negociação
  3. Determinar rácios razoáveis stop loss/profit através de backtest
  4. Otimizar a selecção de produtos de negociação e o dimensionamento das posições
  5. Combinar com outras técnicas melhores para uma otimização adicional

Resumo

Esta estratégia rastreia a tendência pelas características de oscilação do ciclo anual do RSI, controlando efetivamente os riscos de negociação.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy(title = "Bitlinc MARSI Study AST",shorttitle="Bitlinc MARSI Study AST",default_qty_type = strategy.percent_of_equity, default_qty_value = 100,commission_type=strategy.commission.percent,commission_value=0.1,initial_capital=1000,currency="USD",pyramiding=0, calc_on_order_fills=false)

// === General Inputs ===
lengthofma = input(62, minval=1, title="Length of MA")
len = input(31, minval=1, title="Length")
upperband = input(89, minval=1, title='Upper Band for RSI')
lowerband = input(10, minval=1, title="Lower Band for RSI")
takeprofit =input(1.25, title="Take Profit Percent")
stoploss =input(.04, title ="Stop Loss Percent")
monthfrom =input(8, title = "Month Start")
monthuntil =input(12, title = "Month End")
dayfrom=input(1, title= "Day Start")
dayuntil=input(31, title= "Day End")

// === Innput Backtest Range ===
//FromMonth = input(defval = 9, title = "From Month", minval = 1, maxval = 12)
//FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
//FromYear  = input(defval = 2018, title = "From Year", minval = 2017)
//ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
//ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
//ToYear    = input(defval = 9999, title = "To Year", minval = 2017)

// === Create RSI ===
src=sma(close,lengthofma)
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,linewidth = 2, color=purple)

// === Plot Bands ===
band1 = hline(upperband)
band0 = hline(lowerband)
fill(band1, band0, color=blue, transp=95)

// === Entry and Exit Methods ===
longCond =  crossover(rsi,lowerband)
shortCond =  crossunder(rsi,upperband)

// === Long Entry Logic ===
if (  longCond ) 
    strategy.entry("LONG", strategy.long, stop=close, oca_name="TREND", comment="LONG")
else
    strategy.cancel(id="LONG")

// === Short Entry Logic ===    
if ( shortCond   ) 
    strategy.entry("SHORT", strategy.short,stop=close, oca_name="TREND",  comment="SHORT")
else
    strategy.cancel(id="SHORT")

// === Take Profit and Stop Loss Logic ===
//strategy.exit("Take Profit LONG", "LONG", profit = close * takeprofit / syminfo.mintick, loss = close * stoploss / syminfo.mintick)
//strategy.exit("Take Profit SHORT", "SHORT", profit = close * takeprofit / syminfo.mintick, loss = close * stoploss / syminfo.mintick)
strategy.exit("LONG TAKE PROFIT", "LONG", profit = close * takeprofit / syminfo.mintick)
strategy.exit("SHORT STOP LOSS", "SHORT", profit = close * takeprofit / syminfo.mintick)
strategy.exit("LONG STOP LOSS", "LONG", loss = close * stoploss / syminfo.mintick)
strategy.exit("SHORT STOP LOSS", "SHORT", loss = close * stoploss / syminfo.mintick)



Mais.