アダプティブMAとトレンドラインに基づくトレンドブレイク戦略

作者: リン・ハーンチャオチャン開催日:2023年9月19日 15:49:37
タグ:

概要

この戦略は,エントリーに適応型移動平均値とトレンドラインブレイクアウト,出口にRSIを使用します.条件を満たしたときにトレンドに入力し,過剰購入レベルで利益を得,月に1回の取引に制限することを目指しています.

戦略の論理

  1. 総動向を決定するために 99 期間の適応型 MA を計算する.

  2. トレンドライン上部のレジスタンスの 14 期間のローカル・ハイを計算します

  3. トレンドラインの上を 接近し,今月オーダーがない場合

  4. RSIが70以上 (過買い) で終了する 14期間のRSIを計算します.

  5. 毎月1つの取引を確保するために最後のエントリー月を追跡します.

利点分析

  1. アダプティブMAは動的にトレンド変化を追跡します

  2. トレンドラインの突破は 入力の精度を向上させる

  3. RSIはリスク管理のために過剰購入/過剰販売レベルを効果的に判断します

  4. 毎月1回の取引で 頻度と手数料が減ります

  5. シンプルで明快な論理で 分かりやすく実行できます

リスク分析

  1. 誤ったパラメータが 誤ったエントリを引き起こす可能性があります

  2. 固定出口指標は 市場に適したタイミングで適応できない.

  3. 引き上げの可能性

  4. 長期保持期間におけるリスク管理がない.

  5. フィルタが多すぎると 入力が妨げられます

オプティマイゼーションの方向性

  1. 最適な設定のために異なるパラメータをテストします.

  2. 戦略の安定性を高めるためにフィルターを追加します

  3. ダイナミックなストップ戦略を 開発する

  4. 侵入ロジックを最適化して より強い脱出を特定する

  5. 適した機器と時間枠をテストする

  6. トレンドフィルターを追加して 偽のブレイクを避ける

概要

この戦略は,トレンド分析とオシレーターを統合して安定したトレンドフォロー効果をもたらす.パラメータ,ダイナミック出口等をさらに最適化することで,信頼性の高い量子システムになることができる.全体的に,良好な操作性があり,改善と検証に値する.


/*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)


もっと