累積段階の識別子と取引戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-20 11:29:57
タグ:

img

概要

この戦略は,移動平均値,ボリューム指標,価格動向指標を組み合わせて,蓄積段階に入る株式のタイミングを特定するための定量規則を設計する.この段階では,株式は通常価格統合と貯蔵状態にあり,低価格の良い機会を提供します.

戦略原則

この戦略は,価格動向を決定するために50日,90日,200日間の単純な移動平均値を使用する.価格が200日線を超えるとのみ購入信号が生成される.これは主要な下落傾向の不確実性をフィルター化する.

主なトレンドを判断することに加えて,戦略はトレンドを確認するために短期移動平均の順序も判断します.特に,50日線が90日線を超えているかどうかを判断します.

移動平均が主要および短期トレンドを確認する根拠に基づいて,戦略はPVTボリューム指標とMACD指標を組み合わせて蓄積特性を判断する.PVTが上昇を突破し,MACD線がシグナル線より高くなり,ボリュームが拡大するときにのみ購入信号が生成される.

利点

この戦略は,移動平均値のみを使用するのと比べて,トレンドを確認しながら,ボリュームの特徴もチェックします. これにより,蓄積段階に入るストックのタイミングをより正確に決定し,より良い入場価格を確保できます.

この戦略は,複数のタイムフレームを分析することで,中長期のトレンド判断と短期の特徴判断を組み合わせて,タイムフレームをマッチさせ,単一のタイムフレームを誤って判断する不確実性を軽減します.

リスク と 解決策

この戦略は主に移動平均判断に依存する.価格が激動すると,移動平均判断は失敗する.この時点で,ポジションサイズを減らすか,ストップロスの出口を誘発すべきである.

さらに,蓄積段階では誤った判断が起こり,逆転の機会が失われる可能性があります.これは判断を確認するためにより多くの特徴指標を観察する必要があります.

最適化 の アイデア

機械学習アルゴリズムは,特徴とモデルトレーニングを抽出して,蓄積段階の自動判断を達成することで,この戦略に導入することができます.これは手動で値設定の制限を軽減することができます.

さらに,この戦略は,ブレイクポイント機能を試して,異なる市場環境でパラメータを自動的に切り替えることもできます.

概要

概要すると,この戦略は一般的に,株蓄積段階の特徴を判断するために価格と量を一致させるというアイデアを採用している.主要な方向性を確認しながら,短期間の蓄積機会を掘り出す.パラメータ最適化と機械学習を導入することにより,戦略パフォーマンスをさらに改善する余地がある.


/*backtest
start: 2023-02-13 00:00:00
end: 2024-02-19 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © stocktechbot

//@version=5
strategy("Accumulate", overlay = true)
lookback = input(defval = 21, title = 'Lookback')
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
//SMA Tredline
out = ta.sma(close, 200)
outf = ta.sma(close, 50)
outn = ta.sma(close, 90)
outt = ta.sma(close, 21)
//sma plot
plot(out, color=color.blue, title="MA200", offset=offset)
plot(outf, color=color.maroon, title="MA50", offset=offset)
plot(outn, color=color.orange, title="MA90", offset=offset)
plot(outt, color=color.olive, title="MA21", offset=offset)

//MarketCap Calculation
//MarketCap = 0.0
//TSO = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ", ignore_invalid_symbol = true)


//if str.tostring(TSO) != 'na'
//    if ta.barssince(TSO != TSO[1] and TSO > TSO[1])==0
//        MarketCap := TSO * close
//       
//    if barstate.islast and MarketCap == 0
//        runtime.error("No MarketCap is provided by the data vendor.")
//    
//momlen = 100
//msrc = MarketCap
//mom = msrc - msrc[momlen]
//plotmom = if (mom > mom[1])
//    true
//else
//   false

//OBV with sma on macd
obv = ta.cum(math.sign(ta.change(close)) * volume)
smoothingLength = 5
smoothingLine = ta.sma(obv,5)
[macdLine, signalLine, histLine] = ta.macd(ta.pvt, 12, 26, 9)
sellvolhigh = macdLine < signalLine
buyvolhigh = macdLine > signalLine
//Buy Signal
mafentry =ta.sma(close, 50) > ta.sma(close, 90)
//matentry = ta.sma(close, 21) > ta.sma(close, 50)
matwohun = close > ta.sma(close, 200)
higheshigh = ta.rising(high, 2)
higheslow = ta.rising(low, 2 )
twohunraise = ta.rising(out, 2)
//highvol =  ta.crossover(volume, ta.sma(volume, lookback))
highvol = ta.rising(volume,2)
fourlow = ta.lowest(close, lookback)
fourhig = ta.highest(close, lookback)
change =  (((fourhig - fourlow) / fourlow) * 100) <= 30
green = close > open
allup = false
lineabove = ta.cross(close, ta.sma(close, input(defval = 21, title = 'Entry Line')))
if matwohun and mafentry and higheshigh and twohunraise and buyvolhigh
//if higheshigh and higheslow and highvol
    allup := true

plotshape(allup, style=shape.arrowup,location=location.belowbar, color=color.green, title = "Buy Signal")

barsSinceLastEntry() =>
    strategy.opentrades > 0 ? bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) : na
    
//Sell Signal
mafexit =ta.sma(close, 50) < ta.sma(close, 90)
matexit = ta.sma(close, 21) < ta.sma(close, 50)
matwohund = close < ta.sma(close, 200)
linebreak = ta.sma(close, input(defval = 21, title = 'Exit Line')) > close
lowesthigh = ta.falling(high, 3)
lowestlow = ta.falling(low, 2 )
twohunfall = ta.falling(out, 3)
twentyfall = ta.falling(outt, 2)
highvole =  ta.crossover(volume, ta.sma(volume, 5))
//fourlow = ta.lowest(close, lookback)
//fourhig = ta.highest(close, lookback)
changed =  (((fourhig - close) / close) * 100) >= 10
red = close < open
atr = ta.atr(14)
//atrsmalen = int(bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) )
atrsmalen = barsSinceLastEntry()
atrsma = false
atrlen = 5
if str.tostring(atrsmalen) != 'NaN' and atrsmalen > 0
    atrlen := atrsmalen

    
atrsma := atr > ta.sma(atr,50)


alldwn = false
if sellvolhigh and lowestlow and (close < close[1] and close < open)
//if higheshigh and higheslow and highvol
    alldwn := true

plotshape(alldwn, style=shape.arrowdown,location=location.abovebar, color=color.red, title = "Sell Signal")


longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (allup)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (alldwn)
    strategy.entry("My Short Entry Id", strategy.short)


もっと