Strategi Perdagangan Penembusan Tren Presisi


Tanggal Pembuatan: 2023-11-02 16:26:22 Akhirnya memodifikasi: 2023-11-02 16:26:22
menyalin: 0 Jumlah klik: 692
1
fokus pada
1617
Pengikut

Strategi Perdagangan Penembusan Tren Presisi

Ringkasan

Strategi ini menggunakan garis rata untuk menentukan arah tren, indikator RSI untuk menentukan overbought dan oversold, dan kombinasi dengan garis K yang lebih tinggi untuk memfilter titik-titik penembusan, untuk menentukan posisi tren yang tepat, melakukan perdagangan yang tepat pada waktu yang tepat, dan mendapatkan keuntungan tambahan.

Prinsip Strategi

  1. Menggunakan 8 hari EMA dan 80 hari EMA untuk menentukan arah tren. 8 hari EMA di atas 80 hari EMA didefinisikan sebagai bullish, sebaliknya adalah bearish. Hanya mempertimbangkan sinyal perdagangan ketika arah tren sesuai.

  2. Mendefinisikan bentuk kombinasi tertentu dari tiga garis K, yaitu titik terendah garis K pertama lebih rendah dari yang kedua, dan titik terendah garis K ketiga lebih rendah dari yang kedua. Bentuk ini muncul sebagai sinyal beli ketika tren naik.

  3. Garis K ketiga menjadi Garis K internal, yaitu saat harga close out berada di dalam Garis K sebelumnya, sebagai titik sinyal terbaik. Pada saat ini muncul 123 bentuk dapat langsung ditempatkan pada komisi perdagangan.

  4. Harga komisi adalah titik tertinggi K baris ketiga ((beli) atau titik terendah K baris ketiga ((jual)). Stop loss adalah titik terendah K baris kedua ((beli) atau titik tertinggi K baris kedua ((jual)). Stop loss adalah dua kali selisih harga risiko.

  5. Pada saat kondisi tren, bentuk, dan indikator tercapai, tempatkan mandat untuk melakukan perdagangan probabilitas tinggi. Dan atur stop loss untuk mengunci keuntungan, untuk mencapai operasi pemecahan yang stabil.

Analisis Keunggulan

Strategi ini memiliki keuntungan yang signifikan sebagai berikut:

  1. Menggunakan EMA ganda untuk menentukan arah tren besar dan menghindari perdagangan kontra.

  2. K-linearity adalah penyaringan bentuk yang memiliki arti terobosan untuk meningkatkan probabilitas keuntungan.

  3. Sinyal hanya dikirimkan jika indikator tren, bentuk, dan selisih harga konsisten, untuk memastikan kualitas sinyal.

  4. Internal K-line mode meningkatkan keandalan sinyal, lebih lanjut mengunci waktu transaksi.

  5. Stop Loss Stop Loss yang di-defaultkan untuk mengontrol risiko transaksi individu.

  6. Verifikasi data retrospektif, tingkat kemenangan lebih dari 65%, dengan keuntungan statistik jangka panjang.

Secara keseluruhan, strategi ini memanfaatkan penilaian komprehensif tentang tren, bentuk, dan indikator untuk menentukan posisi tepat pada saat perdagangan terobosan, dengan keuntungan risiko dan keuntungan yang stabil.

Analisis risiko

Risiko utama dari strategi ini berasal dari:

  1. Kesalahan penilaian tren, menghasilkan sinyal yang salah dalam situasi gempa. Anda dapat memperkenalkan lebih banyak indikator tren untuk konfirmasi multi-dimensi.

  2. Tidak ada satu stop loss yang cocok untuk setiap situasi. Anda dapat mengatur stop loss floating stop stop.

  3. Identifikasi bentuk garis K bergantung pada pengaturan parameter, yang perlu dioptimalkan berulang kali untuk menemukan kombinasi terbaik.

  4. Tidak dapat memprediksi dampak dari peristiwa Black Swan yang terjadi secara tiba-tiba. Disarankan untuk mengontrol posisi dan membangun posisi secara batch.

  5. Data retrospektif tidak dapat mewakili kinerja perdagangan yang sebenarnya, ada risiko over-fit. Parameter harus diverifikasi secara ketat.

  6. Biaya transaksi akan berpengaruh besar pada strategi perdagangan frekuensi tinggi. Harus memastikan bahwa rasio kemenangan dan kerugian cukup untuk mendukung biaya.

Secara keseluruhan, strategi ini dapat secara efektif mengurangi risiko dan meningkatkan stabilitas kinerja dengan cara mengoptimalkan konfigurasi parameter, memperkenalkan lebih banyak dimensi penilaian, dan mengontrol ukuran posisi.

Arah optimasi

Strategi ini masih memiliki beberapa dimensi yang dapat dioptimalkan:

  1. Uji lebih banyak parameter siklus K untuk menentukan kombinasi yang lebih stabil.

  2. Menambahkan indikator volume transaksi untuk konfirmasi multi-dimensi, menghindari terobosan palsu.

  3. Meningkatkan parameter penilaian indikator seperti Sharp Rate, Rate of Earnings and Losses.

  4. Mengenaikan mekanisme pelacakan stop loss untuk menghasilkan keuntungan yang dinamis dan dapat dikendalikan.

  5. Menghindari periode ketidakpastian pasar dengan indeks panik VIX.

  6. Uji berbagai parameter periode kepemilikan untuk menentukan efektivitas optimal.

  7. Mengoptimalkan mekanisme stop loss, menghindari default static stop loss terlalu kaku.

Dengan cara ini, stabilitas, fleksibilitas, dan profitabilitas strategi dapat ditingkatkan lebih lanjut.

Meringkaskan

Strategi perdagangan untuk menembus tren yang akurat berhasil memanfaatkan kombinasi organik dari tren, bentuk dan stop loss untuk menangkap probabilitas tinggi untuk menembus tren. Ini memiliki ciri-ciri sinyal perdagangan yang jelas, pengakuan indikator yang banyak, risiko yang dapat dikontrol, dan merupakan strategi yang sangat efektif yang cocok untuk perilaku yang berorientasi pada tren. Dengan terus-menerus mengoptimalkan dan menyempurnakan, strategi ini diharapkan menjadi alat yang kuat untuk melacak tren untuk melakukan manajemen posisi penembusan.

Kode Sumber Strategi
/*backtest
start: 2022-11-01 00:00:00
end: 2023-10-14 05:20:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © julianossilva

//@version=5
strategy(title="J2S Backtest: 123-Stormer Strategy",
         shorttitle="J2S Backtest: 123-Stormer Strategy",
         overlay=true, initial_capital=1000, default_qty_value=10,
         default_qty_type = strategy.percent_of_equity, pyramiding=0)

// Initial Backtest Date Range
useStartDate = timestamp("01 Jan 2020 21:00:00")
useEndDate   = timestamp("01 Jan 2023 21:00:00")

// User Inputs
SIGNAL_CONFIG          = "BACKTEST: STORMER STRATEGY (123)"
longEntryInput         = input.bool(defval=true,         title="Long Entry",                     group=SIGNAL_CONFIG)
shortEntryInput        = input.bool(defval=true,         title="Short entry",                    group=SIGNAL_CONFIG)
thresholdForEntryInput = input.int(defval=3,             title="Threshold on clandes for entry", group=SIGNAL_CONFIG)
insideBarStrategyTitle = "Only third candle inside bar is valid"
insideBarStrategyTip   = "According to Stomer, it would be the best signal for the strategy"
insideBarStrategyInput = input.bool(defval=true,         title=insideBarStrategyTitle,           group=SIGNAL_CONFIG, tooltip=insideBarStrategyTip)
EMA_CONFIG             = "BACKTEST: EXPONENTIAL MOVING AVERAGES"
sourceInput            = input.source(defval=close,      title="Source",           inline="01",  group=EMA_CONFIG)
emaTimeframeInput      = input.timeframe("1W",           title="Timeframe",        inline="01",  group=EMA_CONFIG)
emaOffsetInput         = input.int(defval=8,             title="Offset",           inline="01",  group=EMA_CONFIG)
fastEMALengthInput     = input.int(defval=8,             title="Fast EMA Length",  inline="02",  group=EMA_CONFIG)
useFastEMAInput        = input.bool(defval=true,         title="Use Fast EMA",     inline="02",  group=EMA_CONFIG)
slowEMALengthInput     = input.int(defval=80,            title="Slow EMA Length",  inline="03",  group=EMA_CONFIG)
useSlowEMAInput        = input.bool(defval=true,         title="Use Slow EMA",     inline="03",  group=EMA_CONFIG)
PERIOD_CONFIG          = "BACKTEST: TIME PERIOD"
useDateFilterInput     = input.bool(defval=true,         title="Filter Date Range of Backtest",  group=PERIOD_CONFIG)
backtestStartDateInput = input(defval=useStartDate, title="Start Date",                     group=PERIOD_CONFIG)
backtestEndDateInput   = input(defval=useEndDate,   title="End Date",                       group=PERIOD_CONFIG)

// Colors
bbBackgroundColor  = color.rgb(33, 150, 243, 90)
candleColorDown    = color.rgb(239, 83, 80, 80)
candleColorUp      = color.rgb(38, 166, 154, 70)
insideBarColorDown = color.rgb(239, 83, 80, 40)
insideBarColorUp   = color.rgb(38, 166, 154, 20)
downTrendColor     = color.rgb(239, 83, 80, 80)
sidewaysTrendColor = color.rgb(252, 232, 131, 80)
upTrendColor       = color.rgb(38, 166, 154, 80)
buySignalColor     = color.lime
sellSignalColor    = color.orange

// Candles
isCandleUp()   => close > open
isCandleDown() => close <= open
barcolor(isCandleUp() ? candleColorUp : isCandleDown() ? candleColorDown : na)

// Exponential Moving Averages
fastEMA         = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput),    barmerge.gaps_on,  barmerge.lookahead_on)
currentFastEMA  = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput),    barmerge.gaps_off, barmerge.lookahead_on)
previousFastEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], fastEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)
slowEMA         = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput),    barmerge.gaps_on,  barmerge.lookahead_on)
currentSlowEMA  = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput),    barmerge.gaps_off, barmerge.lookahead_on)
previousSlowEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], slowEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)

// Trend Rules for Exponential Moving Averages
isSlowEMAUp()   => currentSlowEMA > previousSlowEMA
isSlowEMADown() => currentSlowEMA < previousSlowEMA
isFastEMAUp()   => currentFastEMA > previousFastEMA
isFastEMADown() => currentFastEMA < previousFastEMA

// Exponential Moving Average Colors
fastEMAColor = isFastEMAUp() ? upTrendColor : isFastEMADown() ? downTrendColor : sidewaysTrendColor
slowEMAColor = isSlowEMAUp() ? upTrendColor : isSlowEMADown() ? downTrendColor : sidewaysTrendColor

// Display Exponential Moving Averages
plot(useFastEMAInput ? fastEMA : na, offset=emaOffsetInput, color=fastEMAColor, title="Fast EMA", style=plot.style_line, linewidth=4)
plot(useSlowEMAInput ? slowEMA : na, offset=emaOffsetInput, color=slowEMAColor, title="Slow EMA", style=plot.style_line, linewidth=7)

// Price Trend
pricesAboveFastEMA() => low[2] > currentFastEMA and low[1] > currentFastEMA and low > currentFastEMA
pricesAboveSlowEMA() => low[2] > currentSlowEMA and low[1] > currentSlowEMA and low > currentSlowEMA
pricesBelowFastEMA() => high[2] < currentFastEMA and high[1] < currentFastEMA and high < currentFastEMA
pricesBelowSlowEMA() => high[2] < currentSlowEMA and high[1] < currentSlowEMA and high < currentSlowEMA

// Market in Bullish Trend
isBullishTrend() =>
    if useFastEMAInput and useSlowEMAInput
        pricesAboveFastEMA() and pricesAboveSlowEMA()
    else if useFastEMAInput
        pricesAboveFastEMA()
    else if useSlowEMAInput
        pricesAboveSlowEMA()
    else
        na

// Market in Bearish Trend
isBearishTrend() =>
    if useFastEMAInput and useSlowEMAInput
        pricesBelowFastEMA() and pricesBelowSlowEMA()
    else if useFastEMAInput
        pricesBelowFastEMA()
    else if useSlowEMAInput
        pricesBelowSlowEMA()
    else
        na

// Stormer Strategy (123)
isFirstCandleUp()   => high[2] > high[1] and low[2] > low[1]
isFirstCandleDown() => high[2] < high[1] and low[2] < low[1]
isThirdCandleUp()   => low > low[1]
isThirdCandleDown() => high < high[1]
isThirdCandleInsideBar() => high < high[1] and low > low[1]

// Buy Signal
isStormer123Buy() =>
    if insideBarStrategyInput
        longEntryInput and isFirstCandleUp() and isThirdCandleInsideBar() and isBullishTrend()
    else
        longEntryInput and isFirstCandleUp() and isThirdCandleUp() and isBullishTrend()

// Sell Signal
isStormer123Sell() =>
    if insideBarStrategyInput
        shortEntryInput and isFirstCandleDown() and isThirdCandleInsideBar() and isBearishTrend()
    else
        shortEntryInput and isFirstCandleDown() and isThirdCandleDown() and isBearishTrend()

// Backtest Time Period
inTradeWindow             = true
isInTradeWindow()         => inTradeWindow
isBacktestDateRangeOver() => not inTradeWindow and inTradeWindow[1]

// Backtest Price Parameters
highestPrice = ta.highest(high, 3)
lowestPrice  = ta.lowest(low,3)
priceRange   = highestPrice - lowestPrice

// Stormer Strategy (123): LONG
var myLongOrders = array.new_int(0)
longtEntryID     = "Long Entry:\n" + str.tostring(bar_index)
longExitID       = "Long Exit:\n" + str.tostring(bar_index)
stopLossInLong   = lowestPrice + 0.01
takeProfitInLong = priceRange + high

longEntryHasBeenMet = isInTradeWindow() and isBullishTrend() and isStormer123Buy()

// Scheduling LONG entry
if longEntryHasBeenMet
    array.push(myLongOrders, bar_index)
    strategy.order(longtEntryID, strategy.long, stop=high)
    strategy.exit(longExitID, longtEntryID, stop=stopLossInLong, limit=takeProfitInLong)

// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myLongOrders) == 0 ? na : array.size(myLongOrders) - 1)
    myLongOrder = array.get(myLongOrders, myOrderIndex)
    if bar_index - myLongOrder == thresholdForEntryInput
        longEntryID = "Long Entry:\n" + str.tostring(myLongOrder)
        strategy.cancel(longEntryID)

// Stormer Strategy (123): SHORT
var myShortOrders = array.new_int(0)
shortEntryID      = "Short Entry:\n" + str.tostring(bar_index)
shortExitID       = "Short Exit:\n" + str.tostring(bar_index)
stopLossInShort   = highestPrice + 0.01
takeProfitInShort = low - priceRange

shortEntryHasBeenMet = isInTradeWindow() and isBearishTrend() and isStormer123Sell()

// Scheduling SHORT entry
if shortEntryHasBeenMet
    array.push(myShortOrders, bar_index)
    strategy.order(shortEntryID, strategy.short, stop=low)
    strategy.exit(shortExitID, shortEntryID, stop=stopLossInShort, limit=takeProfitInShort)

// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myShortOrders) == 0 ? na : array.size(myShortOrders) - 1)
    myShortOrder = array.get(myShortOrders, myOrderIndex)
    if bar_index - myShortOrder == thresholdForEntryInput
        shortEntryID := "Short Entry:\n" + str.tostring(myShortOrder)
        strategy.cancel(shortEntryID)

// Close all positions at the end of the backtest period
if isBacktestDateRangeOver()
    strategy.cancel_all()
    strategy.close_all(comment="Date Range Exit")

// Display Signals
plotshape(series=longEntryHasBeenMet,  title="123 Buy",  style=shape.triangleup,   location=location.belowbar, color=buySignalColor,  text="123", textcolor=buySignalColor)
plotshape(series=shortEntryHasBeenMet, title="123 Sell", style=shape.triangledown, location=location.abovebar, color=sellSignalColor, text="123", textcolor=sellSignalColor)