Strategi Penembusan Trend Berdasarkan MA dan Trendlines yang Sesuai

Penulis:ChaoZhang, Tarikh: 2023-09-19 15:49:37
Tag:

Ringkasan

Strategi ini menggunakan purata bergerak adaptif dan trendline breakout untuk entri, dan RSI untuk keluar.

Logika Strategi

  1. Mengira MA adaptif 99-periode untuk menentukan trend keseluruhan.

  2. Mengira 14 tempoh tertinggi tempatan untuk rintangan trendline atas.

  3. Pergi panjang apabila hampir pecah di atas trendline dan tiada pesanan bulan ini.

  4. Mengira RSI 14 tempoh dan keluar pada RSI lebih daripada 70 (terlampau dibeli).

  5. Mengesan bulan masuk terakhir untuk memastikan satu perdagangan sebulan.

Analisis Kelebihan

  1. MA adaptif secara dinamik mengesan perubahan trend.

  2. Penembusan trendline meningkatkan ketepatan kemasukan.

  3. RSI menilai tahap overbought / oversold untuk kawalan risiko.

  4. Satu perdagangan sebulan mengurangkan kekerapan dan yuran.

  5. Logik yang mudah dan jelas, mudah difahami dan dilaksanakan.

Analisis Risiko

  1. Parameter yang tidak betul boleh menyebabkan entri yang terlepas.

  2. Penunjuk keluar tetap tidak dapat menyesuaikan diri dengan masa dengan pasaran.

  3. Kemungkinan pengeluaran.

  4. Tiada kawalan risiko untuk tempoh penahan yang panjang.

  5. Terlalu banyak penapis boleh menghalang kemasukan.

Arahan pengoptimuman

  1. Uji parameter yang berbeza untuk tetapan optimum.

  2. Tambah penapis untuk meningkatkan kekuatan strategi.

  3. Membangunkan strategi berhenti yang dinamik dan berturut-turut.

  4. Mengoptimumkan logik kemasukan untuk mengenal pasti pelarian yang lebih kuat.

  5. Uji instrumen dan jangka masa yang sesuai.

  6. Tambah penapis trend untuk mengelakkan pecah palsu.

Ringkasan

Strategi ini mengintegrasikan analisis trend dan osilator untuk kesan trend yang berterusan. pengoptimuman lebih lanjut pada parameter, keluar dinamik dan lain-lain boleh menjadikannya sistem kuant yang boleh dipercayai. Secara keseluruhan ia mempunyai operasi yang baik dan bernilai peningkatan dan pengesahan.


/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-18 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Bannos Strategy', shorttitle='Bannos', overlay=true)

//The provided script is an indicator for TradingView written in Pine Script version 5. The indicator is used to determine entry and exit points for a trading strategy. Here's a detailed breakdown of what the script does:

// Strategy Definition:

// Bannos Strategy is the full name, with a short title Bannos.
// The overlay=true option indicates that the strategy will be overlayed on the price chart.
// Tracking Entry Month:

// A variable lastEntryMonth is set up to track the month of the last entry.
// currentMonth identifies the current month.
// Trend Regularity Adaptive Moving Average (TRAMA):

// It takes an input of length 99 as default.
// It uses adaptive calculations to track trend changes.
// Trendlines with Breaks:

// Identifies local peaks over a given period (in this case, 14) and calculates a slope based on these peaks.
// Relative Strength Index (RSI):

// Uses a length of 14 (default) to calculate the RSI.
// RSI is an oscillation indicator that indicates overbought or oversold conditions.
// Strategy Logic for Long Entry:

// A long position is opened if:
// The close price is above the TRAMA.
// There's a crossover of the close price and the upper trendline.
// The position is taken only once per month.
// Strategy Logic for Long Exit:

// The long position is closed if the RSI exceeds 70, indicating an overbought condition.
// Plotting:

// The TRAMA is plotted in red on the chart.
// A horizontal line is also drawn at 70 to indicate the RSI's overbought zone.
// In summary, this strategy aims to enter a long position when certain trend and crossover conditions are met, and close the position when the market is considered overbought as per the RSI. Additionally, it ensures entries only occur once a month.
//



// Variable pour suivre le mois de la dernière entrée
var float lastEntryMonth = na
currentMonth = month(time)

// Parameters for Trend Regularity Adaptive Moving Average (TRAMA)
length_trama = input(99)
src_trama = close
ama = 0.
hh = math.max(math.sign(ta.change(ta.highest(length_trama))), 0)
ll = math.max(math.sign(ta.change(ta.lowest(length_trama)) * -1), 0)
tc = math.pow(ta.sma(hh or ll ? 1 : 0, length_trama), 2)
ama := nz(ama[1] + tc * (src_trama - ama[1]), src_trama)

// Parameters for Trendlines with Breaks
length_trend = 14
mult = 1.0
ph = ta.pivothigh(length_trend, length_trend)
upper = 0.
slope_ph = 0.
slope_ph := ph ? mult : slope_ph
upper := ph ? ph : upper - slope_ph

// Parameters for RSI
rsiLength = 14
up = ta.rma(math.max(ta.change(close), 0), rsiLength)
down = ta.rma(-math.min(ta.change(close), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

// Strategy Logic for Long Entry
longCondition = close > ama and ta.crossover(close, upper) and (na(lastEntryMonth) or lastEntryMonth != currentMonth)
if (longCondition)
    lastEntryMonth := currentMonth
    strategy.entry('Long', strategy.long)

// Strategy Logic for Long Exit
exitCondition = rsi > 70
if (exitCondition)
    strategy.close('Long')

// Plotting
plot(ama, 'TRAMA', color=color.red)
hline(70, 'Overbought', color=color.red)


Lebih lanjut