
この策略は,色の閃電と呼ばれるもので,3つの移動平均に基づいてトレンドフォロー策略である.それは,快線,中線,および遅線の交差を計算して価格の傾向を判断し,ATR値でターゲット価格とストップ価格を設定する.
この戦略は以下の3つの移動平均を使用しています.
快線上を中線,中線上を遅線上を穿ったとき,判断は多傾向として;快線下を中線下を穿ったとき,中線下を遅線下を穿ったとき,判断は空頭傾向として.
この戦略は,一部のノイズ取引をフィルタリングするために,いくつかの補助条件を設定しています.
これらの条件を満たす場合,多額または空白の信号が発せられます. 一度に1つのポジションしか持っていないので,平仓または停止後に再びポジションを開くことができます.
ターゲット価格とストップ価格はATR値に基づいて一定の倍数で設定されます.
この戦略の利点は以下の通りです.
この戦略には以下のリスクもあります.
リスクを制御するために,移動平均のパラメータを適切に調整し,ATRの倍数を最適化し,単一の損失を過大にしないように最大保有時間を設定することをお勧めします.
この戦略は以下の点で最適化できます.
この戦略は,全体として安定したトレンドフォロー戦略である.それは,主に移動平均を判断してトレンドの方向を判断し,特定の技術指標群が協力して,部分的なノイズをフィルタリングすることができます.さらに最適化の余地があるが,全体的なリスクは制御可能であり,中長線トレンドフォローに適した投資である.
/*backtest
start: 2024-01-02 00:00:00
end: 2024-02-01 00:00:00
period: 2h
basePeriod: 15m
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/
// © greenmask9
//@version=4
strategy("Dazzling Bolts", overlay=true)
//max_bars_back=3000
// 13 SMMA
len = input(10, minval=1, title="SMMA Period")
src = input(close, title="Source")
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len
// 55 EMA
emalength = input(55, title="EMA Period")
ema = ema(close, emalength)
// 100 SMA
smalength = input(110, title="SMA Period")
sma = sma(close, smalength)
emaforce = input(title="Force trend with medium EMA", type=input.bool, defval=true)
offsetemavalue = input(defval = 6)
bullbounce = smma>ema and ema>sma and low[5]>ema and low[2]<ema and close[1]>ema and (ema[offsetemavalue]>sma or (not emaforce))
bearbounce = smma<ema and ema<sma and high[5]<ema and high[2]>ema and close[1]<ema and (ema[offsetemavalue]<sma or (not emaforce))
plotshape(bullbounce, title= "Purple", location=location.belowbar, color=#ff33cc, transp=0, style=shape.triangleup, size=size.tiny, text="Bolts")
plotshape(bearbounce, title= "Purple", location=location.abovebar, color=#ff33cc, transp=0, style=shape.triangledown, size=size.tiny, text="Bolts")
strategy.initial_capital = 50000
ordersize=floor(strategy.initial_capital/close)
longs = input(title="Test longs", type=input.bool, defval=true)
shorts = input(title="Test shorts", type=input.bool, defval=true)
atrlength = input(title="ATR length", defval=12)
atrm = input(title="ATR muliplier",type=input.float, defval=2)
atr = atr(atrlength)
target = close + atr*atrm
antitarget = close - (atr*atrm)
//limits and stop do not move, no need to count bars from since
bullbuy = bullbounce and longs and strategy.opentrades==0
bb = barssince(bullbuy)
bearsell = bearbounce and shorts and strategy.opentrades==0
bs = barssince(bearsell)
if (bullbuy)
strategy.entry("Boltsup", strategy.long, ordersize)
strategy.exit ("Bolts.close", from_entry="Boltsup", limit=target, stop=antitarget)
if (crossover(smma, sma))
strategy.close("Boltsup", qty_percent = 100, comment = "Bolts.crossover")
if (bearsell)
strategy.entry("Boltsdown", strategy.short, ordersize)
strategy.exit("Bolts.close", from_entry="Boltsdown", limit=antitarget, stop=target)
if (crossunder(smma, sma))
strategy.close("Boltsdown", qty_percent = 100, comment = "Bolts.crossover")
// if (bb<5)
// bulltarget = line.new(bar_index[bb], target[bb], bar_index[0], target[bb], color=color.blue, width=2)
// bullclose = line.new(bar_index[bb], close[bb], bar_index[0], close[bb], color=color.blue, width=2)
// bullstop = line.new(bar_index[bb], antitarget[bb], bar_index[0], antitarget[bb], color=color.blue, width=2)
// if (bs<5)
// bulltarget = line.new(bar_index[bs], antitarget[bs], bar_index[0], antitarget[bs], color=color.purple, width=2)
// bullclose = line.new(bar_index[bs], close[bs], bar_index[0], close[bs], color=color.purple, width=2)
// bullstop = line.new(bar_index[bs], target[bs], bar_index[0], target[bs], color=color.purple, width=2)