この戦略は,二重のランダムな動力指標 ((SMIとRSI) を使って多空判断を行い,マーティンゲルと身体フィルターで取引信号をフィルターし,中短線トレンドを捕捉し,価格変動を追跡することを目的としています.
この戦略は,二重のランダム動能指標SMIとRSIを使用して空白判断を行う.SMIは,K線実物価格差と閉盘価格の移動平均によって計算され,反転点を効果的に識別することができる.RSIは,多空の動きを比較して,超買超売を決定することができる.戦略は,SMIが50未満とRSIが20未満の場合は,多買する.SMIが50以上の場合とRSIが80以上の場合は,空白する.
偽突破をフィルターするために,戦略は10サイクル体均線の1/3を突破フィルター条件として使用する. 实体が均線の1/3を突破すると,突破は有効とみなされる.
さらに,戦略は,前期の損失を回収する見込みで,損失の取引時に比例してポジションを上げることである,選択可能なマーティンゲル戦略を採用している.
バックテスト機能は,スタート・ストップ時間を入力して,戦略の効果を測る.
この戦略は,二重ランダム指数とフィルターを統合して,反転点を効果的に識別し,中短線トレンドを捕捉し,価格変動を追跡します.
SMIとRSIのパラメータを最適化することで,追高殺低の確率を下げることができる.合理的なマーティンゲル戦略を使用し,加仓率と回数を制御する.市場状況に応じてフィルタをオンにするかどうかを選択し,フィルタvalid信号の確率を下げる.
この戦略は,反転点を捕捉する二重ランダム指標を総合的に使用し,フィルターとマーティンガルの取引信号のフィルタリングと追跡を補助し,中短線トレンドを効果的に識別し,価格変動を追跡し,高い勝率を追求する投資家に適しています.指標の遅滞や震動市場のリスクを注意して使用する.パラメータの最適化とストップ損失によってリスクを制御することができます.
/*backtest
start: 2022-09-30 00:00:00
end: 2023-10-06 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
// strategy(title = "CS Basic Scripts - Stochastic Special (Strategy)", shorttitle = "Stochastic Special", overlay = false, 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")
usemar = input(false, defval = false, title = "Use Martingale")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
usesmi = input(true, defval = true, title = "Use SMI Strategy")
usersi = input(true, defval = true, title = "Use RSI Strategy")
usebod = input(true, defval = true, title = "Use Body-Filter")
a = input(5, "SMI Percent K Length")
b = input(3, "SMI Percent D Length")
limit = input(50, defval = 50, minval = 1, maxval = 100, title = "SMI Limit")
//Backtesting Input Range
fromyear = input(2017, defval = 2017, 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")
//Fast RSI
fastup = rma(max(change(close), 0), 7)
fastdown = rma(-min(change(close), 0), 7)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))
//Stochastic Momentum Index
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
SMIsignal = ema(SMI,b)
//Lines
plot(SMI, color = blue, linewidth = 3, title = "Stochastic Momentum Index")
plot(SMIsignal, color = red, linewidth = 3, title = "SMI Signal Line")
plot(limit, color = black, title = "Over Bought")
plot(-1 * limit, color = black, title = "Over Sold")
plot(0, color = blue, title = "Zero Line")
//Body Filter
nbody = abs(close - open)
abody = sma(nbody, 10)
body = nbody > abody / 3 or usebod == false
//Signals
up1 = SMI < -1 * limit and close < open and body and usesmi
dn1 = SMI > limit and close > open and body and usesmi
up2 = fastrsi < 20 and close < open and body and usersi
dn2 = fastrsi > 80 and close > open and body and usersi
exit = ((strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open)) and body
//Trading
profit = exit ? ((strategy.position_size > 0 and close > strategy.position_avg_price) or (strategy.position_size < 0 and close < strategy.position_avg_price)) ? 1 : -1 : profit[1]
mult = usemar ? exit ? profit == -1 ? mult[1] * 2 : 1 : mult[1] : 1
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 * mult : lot[1]
if up1 or up2
if strategy.position_size < 0
strategy.close_all()
strategy.entry("long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if dn1 or dn2
if strategy.position_size > 0
strategy.close_all()
strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if time > timestamp(toyear, tomonth, today, 23, 59) or exit
strategy.close_all()