
Esta estratégia é um sistema de negociação de curto prazo baseado na combinação de um cruzamento de dupla linha de equilíbrio e um indicador RSI. A estratégia usa um índice de média móvel de 9 ciclos e 21 ciclos (EMA) como base para determinar a tendência, enquanto combina um indicador relativamente forte (RSI) como uma ferramenta de confirmação de dinâmica para gerenciar o risco, definindo um stop loss e um stop loss fixos.
A lógica central da estratégia baseia-se na interação de dois indicadores técnicos. Primeiro, a direção da tendência do mercado é determinada pelo cruzamento de EMA de 9 ciclos e EMA de 21 ciclos. Quando a EMA curta atravessa a EMA de longo prazo para cima, é considerada uma tendência ascendente; Quando a EMA curta atravessa a EMA de longo prazo para baixo, é considerada uma tendência descendente.
A estratégia, combinando equilíbrio de linha cruzada e indicadores RSI, constrói um sistema de negociação de linha curta relativamente completo. Os benefícios da estratégia são a clareza do sinal, o risco é controlável, mas há também espaço para otimização. A estabilidade e a lucratividade da estratégia podem ser melhoradas adicionando mecanismos como stop loss dinâmico, filtragem de tempo e outros.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("abo 3llash - EMA + RSI Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Parameters
emaShortLength = input.int(9, title="Short EMA Length")
emaLongLength = input.int(21, title="Long EMA Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
stopLossPercent = input.float(1, title="Stop Loss Percentage") / 100
takeProfitPercent = input.float(2, title="Take Profit Percentage") / 100
// Calculating EMAs and RSI
emaShort = ta.ema(close, emaShortLength)
emaLong = ta.ema(close, emaLongLength)
rsi = ta.rsi(close, rsiLength)
// Buy and Sell Conditions
buyCondition = ta.crossover(emaShort, emaLong) and rsi < rsiOverbought
sellCondition = ta.crossunder(emaShort, emaLong) and rsi > rsiOversold
// Plotting the EMAs
plot(emaShort, title="Short EMA", color=color.blue)
plot(emaLong, title="Long EMA", color=color.red)
// Generating buy and sell signals on the chart
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Strategy Execution
if (buyCondition)
strategy.entry("Buy", strategy.long)
// Set Stop Loss and Take Profit for Buy
stopLossLevel = close * (1 - stopLossPercent)
takeProfitLevel = close * (1 + takeProfitPercent)
strategy.exit("Take Profit/Stop Loss", from_entry="Buy", stop=stopLossLevel, limit=takeProfitLevel)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Set Stop Loss and Take Profit for Sell
stopLossLevel = close * (1 + stopLossPercent)
takeProfitLevel = close * (1 - takeProfitPercent)
strategy.exit("Take Profit/Stop Loss", from_entry="Sell", stop=stopLossLevel, limit=takeProfitLevel)