Стратегия количественного прорыва цены E9 Shark 32 Pattern


Дата создания: 2024-11-12 14:51:17 Последнее изменение: 2024-11-12 14:51:17
Копировать: 1 Количество просмотров: 422
1
Подписаться
1617
Подписчики

Стратегия количественного прорыва цены E9 Shark 32 Pattern

Обзор

Стратегия является количественной торговой системой, основанной на распознавании ценовых форм, основанной на распознавании и использовании особых K-линейных форм, таких как “Крысолова 32”. Стратегия анализирует последовательность изменений в высоких и низких точках, устанавливает ключевые ценовые уровни после подтверждения форм и совершает сделки при их прорыве. Стратегия объединяет несколько элементов технического анализа, таких как распознавание форм, отслеживание тенденций и ценовые прорывы, чтобы создать целостную торговую систему.

Стратегический принцип

В основе стратегии лежит выявление формы “Крыльев 32”, которая требует выполнения следующих условий: низкие точки первых двух K-линий продолжают снижаться, в то время как высокие - продолжают расти. После подтверждения формы стратегия блокирует высокие и низкие точки начальной K-линии формы в качестве ключевых уровней цен. Система открывает позиции, когда цена пробивает эти ключевые уровни: когда цена на биржевой бирже пробивает высокие точки блокирования, она делает больше, а когда она пробивает низкие точки блокирования, она делает пустое место.

Стратегические преимущества

  1. Точность формы: форма идентифицируется с помощью строгих математических определений, избегая субъективного суждения
  2. Управление рисками: включает четкие установки стоп-лосса и прибыли
  3. Четкая визуальная обратная связь: использование различных цветных линий и фонов для обозначения форм и торговых сигналов
  4. Фильтрация дублирующих сигналов: только одна сделка разрешена в каждом формате, чтобы избежать переторгов
  5. Целевая установка разумная: целевые показатели прибыли, основанные на динамике формы, с хорошим соотношением риска и прибыли

Стратегический риск

  1. Риск рыночных потрясений: частое появление ложных сигналов прорыва на рынке в условиях пассивного колебания
  2. Риск скольжения: в быстром движении возможны большие скольжения
  3. Одноформатная зависимость: чрезмерная зависимость от одногоформата может привести к упущению других торговых возможностей
  4. Чувствительность параметров: параметры, установленные в целях остановки и получения прибыли, оказывают большое влияние на эффективность стратегии

Направление оптимизации стратегии

  1. Добавление подтверждения объема сделок: можно комбинировать изменения объема сделок для подтверждения эффективности прорыва
  2. Введение фильтрации рыночных условий: добавление индикатора интенсивности тренда для фильтрации неблагоприятных рыночных условий
  3. Оптимизация методов остановки: можно рассмотреть возможность использования динамического остановки для повышения адаптивности стратегии
  4. Добавление фильтрации по времени: добавление фильтрации по времени сделки, чтобы избежать колебаний в определенные периоды времени
  5. Совершенствование управления капиталом: добавление модуля управления позициями для оптимизации эффективности использования капитала

Подвести итог

Стратегия прорыва цены с количественной формой E9 рыбы 32 является структурированной, логически четкой торговой системой. Она создает стратегию торговли с количественной реализацией с помощью строгих формальных определений и четких правил торговли. Система управления рисками стратегии совершенна, визуальная обратная связь ясна, и ее легко понять и выполнить для трейдеров.

Исходный код стратегии
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
//║                                                                                                             ║
//║ ░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░   ░▒▓████████▓▒░▒▓██████▓▒░  ║
//║    ░▒▓█▓▒░   ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░      ░▒▓█▓▒░░▒▓█▓▒   ░▒▓█▓▒░     ░▒▓█▓▒░░▒▓█▓▒░ ║
//║    ░▒▓█▓▒░   ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░      ░▒▓█▓▒░░▒▓█▓▒.  ░▒▓█▓▒░     ░▒▓█▓▒░░▒▓█▓▒░ ║
//║    ░▒▓█▓▒░   ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓██████▓▒░ ░▒▓███████▓▒░.  ░▒▓██████▓▒░ ░▒▓███████▓▒░ ║
//║    ░▒▓█▓▒░   ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░      ░▒▓█▓▒░░▒▓█▓▒.  ░▒▓█▓▒░            ░▒▓█▓▒░ ║
//║    ░▒▓█▓▒░   ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░      ░▒▓█▓▒░░▒▓█▓▒.  ░▒▓█▓▒░            ░▒▓█▓▒░ ║
//║    ░▒▓█▓▒░   ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒.  ░▒▓████████▓▒░▒▓██████▓▒░  ║
//║                                                                                                             ║
//╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

//@version=5
strategy("E9 Shark-32 Pattern Strategy with Target Lines", shorttitle="E9 Shark-32 Strategy", overlay=true)

// Inputs for background color settings
bgcolorEnabled = input(true, title="Enable Background Color")
bgcolorColor = input.color(color.new(color.blue, 90), title="Background Color")

// Inputs for bar color settings
barcolorEnabled = input(true, title="Enable Bar Color")
barcolorColor = input.color(color.rgb(240, 241, 154), title="Bar Color")

// Inputs for target lines settings
targetLinesEnabled = input(true, title="Enable Target Lines")
targetLineColor = input.color(color.white, title="Target Line Color")
targetLineThickness = input.int(1, title="Target Line Thickness", minval=1, maxval=5)

// Define Shark-32 Pattern
shark32 = low[2] < low[1] and low[1] < low and high[2] > high[1] and high[1] > high

// Initialize color variables for bars
var color barColorCurrent = na
var color barColor1 = na
var color barColor2 = na

// Update color variables based on Shark-32 pattern
barColorCurrent := barcolorEnabled and (shark32 or shark32[1] or shark32[2]) ? barcolorColor : na
barColor1 := barcolorEnabled and (shark32[1] or shark32[2]) ? barcolorColor : na
barColor2 := barcolorEnabled and shark32[2] ? barcolorColor : na

// Apply the bar colors to the chart
barcolor(barColorCurrent, offset=-2, title="Shark-32 Confirmed Current")
barcolor(barColor1, offset=-3, title="Shark-32 Confirmed Previous Bar 1")
barcolor(barColor2, offset=-4, title="Shark-32 Confirmed Previous Bar 2")

// Variables for locking the high and low of confirmed Shark-32
var float patternHigh = na
var float patternLow = na
var float upperTarget = na
var float lowerTarget = na

// Once Shark-32 pattern is confirmed, lock the patternHigh, patternLow, and target lines
if shark32
    patternHigh := high[2]  // The high of the first bar in Shark-32 pattern
    patternLow := low[2]    // The low of the first bar in Shark-32 pattern

    // Calculate the upper and lower white target lines
    upperTarget := patternHigh + (patternHigh - patternLow)  // Dotted white line above
    lowerTarget := patternLow - (patternHigh - patternLow)   // Dotted white line below

// Initialize variables for the lines
var line greenLine = na
var line redLine = na
var line upperTargetLine = na
var line lowerTargetLine = na

// Draw the lines based on the locked patternHigh, patternLow, and target lines
// if shark32
//     future_bar_index_lines = bar_index + 10

//     // Draw lines based on locked patternHigh and patternLow
//     greenLine := line.new(x1=bar_index[2], y1=patternHigh, x2=future_bar_index_lines, y2=patternHigh, color=color.green, width=2, extend=extend.none)
//     redLine := line.new(x1=bar_index[2], y1=patternLow, x2=future_bar_index_lines, y2=patternLow, color=color.red, width=2, extend=extend.none)

//     // Draw dotted white lines if targetLinesEnabled is true
//     if targetLinesEnabled
//         upperTargetLine := line.new(x1=bar_index[2], y1=upperTarget, x2=future_bar_index_lines, y2=upperTarget, color=targetLineColor, width=targetLineThickness, style=line.style_dotted, extend=extend.none)
//         lowerTargetLine := line.new(x1=bar_index[2], y1=lowerTarget, x2=future_bar_index_lines, y2=lowerTarget, color=targetLineColor, width=targetLineThickness, style=line.style_dotted, extend=extend.none)

//     // Create a box to fill the background between the red and green lines
//     if bgcolorEnabled
//         box.new(left=bar_index[2], top=patternHigh, right=future_bar_index_lines, bottom=patternLow, bgcolor=bgcolorColor)

// -------------------------------------------------------------------------
// Strategy Entry and Exit Parameters
// -------------------------------------------------------------------------

// Input parameters for stop loss
longStopLoss = input.float(1.0, title="Long Stop Loss (%)", minval=0.1)  // Percentage-based stop loss for long
shortStopLoss = input.float(1.0, title="Short Stop Loss (%)", minval=0.1)  // Percentage-based stop loss for short

// Variable to track if a trade has been taken
var bool tradeTaken = false

// Reset the flag when a new Shark-32 pattern is confirmed
if shark32
    tradeTaken := false

// Entry conditions only trigger after the Shark-32 is confirmed
longCondition = ta.crossover(close, patternHigh) and not tradeTaken  // Long entry when close crosses above locked patternHigh
shortCondition = ta.crossunder(close, patternLow) and not tradeTaken  // Short entry when close crosses below locked patternLow

// Trigger long and short trades based on the crossover conditions
if (longCondition)
    label.new(bar_index, high, "Long Trigger", style=label.style_label_down, color=color.green, textcolor=color.white, size=size.small)
    strategy.entry("Shark-32 Long", strategy.long)
    tradeTaken := true  // Set the flag to true after a trade is taken

if (shortCondition)
    label.new(bar_index, low, "Short Trigger", style=label.style_label_up, color=color.red, textcolor=color.white, size=size.small)
    strategy.entry("Shark-32 Short", strategy.short)
    tradeTaken := true  // Set the flag to true after a trade is taken

// Exit long trade based on the upper target line (upper white dotted line) as take profit
if strategy.position_size > 0
    strategy.exit("Take Profit Long", "Shark-32 Long", limit=upperTarget, stop=close * (1 - longStopLoss / 100))

// Exit short trade based on the lower target line (lower white dotted line) as take profit
if strategy.position_size < 0
    strategy.exit("Take Profit Short", "Shark-32 Short", limit=lowerTarget, stop=close * (1 + shortStopLoss / 100))