双方向の逆転戦略


作成日: 2023-09-21 16:40:01 最終変更日: 2023-09-21 16:40:01
コピー: 0 クリック数: 606
1
フォロー
1617
フォロワー

概要

この戦略は双均線の金叉死叉原理に基づいて設計されている.短期均線に長期均線を穿うとき,多行し,短期均線の下に長期均線を穿うとき,平行する.この戦略は簡単で理解しやすく,初心者学習に適している.

戦略原則

この戦略は主に sma ((close, 14) と sma ((close, 28) の2つの平均線指標に基づいています.

長い平均線を定義する.

short_ma = sma(close, 14)
long_ma = sma(close, 28)

ゴルフ・オブ・ゴールド・フォークの判断で入場した選手は,

longCondition = crossover(short_ma, long_ma)
shortCondition = crossunder(short_ma, long_ma)

短期平均線を長期平均線にすると,

strategy.entry("Buy", strategy.long, when = longCondition) 

短期平均線の下から長期平均線を通過する際の平仓:

strategy.close_all(when = shortCondition)

この戦略の原理はシンプルで,双均線の金叉死叉を用いて判断し,ある種のトレンド追跡能力を持っている.

優位分析

  • 戦略はシンプルで,初心者でも使いやすい.
  • 平均線を使ってトレンドを判断し,ある程度のトレンド追跡能力を持つ.
  • カスタマイズ可能な平均線周期,最適化策略パラメータ
  • ストップポイントを設定して,単一損失を制御します.

リスク分析

  • 市場変動に敏感で,多発的な損益取引を起こす可能性のある二重均線戦略
  • 平均線は遅滞しており,価格転換点を逃している可能性があります.
  • 平均線交差点に近いポジションは 囚われやすい
  • 均線周期パラメータを最適化する必要があり,異なる周期効果には違いがある
  • トレンドが激しく変化する時に, 迅速に止まらない.

最適化の方向

この戦略は以下の点で最適化できます.

  1. 均線周期パラメータを最適化し,最適なパラメータの組み合わせを探す

異なる短期および長期の平均線周期を試して,最適な組み合わせを探せます.例えば (5, 10), ((10, 20), ((20, 60)) などのパラメータ対比テストです.

  1. フィルタリング条件を増やして 偽信号を回避する

平均線交差時に取引量や差差などのフィルタリング条件を追加して,波動的な市場で過剰な取引を避けることができます.

  1. ストップ・ロスの策略を増やす

ストップポイントを設定するか,均線をストップラインとして使用することで,単一損失を制御できます.

  1. 他の指標と組み合わせた

MACD,KDJなどの補助指標を組み合わせて,戦略の効果を高める.

  1. 入場ポイントの最適化

平均線の近くでよりよい入場点を探し,平均線に緊密にポジションを確立するよりも.例えば,平均線から離れている点での入場場所.

要約する

双均線戦略の概念はシンプルで,初心者は使いやすい。しかし,この戦略は市場の揺れに敏感であり,一定損失のリスクがある。戦略の効果を,パラメータを最適化,フィルタリング条件を追加,ストップを設定し,その他の指標を加えるなどによって向上させることができます。強いトレンドでは,この戦略は良い効果を得ることができます。しかし,市場の揺れ期には,慎重に使用するか,ストップを制御するリスクが推奨されます。

||

Overview

This strategy is designed based on the golden cross and death cross of dual moving averages. It goes long when the short period moving average crosses above the long period moving average, and closes position when the short period moving average crosses below the long period moving average. The strategy is simple and easy to understand, suitable for beginners to learn.

Strategy Logic

The strategy is mainly based on the sma(close, 14) and sma(close, 28) indicators.

First define the short and long moving averages:

short_ma = sma(close, 14)  
long_ma = sma(close, 28)

Then determine entry and exit based on golden cross and death cross:

longCondition = crossover(short_ma, long_ma)
shortCondition = crossunder(short_ma, long_ma) 

Go long when the short MA crosses above the long MA:

strategy.entry("Buy", strategy.long, when = longCondition)

Close position when the short MA crosses below the long MA:

strategy.close_all(when = shortCondition) 

The logic is simple and clear, utilizing the crossovers of dual MAs to determine entries and exits. It has some trend following capacity.

Advantage Analysis

  • Simple logic, easy for beginners to use
  • Utilizes MA crossovers to determine trends
  • Customizable MA periods for parameter optimization
  • Allows stop loss to control single trade loss

Risk Analysis

  • Sensitive to market fluctuation, may generate multiple losing trades
  • Lagging nature of MAs, may miss price reversal points
  • Prone to being trapped near MA crossover points
  • Need to optimize MA periods, different periods may lead to different results
  • Unable to quickly cut loss when trend changes violently

Optimization Directions

The strategy can be optimized in the following aspects:

  1. Optimize MA periods to find the best combination

Test different short and long MA periods, such as (5, 10), (10, 20), (20, 60) etc to find the optimal combination.

  1. Add filters to avoid false signals

Add filters like trading volume, price gap etc. near MA crossovers to avoid excessive trades in ranging markets.

  1. Incorporate stop loss

Set stop loss price or use MA as stop loss line to control single trade loss.

  1. Combine with other indicators

Add auxiliary indicators like MACD, KDJ etc. to improve strategy performance.

  1. Optimize entry points

Find better entry points near MAs instead of entering right at the crossover. For example, enter on MA divergence points.

Summary

The dual MA strategy is simple for beginners to use. But it is sensitive to market fluctuations and has risks of losses. We can improve it by optimizing parameters, adding filters, incorporating stop loss, combining other indicators etc. It can perform well in strong trends but should be used with caution or proper stop loss in ranging markets.
[/trans]

ストラテジーソースコード
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

//@version=2
// strategy("Tester", pyramiding = 50, default_qty_type = strategy.cash, default_qty_value = 20, initial_capital = 2000, commission_type = strategy.commission.percent, commission_value = 0.25)

minGainPercent = input(0.6)
gainMultiplier = minGainPercent * 0.01 + 1


longCondition = crossover(sma(close, 14), sma(close, 28))
shortCondition = crossunder(sma(close, 14), sma(close, 28))


avg_protection = input(1)
gain_protection = input(1)


strategy.entry("Buy", strategy.long, when = longCondition    and (avg_protection >= 1 ? (na(strategy.position_avg_price) ? true : close <= strategy.position_avg_price) : true))
strategy.close_all(when = shortCondition  and (gain_protection >=1 ? (close >= gainMultiplier * strategy.position_avg_price) : true))