
Эта стратегия является системой торговли, которая сочетает в себе индикатор SuperTrend и случайный индикатор (Stochastic Oscillator). Эта стратегия использует индикатор SuperTrend для определения направления рыночной тенденции, а также использует сигнал перекупа и перепродажи случайного индикатора в качестве сигнала подтверждения сделки. Стратегия использует метод пересечения динамики, чтобы найти оптимальные моменты входа и выхода в направлении тенденции, чтобы достичь идеального сочетания слежения за тенденцией и анализа динамики.
Основная логика стратегии основана на сочетании двух основных показателей:
Правила сделки следующие:
Эта стратегия, объединенная с отслеживанием тенденций и динамическим анализом, создает более полную торговую систему. Она не только обеспечивает четкие сигналы входа и выхода, но также включает в себя рамки для управления рисками и оптимизации параметров. Хотя существуют некоторые присущие риски, предоставление рекомендаций по оптимизации может дополнительно повысить стабильность и адаптацию стратегии.
/*backtest
start: 2024-02-21 00:00:00
end: 2024-10-01 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("SuperTrend + Stochastic Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// SuperTrend Settings
superTrendFactor = input.float(3.0, title="SuperTrend Factor", step=0.1)
superTrendATRLength = input.int(10, title="SuperTrend ATR Length")
// Calculate SuperTrend
[superTrend, direction] = ta.supertrend(superTrendFactor, superTrendATRLength)
// Plot SuperTrend
plot(superTrend, color=direction == 1 ? color.green : color.red, title="SuperTrend")
bgcolor(direction == 1 ? color.new(color.green, 90) : color.new(color.red, 90), transp=90)
// Stochastic Settings
stochKLength = input.int(14, title="Stochastic %K Length")
stochDLength = input.int(3, title="Stochastic %D Length")
stochSmoothK = input.int(3, title="Stochastic %K Smoothing")
stochOverbought = input.int(80, title="Stochastic Overbought Level")
stochOversold = input.int(20, title="Stochastic Oversold Level")
// Calculate Stochastic
k = ta.sma(ta.stoch(close, high, low, stochKLength), stochSmoothK)
d = ta.sma(k, stochDLength)
// Plot Stochastic in separate pane
hline(stochOverbought, "Overbought", color=color.red)
hline(stochOversold, "Oversold", color=color.green)
plot(k, color=color.blue, title="%K", linewidth=2)
plot(d, color=color.orange, title="%D", linewidth=2)
// Long Condition: SuperTrend is up and Stochastic %K crosses above oversold
longCondition = direction == 1 and ta.crossover(k, stochOversold)
if (longCondition)
strategy.entry("Long", strategy.long)
// Short Condition: SuperTrend is down and Stochastic %K crosses below overbought
shortCondition = direction == -1 and ta.crossunder(k, stochOverbought)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Exit Long: SuperTrend turns down or Stochastic %K crosses below overbought
exitLong = direction == -1 or ta.crossunder(k, stochOverbought)
if (exitLong)
strategy.close("Long")
// Exit Short: SuperTrend turns up or Stochastic %K crosses above oversold
exitShort = direction == 1 or ta.crossover(k, stochOversold)
if (exitShort)
strategy.close("Short")