
この戦略は,K線の最高価格と最低価格の変化を用い,市場の揺れ方向と強さを判断し,均線と組み合わせて全体的な傾向を判断し,ショートライン操作を実現する.これは,揺れがより顕著な品種に主に適用する.
この戦略は,まず,K線の最高値と最低値の相対の前K線の変化を判断し,最高値が上昇した場合は1で,最低値が低下した場合は1で,そうでない場合は0で記す.それから,一定の周期における最高値と最低価格の変化の平均値をそれぞれ計算して,市場の振動方向と強さを判断する.
同時に,戦略は,最近の周期における最高価格と最低価格を記録する. 平均線がトレンド転換を判断するときに,記録された価格と組み合わせて,重要な価格位を判断し,ストップとストップのレベルを形成する.
入口方向は均線で判断し,多頭は上線上に購入し,空頭は下線下に販売する.止損と止レベルは,判断によって重要な価格位が形成される.
この戦略の最大の利点は,短線の振動特性を充分利用することにある. 決定的な価格位を判断することでストップロストが形成され,戦略が明確なルールの下で動作することを可能にする. 同時に,傾向判断を組み合わせて不利な動きをフィルタリングし,無駄な損失を避ける.
この戦略には以下のリスクがあります.
ビジネスが動揺しないと,利益は得られない.
価格がストップラインを突破すると,不必要な損失が生じます. ストップラインの範囲は,適切に緩和することができます.
傾向を誤って判断し,状況を見逃したり逆操作したりするかもしれない。平均線パラメータを適切に調整することができる。
この戦略は以下の点で最適化できます.
平均線周期を調整し,異なる品種の特性に適応する.
ストップ・ロスの範囲を最適化し,利益と損失のバランスをとる.
誤った操作を避けるために,他の指標の判断を追加します.
自動ストップを増加させ,最大損失を制御する.
この戦略は,全体として,ショートラインの振動特性を利用する戦略である.価格の小さな範囲を充分に活用して利益を得る.同時に,リスクを厳格に制御し,トレンドが不利であるときに時効で止まる.安定した収益を追求するより慎重な投資家に適している.パラメータを適切に調整すれば,振動の状況で良い効果を得ることができる.
/*backtest
start: 2024-01-16 00:00:00
end: 2024-01-16 22:45:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//Noro
//2018
//@version=3
strategy(title = "Noro's ZZ-3 Strategy", shorttitle = "ZZ-3 str", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
corr = input(0.0, title = "Correction, %")
bars = input(1, minval = 1)
revers = input(false, defval = false, title = "revers")
showll = input(true, defval = true, title = "Show Levels")
showbg = input(false, defval = false, title = "Show Background")
showar = input(false, defval = false, title = "Show Arrows")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//Levels
hbar = 0
hbar := high > high[1] ? 1 : high < high[1] ? -1 : 0
lbar = 0
lbar := low > low[1] ? 1 : low < low[1] ? -1 : 0
uplevel = 0.0
dnlevel = 0.0
hh = highest(high, bars + 1)
ll = lowest(low, bars + 1)
uplevel := hbar == -1 and sma(hbar, bars)[1] == 1 ? hh + ((hh / 100) * corr) : uplevel[1]
dnlevel := lbar == 1 and sma(lbar, bars)[1] == -1 ? ll - ((ll / 100) * corr) : dnlevel[1]
//Lines
upcol = na
upcol := showll == false ? na : uplevel != uplevel[1] ? na : lime
plot(uplevel, color = upcol, linewidth = 2)
dncol = na
dncol := showll == false ? na : dnlevel != dnlevel[1] ? na : red
plot(dnlevel, color = dncol, linewidth = 2)
//Background
size = strategy.position_size
trend = 0
trend := size > 0 ? 1 : size < 0 ? -1 : high >= uplevel ? 1 : low <= dnlevel ? -1 : trend[1]
col = showbg == false ? na : trend == 1 ? lime : trend == -1 ? red : na
bgcolor(col)
//Arrows
longsignal = false
shortsignal = false
longsignal := size > size[1]
shortsignal := size < size[1]
plotarrow(longsignal and showar and needlong ? 1 : na, colorup = blue, colordown = blue, transp = 0)
plotarrow(shortsignal and showar and needshort ? -1 : na, colorup = blue, colordown = blue, transp = 0)
//Trading
lot = 0.0
lot := size != size[1] ? strategy.equity / close * capital / 100 : lot[1]
if uplevel > 0 and dnlevel > 0 and revers == false
strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, stop = uplevel, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, stop = dnlevel, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if uplevel > 0 and dnlevel > 0 and revers == true
strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, limit = dnlevel, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, limit = uplevel, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if time > timestamp(toyear, tomonth, today, 23, 59)
strategy.close_all()