雄牛と熊の力 バックテスト戦略

作者: リン・ハーンチャオチャン,日付: 2023年10月24日 16時43分52秒
タグ:

img

概要

ブール&ベアパワー戦略は,市場における買取・販売圧力を測定するためにエルダー線指標を用いて,アレキサンダー・エルダー博士によって開発された.エルダー線は,しばしばトリプルスクリーンシステムと使用されますが,単独でも使用できます.

エルダー博士は13期指数関数移動平均 (EMA) を用いて,市場のコンセンサス値を示します. ブールパワーでは,購入者がコンセンサス値以上の価格を押し上げる能力を測定します.ベアパワーでは,売り手が平均コンセンサス値以下の価格を押し上げる能力を反映しています.

ブールパワーは高値から13期間のEMAを引いて計算される.ベアパワーは低値から13期間のEMAを引いて計算される.

戦略の論理

この戦略は,牛と熊の指標を計算して市場情勢を判断します.

  1. 13 期間の EMA を市場価値の合意として計算する
  2. 高値マイナス13期EMAを計算する
  3. 低マイナス13期EMAを計算する.
  4. 長信号と短信号を決定するために,ブールパワーとベアパワーと値を比較します.
  5. リバース・シグナル取引のオプション

トールパワーが値を超えると,それはロング・シグナルです.ベアパワーが値を超えると,それはショート・シグナルです.逆取引を選択できます.

利点分析

  1. 市場情勢を判断するために,牛と熊のパワー指標を使用し,シンプルで直感的な
  2. パラメータの柔軟な設定,調整可能な限界値と期間
  3. リバース・トレードオプションは,異なる市場環境に適応します.
  4. 指数的な移動平均値を使用し,異常値に敏感ではない.

リスク分析

  1. 誤った信号に敏感で,トレンドと他のフィルタを組み合わせる必要がある
  2. 固定期間は市場の変化に適応できないが,適応期間は最適化できる
  3. ストップ・ロスはなく,大きな損失で簡単に市場を追いかける
  4. 判定は長か短か タイミングの選択がない

ストップ・ロスを追加し,移動平均期を最適化し,トレンドフィルターなどと組み合わせることができます.

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

  1. 移動平均期を最適化し,適応期 EMA を使用する
  2. 逆トレンド取引を避けるためにトレンドフィルターを追加する
  3. 単一の取引損失を制御するためにストップロスを追加する
  4. 他の指標を組み合わせて,より良いエントリータイミングを選択する
  5. パラメータを最適化するために機械学習を利用する

結論

ブル&ベアパワー戦略は,設定可能なパラメータを使用して,市場情勢を単純で直感的に判断します. しかし,それは誤った信号に易しく,トレンドとストップロスのさらなる最適化が必要です.論理は学ぶ価値がありますが,直接的な適用は注意が必要です.


/*backtest
start: 2023-09-23 00:00:00
end: 2023-10-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version = 2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 08/12/2016
// Developed by Dr Alexander Elder, the Elder-ray indicator measures buying 
// and selling pressure in the market. The Elder-ray is often used as part 
// of the Triple Screen trading system but may also be used on its own.
// Dr Elder uses a 13-day exponential moving average (EMA) to indicate the 
// market consensus of value. Bull Power measures the ability of buyers to 
// drive prices above the consensus of value. Bear Power reflects the ability 
// of sellers to drive prices below the average consensus of value.
// Bull Power is calculated by subtracting the 13-day EMA from the day's High. 
// Bear power subtracts the 13-day EMA from the day's Low.
//
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
////////////////////////////////////////////////////////////
strategy(title="Elder Ray (Bull Power) Strategy Backtest")
Length = input(13, minval=1)
Trigger = input(0)
reverse = input(false, title="Trade reverse")
hline(0, color=purple, linestyle=line)
xPrice = close
xMA = ema(xPrice,Length)
DayHigh = iff(dayofmonth != dayofmonth[1], high, max(high, nz(DayHigh[1])))
nRes = DayHigh - xMA
pos = iff(nRes > Trigger, 1,
	   iff(nRes < Trigger, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
         iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(nRes, color=blue, title="Bull Power", style = histogram)

もっと