
この戦略は主に月線と四季線の均線をベースに操作する.具体的には20日線が月線,60日線が四季線,戦略信号源は2つの均線の金叉死叉である.月線上を四季線を横切るときにロングし,多頭信号を形成する.月線下を四季線を横切るときに清仓を平仓する.この戦略は中長線操作に適用され,整盤を捕まえて裏切りチャンスを利益にする.
この戦略は20日単調移動平均線を月線指標として,60日単調移動平均線を四季線指標として使用している.具体的取引信号生成ロジックは以下の通りである.
月線と季線の均線交差によって中長線トレンドを判断し,金叉が多ければ中長線牛市に入ると,死叉が空ければ中長線熊市に入るとする.同時に,ストップ・ストップ・ストラトジーとリスクコントロールする.
解決策は
この戦略Overall XXXXXシステムは,月季線平均線の優位性をatically利用し,平均線の金銀死叉によって中長線トレンド方向を判断する。同時に,合理的なストップ・ストップ・メカニズムを配置してリスクを制御する。戦略の最適化スペースは大きく,さらにテスト・最適化に値する。
/*backtest
start: 2022-12-08 00:00:00
end: 2023-12-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("均線操作-月季", overlay=true, initial_capital = 100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30)
sma20 = sma(close, 20)
sma60 = sma(close, 60)
plot(sma20, title="月線", color=color.purple,linewidth=2)
plot(sma60, title="季線", color=color.yellow,linewidth=2)
backtest_year = input(title="backtest_year",type=input.integer,defval=2020)
backtest_month = input(title="backtest_month",type=input.integer,defval=10)
backtest_date = input(title="backtest_date",type=input.integer,defval=1)
backtest_start_time = timestamp(backtest_year,backtest_month,backtest_date,0,0,0)
to_long = sma20 > sma60 and close > highest(10)*0.9 // 黃金交叉
to_close = sma20 < sma60 // 死亡交叉
to_exit = close < highest(10)*0.9 //股價嚴重回檔
to_stop = close < 0.9*strategy.position_avg_price
// to_long = crossover(sma20, sma60) // 黃金交叉
// to_close = crossunder(sma20, sma60) // 死亡交叉
//plotchar(to_long, char="B", text="買", color=color.red, location=location.belowbar)
//plotchar(to_close, char="S", text="賣", color=color.green, location=location.abovebar)
//strategy.close("open long",when = tslide, comment="多單滑價7%出場")
if true
strategy.entry("golden", strategy.long, when=to_long,comment="多單入場")
strategy.close("golden", when=to_exit,comment="多單滑價7%出場")
strategy.close("golden", when=to_close,comment="月線季線死亡交叉")
strategy.close("golden", when=to_stop,comment="虧損10%強迫停損")