
この戦略は,トレンドの方向と多空のタイミングを識別するために2つの均線指標を使用する. ゆっくりとした均線 (青い線) は,全体的なトレンドの方向を判断するために使用され,急速な均線 (赤い線) は,価格チャネルと組み合わせて,多空のタイミングを検出するために使用されます.
ゆっくりと2つの平均線を計算する. ゆっくりと平均線の周期は21で,全体的なトレンドを判断する. 速く平均線の周期は5で,価格チャネルと結合して,取引のタイミングを発見する.
現在の価格が前の周期の価格チャネルを突破したかどうかを計算します. 価格がチャネルを突破した場合は,取引の機会と見なします.
K線の方向と数を計算する.最後のN根K線が陰線であれば,多時可能;最後のN根K線が陽線であれば,空時可能.Nの数は,Barsパラメータで設定する.
上記のいくつかの要素を統合して,多空信号を発出する. 動きが遅い平均線方向と一致し,速い平均線または価格チャネルが信号を発出し,K線も条件を満たしている場合は,取引信号を発出する.
ツイン・均線システムを使用し,トレンドの方向を効果的に追跡できます.
価格チャネルと高速均線の組み合わせにより,ブレイクポイントを早期に発見し,取引のタイミングを把握できます.
また,K線の方向と数も考慮して信号を発信し,反転市場に囚われないようにする.
平均線パラメータは,異なる品種と周期に適用して自由に調整できます.
双均線は横盤時に誤信号を発しやすい.価格差指数またはATR指数で判断を補助して,震動状況で取引を避ける.
また,異常な状況下でも套用されることがあります. 適切なストップポイントを設定して,単発損失を減らすことができます.
戦略の安定性を高めるため,メカニズムやパラメータを最適化し続けます.
ADX,MACDなどの補助指標の判断を加え,揺れ動いている市場の誤った取引を避ける.
動的に調整するストップポイント.ATRに基づいてリスク予想を計算し,合理的なストップ割合を設定できます.
オプティマイゼーションパラメータの自己適応性.機械学習の方法を使用して,システムが自動的にパラメータを最適化する.
品種特性に応じてパラメータを微調整する.例えば,暗号通貨はより短い周期に適したパラメータである.
この戦略は,全体的にトレンドを追跡するのに非常に適しています. 同時に,いくつかの突破取引の機会も追加されています. 合理的な最適化によって,戦略は,より多くの市場で安定して動作することができます. 我々は,それをビジネスレベルの高品質の量化戦略に構築するために,改善し続けます.
/*backtest
start: 2023-12-31 00:00:00
end: 2024-01-30 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy(title = "Noro's Trend MAs Strategy v1.9 Extreme", shorttitle = "Trend MAs str 1.9 extreme", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)
//Settings
needlong = input(true, "long")
needshort = input(true, "short")
needstops = input(false, "stops")
stoppercent = input(5, defval = 5, minval = 1, maxval = 50, title = "Stop, %")
useohlc4 = input(false, defval = false, title = "Use OHLC4")
usefastsma = input(true, "Use fast MA Filter")
fastlen = input(5, defval = 5, minval = 1, maxval = 50, title = "fast MA Period")
slowlen = input(21, defval = 20, minval = 2, maxval = 200, title = "slow MA Period")
bars = input(2, defval = 2, minval = 0, maxval = 3, title = "Bars Q")
needbg = input(false, defval = false, title = "Need trend Background?")
needarr = input(false, defval = false, title = "Need entry arrows?")
needex = input(true, defval = true, title = "Need extreme? (crypto/fiat only!!!)")
src = useohlc4 == true ? ohlc4 : close
//PriceChannel 1
lasthigh = highest(src, slowlen)
lastlow = lowest(src, slowlen)
center = (lasthigh + lastlow) / 2
//PriceChannel 2
lasthigh2 = highest(src, fastlen)
lastlow2 = lowest(src, fastlen)
center2 = (lasthigh2 + lastlow2) / 2
//Trend
trend = low > center and low[1] > center[1] ? 1 : high < center and high[1] < center[1] ? -1 : trend[1]
//Bars
bar = close > open ? 1 : close < open ? -1 : 0
redbars = bars == 0 ? 1 : bars == 1 and bar == -1 ? 1 : bars == 2 and bar == -1 and bar[1] == -1 ? 1 : bars == 3 and bar == -1 and bar[1] == -1 and bar[2] == -1 ? 1 : 0
greenbars = bars == 0 ? 1 : bars == 1 and bar == 1 ? 1 : bars == 2 and bar == 1 and bar[1] == 1 ? 1 : bars == 3 and bar == 1 and bar[1] == 1 and bar[2] == 1 ? 1 : 0
//Signals
up = trend == 1 and (low < center2 or usefastsma == false) and (redbars == 1) ? 1 : 0
dn = trend == -1 and (high > center2 or usefastsma == false) and (greenbars == 1) ? 1 : 0
up2 = high < center and high < center2 and bar == -1 ? 1 : 0
dn2 = low > center and low > center2 and bar == 1 ? 0 : 0
//Lines
plot(center, color = blue, linewidth = 3, transp = 0, title = "Slow MA")
plot(center2, color = red, linewidth = 3, transp = 0, title = "PriceChannel 2")
//Arrows
plotarrow(up == 1 and needarr == true ? 1 : 0, colorup = black, colordown = black, transp = 0)
plotarrow(dn == 1 and needarr == true ? -1 : 0, colorup = black, colordown = black, transp = 0)
//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 90)
//Alerts
alertcondition(up == 1, title='buy', message='Uptrend')
alertcondition(dn == 1, title='sell', message='Downtrend')
//Trading
stoplong = up == 1 and needstops == true ? close - (close / 100 * stoppercent) : stoplong[1]
stopshort = dn == 1 and needstops == true ? close + (close / 100 * stoppercent) : stopshort[1]
longCondition = up == 1 or (up2 == 1 and needex == true)
if (longCondition)
strategy.entry("Long", strategy.long, needlong == false ? 0 : na)
strategy.exit("Stop Long", "Long", stop = stoplong)
shortCondition = dn == 1
if (shortCondition)
strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
strategy.exit("Stop Short", "Short", stop = stopshort)