
La stratégie utilise des indicateurs tels que la moyenne mobile lisse (SMA), l’indice de force relative (RSI), la portée réelle (TR) et la moyenne mobile de la transaction (Volume MA) pour effectuer des transactions lorsque des conditions spécifiques sont remplies. L’idée principale de la stratégie est de faire des achats lorsque le prix est inférieur à la SMA200 et en baisse, avec un faible volume de transactions et une faible volatilité.
La stratégie utilise plusieurs indicateurs techniques, combinant un filtrage de tendance et des conditions de volume et de volatilité, pour effectuer des transactions dans des situations spécifiques. Dans le même temps, la mise en place d’un mécanisme de stop loss et d’exit exceptionnel peut contrôler efficacement le risque. Cependant, la stratégie présente également certaines limites, car des facteurs tels que le choix des paramètres, les anomalies du marché et autres peuvent affecter la performance de la stratégie.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Strategia Stop Loss & Take Profit z Filtrem Trendu i Wyjątkiem", shorttitle="Smooth MA SL & TP with Exception", overlay=true)
// Parametry
tp_multiplier = input.float(1.5, title="Mnożnik Take Profit")
sl_percent = input.float(5, title="Procent Stop Loss")
wait_bars = input.int(3, title="Liczba Oczekiwanych Świec")
sma_period = input.int(200, title="Okres SMA")
rsi_period = input.int(14, title="Okres RSI")
vol_ma_period = input.int(20, title="Okres Średniej Wolumenu")
tr_ma_period = input.int(20, title="Okres Średniej Rzeczywistego Zakresu")
// Obliczenie Gładkiej Średniej Kroczącej
sma = ta.sma(close, sma_period)
// Obliczenie RSI
rsi = ta.rsi(close, rsi_period)
// Filtr Trendu
uptrend = close > sma
downtrend = close < sma
// Warunek konsolidacji: Niski wolumen i niska zmienność
niski_wolumen = volume < ta.sma(volume, vol_ma_period)
niska_zmienosc = ta.tr(true) < ta.sma(ta.tr(true), tr_ma_period)
// Warunek Wejścia (Long): Cena poniżej SMA 200 i filtr trendu w strefie czerwonej
warunek_wejscia = close < sma and niski_wolumen and niska_zmienosc and not uptrend
// Warunek Wyjścia ze strategii
warunek_wyjscia = downtrend and close > sma and ta.crossover(close, sma)
// Ustalanie Stop Loss i Take Profit
var float stop_loss = na
var float take_profit = na
var int indeks_wejscia = na
if (warunek_wejscia)
stop_loss := close * (1 - sl_percent / 100)
take_profit := close * (1 + tp_multiplier)
indeks_wejscia := bar_index
// Handel
if (warunek_wejscia)
strategy.entry("Long", strategy.long)
// Warunek Wyjścia: RSI w strefie wykupienia lub Stop Loss/Take Profit
if (strategy.opentrades != 0)
if (rsi > 70)
strategy.exit("Take Profit/Stop Loss", "Long", limit=take_profit)
else if (bar_index - indeks_wejscia == wait_bars)
strategy.exit("Take Profit/Stop Loss", "Long", stop=stop_loss, limit=take_profit)
// Wyjątek: Warunek Wyjścia z Longów na podstawie zmiany trendu
if (warunek_wyjscia)
strategy.close("Long")
// Rysowanie RSI
rsi_plot = plot(rsi, title="RSI", color=color.blue)
// Rysowanie Gładkiej Średniej Kroczącej
sma_plot = plot(sma, color=color.gray, title="Smooth MA", linewidth=2)
// Rysowanie Filtru Trendu
fill(sma_plot, rsi_plot, color=downtrend ? color.new(color.red, 90) : na)