
この戦略は均線指標と超トレンド指標を組み合わせて,トレンドへのフォロー操作を実現する.トレンドが上昇する時は多めに,トレンドが低下する時は空っぽにする.
負の移動平均MAを計算する.取引量を重みとして使用し,一定の周期における負の平均価格を計算する.
Hull移動平均は,価格の変化に対してより敏感である.
超トレンド指標の計算。超トレンド指標はATRと組み合わせて,価格トレンドの変化を見ることができる。上線と下線の計算。
閉盘価格が上線を超えると,多めに; 閉盘価格が下線を下回ると,空いてください.
オープン価格,クローズ価格,最高価格,最低価格などの補助指標をグラフに描き,価格の変化をより直観的に観察する.
買いと売却の意思決定を指標の交差で行う.
この戦略は,平均線指標と超トレンド指標を組み合わせて,トレンドの変化をより正確に捉えることができます.
ハル平均線は価格変化に敏感で,トレンドの転換を早期に発見するのに役立ちます.
超トレンド指標は,市場の変動に合わせて動的に上下を調整します.
補助指標は,価格の変化を直視的に表示し,指標信号と組み合わせて判断を行う.
策略パラメータの最適化スペースは広く,平均線周期,超トレンド倍数などのパラメータを調整できます.
市場を整理する際には,誤ったシグナルが生み出され,不必要な取引が起こる可能性があります.
複数の指標を同時に監視する必要があり,戦略は比較的複雑です.
異なる品種の特徴に合わせて指標パラメータを適切に調整する必要があります.
ストップ・ロスを厳格に管理し,単一の損失を過大にしないようにする.
経費の影響をコントロールする必要があります.
異なる平均線のパラメータをテストし,市場に対してより敏感な平均線指標を選択できます.
異なる超トレンドの倍数をテストし,トレンドの変化をタイムリーに捉える数値を選択できます.
波動率の指標と組み合わせて,波動が大きくなるとポジションを下げる.
突破条件が加えられ,誤信号が整合時に発生しないようにする.
ストップ・ロスの戦略を最適化して,市場特性に合わせてストップ・ロスを行う.
この戦略は,均線指標と超トレンド指標を組み合わせてトレンドの方向を判断し,トレンドをフォローする操作を行う.指標間の相互検証が可能で,より正確にトレンドを判断できるという利点がある.しかし,偽信号の干渉に注意する必要がある.パラメータ最適化とリスク制御により,戦略の効果をさらに改善することができる.この戦略は,傾向性強い品種にトレンドフォローする操作を行うのに適している.
/*backtest
start: 2022-11-07 00:00:00
end: 2023-11-13 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/
// © rajukpatel
//@version=5
strategy('My RK Strategy with Alert', shorttitle='My RK Strategy with Alert', overlay=true )
src5 = input(close)
tf = input(1440)
len5 = timeframe.isintraday and timeframe.multiplier >= 1 ? tf / timeframe.multiplier * 7 : timeframe.isintraday and timeframe.multiplier < 60 ? 60 / timeframe.multiplier * 24 * 7 : 7
ma = ta.ema(src5 * volume, len5) / ta.ema(volume, len5)
//script taken from https://www.tradingview.com/script/kChCRRZI-Hull-Moving-Average/
src1 = ma
p(src1, len5) =>
n = 0.0
s = 0.0
for i = 0 to len5 - 1 by 1
w = (len5 - i) * len5
n += w
s += src5[i] * w
s
s / n
hm = 2.0 * p(src1, math.floor(len5 / 3)) - p(src1, len5)
vhma = p(hm, math.floor(math.sqrt(len5)))
lineColor = vhma > vhma[1] ? color.lime : color.red
plot(vhma, title='VHMA', color=lineColor, linewidth=3)
hColor = true
vis = true
hu = hColor ? vhma > vhma[2] ? #00ff00 : #ff0000 : #ff9800
vl = vhma[0]
ll = vhma[1]
m1 = plot(vl, color=hu, linewidth=1, transp=60)
m2 = plot(vis ? ll : na, color=hu, linewidth=2, transp=80)
fill(m1, m2, color=hu, transp=70)
//
b = timeframe.isintraday and timeframe.multiplier >= 1 ? 60 / timeframe.multiplier * 7 : timeframe.isintraday and timeframe.multiplier < 60 ? 60 / timeframe.multiplier * 24 * 7 : 7
//
res5 = input.timeframe('D')
o = request.security(syminfo.tickerid, res5, open, barmerge.gaps_off, barmerge.lookahead_on)
c = request.security(syminfo.tickerid, res5, close, barmerge.gaps_off, barmerge.lookahead_on)
hz = request.security(syminfo.tickerid, res5, high, barmerge.gaps_off, barmerge.lookahead_on)
l = request.security(syminfo.tickerid, res5, low, barmerge.gaps_off, barmerge.lookahead_on)
col = c >= o ? color.lime : color.red
ppo = plot(b ? o >= c ? hz : l : o, color=col, title='Open', style=plot.style_stepline, transp=100)
ppc = plot(b ? o <= c ? hz : l : c, color=col, title='Close', style=plot.style_stepline, transp=100)
plot(b and hz > c ? hz : na, color=col, title='High', style=plot.style_circles, linewidth=2, transp=60)
plot(b and l < c ? l : na, color=col, title='Low', style=plot.style_circles, linewidth=2, transp=60)
fill(ppo, ppc, col, transp=90)
//
// INPUTS //
st_mult = input.float(1, title='SuperTrend Multiplier', minval=0, maxval=100, step=0.01)
st_period = input.int(50, title='SuperTrend Period', minval=1)
// CALCULATIONS //
up_lev = l - st_mult * ta.atr(st_period)
dn_lev = hz + st_mult * ta.atr(st_period)
up_trend = 0.0
up_trend := c[1] > up_trend[1] ? math.max(up_lev, up_trend[1]) : up_lev
down_trend = 0.0
down_trend := c[1] < down_trend[1] ? math.min(dn_lev, down_trend[1]) : dn_lev
// Calculate trend var
trend = 0
trend := c > down_trend[1] ? 1 : c < up_trend[1] ? -1 : nz(trend[1], 1)
// Calculate SuperTrend Line
st_line = trend == 1 ? up_trend : down_trend
// Plotting
//plot(st_line[1], color = trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend")
buy = ta.crossover(c, st_line)
sell = ta.crossunder(c, st_line)
signal = input(false)
/////////////// Plotting ///////////////
plotshape(signal and buy, style=shape.triangleup, size=size.normal, location=location.belowbar, color=color.new(color.lime, 0))
plotshape(signal and sell, style=shape.triangledown, size=size.normal, location=location.abovebar, color=color.new(color.red, 0))
if buy
strategy.entry('My Long Entry Id', strategy.long)
if sell
strategy.entry('My Short Entry Id', strategy.short)