Strategi ini disebut
Strategi ini terutama bergantung pada indikator Bollinger Bands untuk menentukan tren harga dan titik masuk.
Ketika harga pecah ke atas dari garis bawah melalui garis atas, tren bullish diidentifikasi. Ketika harga pecah ke bawah dari garis atas melalui garis bawah, tren bearish telah dimulai. Strategi masuk panjang atau pendek pada terjadinya kedua jenis pecah ini.
Secara khusus, logika strategi adalah:
Untuk menghindari kebocoran palsu, filter rata-rata bergerak ditambahkan.
Di sini Rata-rata Gerak Eksponensial digunakan sebagai indikator.
Singkatnya, kriteria untuk menentukan trend breakout adalah:
Setelah masuk, stop loss melacak garis tengah. keluar ketika harga menyentuh garis tengah lagi.
Kekuatan utama dari strategi ini meliputi:
Meskipun ada keuntungan, strategi ini juga membawa risiko berikut:
Untuk mengendalikan risiko di atas, optimasi berikut dapat dilakukan:
Berdasarkan analisis risiko, optimasi lebih lanjut dapat dilakukan di bidang berikut:
Optimasi Parameter: Gunakan metode yang lebih sistematis seperti algoritma genetik untuk menemukan kombinasi parameter optimal untuk Band dan moving average, untuk membuat strategi lebih stabil dan menguntungkan.
Optimasi Stop Loss: Uji teknik stop loss yang berbeda seperti ATR stop, trailing stop dll, untuk menentukan mekanisme stop terbaik.
Optimasi Filter: Coba tambahkan indikator lain seperti RSI, KD dll sebagai filter tambahan, untuk menurunkan probabilitas sinyal palsu dan meningkatkan tingkat profitabilitas.
Optimasi Kriteria Masuk: Tambahkan pertimbangan lain seperti kondisi tren, volume abnormal dll untuk memilih waktu masuk secara ketat, menghindari entri yang tidak perlu.
Pembelajaran Mesin: Mengumpulkan lebih banyak data historis untuk membangun LSTM, RNN dan model pembelajaran mendalam lainnya, sehingga memungkinkan waktu masuk dan keluar terbaik yang didukung AI.
Manajemen risiko-imbalan yang dinamis: Menggabungkan berhenti rasio tetap, target keuntungan lonjakan setelah mencapai tingkat keuntungan tertentu dll untuk secara dinamis mengendalikan risiko-payoff.
Melalui optimasi di bidang di atas, metrik kunci seperti stabilitas, profitabilitas, kemampuan penyesuaian risiko dapat ditingkatkan secara komprehensif, mengubah strategi menjadi algoritma tingkat produksi yang cocok untuk perdagangan langsung.
Kesimpulannya,
/*backtest start: 2023-12-15 00:00:00 end: 2024-01-14 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //VERSION ================================================================================================================= //@version=5 // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // This strategy is intended to study. // It can also be used to signal a bot to open a deal by providing the Bot ID, email token and trading pair in the strategy settings screen. // As currently written, this strategy uses a Bollinger Bands for trend folling, you can use a EMA as a filter. //Autor Credsonb (M4TR1X_BR) //▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ //STRATEGY ================================================================================================================ strategy(title = 'BT-Bollinger Bands - Trend Following', shorttitle = 'BBTF', overlay = true ) //▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // CONFIG ================================================================================================================= // TIME INPUTS usefromDate = input.bool(defval = true, title = 'Start date', inline = '0', group = "Time Filters") initialDate = input(defval = timestamp('01 Jan 2022 00:00 UTC'), title = '', inline = "0",group = 'Time Filters',tooltip="This start date is in the time zone of the exchange ") usetoDate = input.bool(defval = true, title = 'End date', inline = '1', group = "Time Filters") finalDate = input(defval = timestamp('31 Dec 2029 23:59 UTC'), title = '', inline = "1",group = 'Time Filters',tooltip="This end date is in the time zone of the exchange") // TIME LOGIC inTradeWindow = true // ENABLE LONG SHORT OPTIONS string entrygroup ='Long/Short Options ===================================' checkboxLong = input.bool(defval=true, title="Enable Long Entrys",group=entrygroup) checkboxShort = input.bool(defval=true, title="Enable Short Entrys",group=entrygroup) // BOLLINGER BANDS INPUTS ================================================================================================== string bbgroup ='Bollinger Bands ======================================' bbLength = input.int(defval=20,title='BB Length', minval=1, step=5, group=bbgroup) bbStddev = input.float(defval=2, title='BB StdDev', minval=0.5, group=bbgroup) //BOLLINGER BANDS LOGIC [bbMiddle, bbUpper, bbLower] = ta.bb(close, bbLength, bbStddev) // MOVING AVERAGES INPUTS ================================================================================================ string magroup = 'Moving Average =======================================' useEma = input.bool(defval = true, title = 'Moving Average Filter',inline='', group= magroup,tooltip='This will enable or disable Exponential Moving Average Filter on Strategy') emaType=input.string (defval='Ema',title='Type',options=['Ema','Sma'],inline='', group= magroup) emaSource = input.source(defval=close,title=" Source",inline="", group= magroup) emaLength = input.int(defval=100,title="Length",minval=0,inline='', group= magroup) // MOVING AVERAGE LOGIC float ema = emaType=='Ema'? ta.ema(emaSource,emaLength): ta.sma(emaSource,emaLength) // BOT MESSAGES string msgroup='Alert Message For Bot ================================' messageEntry = input.string("", title="Strategy Entry Message",group=msgroup) messageExit =input.string("",title="Strategy Exit Message",group=msgroup) messageClose = input.string("", title="Strategy Close Message",group=msgroup) // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // POSITIONS ============================================================================================================= //VERIFY IF THE BUY FILTERS ARE ON OR OFF bool emaFilterBuy = useEma? (close > ema):(close >= ema) or (close <= ema) //LONG / SHORT POSITIONS LOGIC bool openLongPosition = (close[1] < bbUpper) and (close > bbUpper) and (emaFilterBuy) bool openShortPosition = (close[1] > bbLower) and (close < bbLower) and (emaFilterBuy) //bool closeLongPosition = (close > bbMiddle) //bool closeShortPosition= (close < bbLower) // CHEK OPEN POSITONS ===================================================================================================== // open signal when not already into a position bool validOpenLongPosition = openLongPosition and strategy.opentrades.size(strategy.opentrades - 1) <= 0 bool longIsActive = validOpenLongPosition or strategy.opentrades.size(strategy.opentrades - 1) > 0 bool validOpenShortPosition = openShortPosition and strategy.opentrades.size(strategy.opentrades - 1) <= 0 bool shortIsActive = validOpenShortPosition or strategy.opentrades.size(strategy.opentrades - 1) < 0 longEntryPoint = high if (openLongPosition) and (inTradeWindow) and (checkboxLong) strategy.entry(id = 'Long Entry', direction = strategy.long, stop = longEntryPoint, alert_message=messageEntry) if not (openLongPosition) strategy.cancel('Long Entry') //submit exit orders for trailing take profit price if (longIsActive) and (inTradeWindow) strategy.exit(id = 'Long Exit', stop=bbMiddle, alert_message=messageExit) //if (closeLongPosition) // strategy.close(id = 'Long Entry', alert_message=messageClose) shortEntryPoint = low if (openShortPosition) and (inTradeWindow) and (checkboxShort) strategy.entry(id = 'Short Entry', direction = strategy.short, stop = shortEntryPoint, alert_message=messageEntry) if not(openShortPosition) strategy.cancel('Short Entry') if (shortIsActive) strategy.exit(id = 'Short Exit', stop = bbMiddle, alert_message=messageExit) //if (closeShortPosition) //strategy.close(id = 'Short Close', alert_message=messageClose) // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // PLOTS =============================================================================================================== // TRADE WINDOW ======================================================================================================== bgcolor(color = inTradeWindow ? color.new(#089981,90):na, title = 'Time Window') // EMA/SMA var emafilterColor = color.new(color.white, 0) plot(series=useEma? ema:na, title = 'EMA Filter', color = emafilterColor, linewidth = 2, style = plot.style_line) // BOLLINGER BANDS plot(series=bbUpper, title = "Upper Band", color = color.aqua)//, display = display.none) plot(series=bbMiddle, title = "MA Band", color = color.red)//, display = display.none) plot(series=bbLower, title = "Lower Band", color = color.aqua)//, display = display.none) // PAINT BARS COLORS bool bulls = (close[1] < bbUpper[1]) and (close > bbUpper) bool bears = (close[1] > bbLower [1]) and (close < bbLower) neutral_color = color.new(color.black, 100) barcolors = bulls ? color.green : bears ? color.red : neutral_color barcolor(barcolors) // ======================================================================================================================