歴史的データに基づく動的サポートと抵抗戦略

作者: リン・ハーンチャオチャン開催日:2023年11月28日 17:00:13
タグ:

img

概要

この戦略は,歴史的な高値,低値,閉値に基づいてサポートとレジスタンスレベルを動的に計算し,それに応じて取引信号を生成する.中長期のポジションに適しており,市場におけるサポートとレジスタンスレベルを効果的に利用して利益を得ることができます.

戦略の論理

  1. 前期高値,低値,閉値の平均をピボットポイント (PP) として計算する.

  2. 3 つのサポートラインを計算します: S1 = 2PP - 最高価格 S2 = PP - (R1-S1) S3 = 最低価格 - 2(最高価格 - PP)

  3. 3つの抵抗線を計算します R1 = 2PP - 最低価格; R2 = PP + (R1-S1); R3 = 最高価格 + 2(PP - 最低価格)

  4. 価格がサポートラインを突破したときのショートポジションです.

利点分析

  1. 過去データに基づく動的サポートとレジスタンスレベルは,市場の構造の変化を迅速に把握することができます.

  2. 多層のサポートとレジスタンス設定により,リスク管理の最適化が可能です.

  3. シンプルで直感的な取引シグナルとストップ・ロスのメカニズム

リスク分析

  1. 過去のデータから得られる基準価格レベルは,高い変動シナリオでは無効になる可能性があります.

  2. ロングとショートポジションの切り替えには,取引コストを考慮する必要があります.

  3. 計算の誤りを避けるためにデータ品質を保証する必要があります.

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

  1. 100日移動平均などなど,より多くの歴史的なデータ参照を組み込むことを検討します.

  2. ポジションサイズを最適化し,例えば波動性に基づいてポジションサイズを調整する.

  3. リスクベースのストップ・ロスのようにストップ・ロスを追加します

概要

この戦略は,歴史に基づく多層のサポートとレジスタンス基準価格レベルを提供します.中期から長期のポジションに適したシンプルで直接的な論理を持っています.一方,高変動市場および取引コストの下でのリスクは監視されるべきです.さらなる最適化は複雑な環境下で戦略を堅牢にすることができます.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 09/06/2020
// Pivot points simply took the high, low, and closing price from the previous period and 
// divided by 3 to find the pivot. From this pivot, traders would then base their 
// calculations for three support, and three resistance levels. The calculation for the most 
// basic flavor of pivot points, known as ‘floor-trader pivots’, along with their support and 
// resistance levels.
//
// WARNING:
//  - For purpose educate only
//  - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Pivot Point V2", shorttitle="Pivot Point V2", overlay = true)
res = input(title="Resolution", type=input.resolution, defval="D")
SellFrom = input(title="Sell from ", defval="R1", options=["R1", "R2", "R3"])
BuyFrom = input(title="Buy from ", defval="S1", options=["S1", "S2", "S3"])
width = input(1, minval=1)
reverse = input(false, title="Trade reverse")
xHigh  = security(syminfo.tickerid,res, high)
xLow   = security(syminfo.tickerid,res, low)
xClose = security(syminfo.tickerid,res, close)
vPP = (xHigh+xLow+xClose) / 3
vS1 = 2*vPP - xHigh 
vR1 = 2*vPP-xLow
vS2 = vPP - (vR1 - vS1)
vR2 = vPP + (vR1 - vS1)
vS3 = xLow - 2 * (xHigh - vPP)
vR3 = xHigh + 2 * (vPP - xLow) 
pos = 0
S = iff(BuyFrom == "S1", vS1, 
      iff(BuyFrom == "S2", vS2,
         iff(BuyFrom == "S3", vS3,0)))
B = iff(SellFrom == "R1", vR1, 
      iff(SellFrom == "R2", vR2,
         iff(SellFrom == "R3", vR3,0)))
pos := iff(close > B, 1,
       iff(close < S, -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)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )

もっと