This strategy identifies key support and resistance levels based on moving averages, and takes trades when price breaks through these levels. The strategy is simple and effective, easy to understand and implement.
The strategy uses a Simple Moving Average (SMA) with a period of 50 to identify support and resistance zones. Specifically:
In other words, the strategy uses the 50-period SMA to divide price zones, and takes trades when price breaks out of these zones. It goes long on breakouts above resistance, and goes short on breakdowns below support. The strategy is straightforward and easy to execute.
The strategy has the following advantages:
The strategy also has the following risks:
These risks can be addressed through optimizations like adjusting the SMA period, adding trend filter indicators, etc. Proper stop loss management is also very important.
Some ways the strategy can be enhanced:
These improvements can make the strategy more robust across different market cycles.
Overall, the strategy identifies support/resistance with SMAs and trades breakouts, keeping things simple and effective. There is also significant room for optimization across multiple dimensions. While false breakouts remain a risk, prudent stop loss usage can effectively control this. The strategy is easy to understand for beginners and great for gaining practical experience.
/*backtest start: 2023-01-01 00:00:00 end: 2023-09-27 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //--------------------------* //-- This source code is subject to the terms of the Mozilla Public License 2.0 //-- 開源代碼受Mozilla公眾授權條款2.0版規範, 網址是https://mozilla.org/MPL/2.0/ // //@version=4 // // 作品: [LunaOwl] 支撐壓力策略第4版 // 英文: [LunaOwl] Support Resistance Strategy V4 // //////////////////////////////// // ~~!!*(๑╹◡╹๑) ** // // 製作: @LunaOwl 彭彭 // // 日期: 2019年03月05日 // // 修改: 2019年04月22日 // // 四版: 2020年06月16日 // // 發表: 2020年06月17日 // //////////////////////////////// //==設定策略==// strategy("[LunaOwl] 支撐壓力策略 [回測]", shorttitle = "支撐壓力策略 [回測]", overlay = true, calc_on_order_fills = false, calc_on_every_tick = false, pyramiding = 0, currency = currency.NONE, initial_capital = 10000, slippage = 5, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, commission_type = strategy.commission.percent, commission_value = 0.05 ) LB = input(50, title = "回溯期數", type = input.integer) R = valuewhen(cross(sma(close, LB),close), highest(high, LB), 1) S = valuewhen(cross(close,sma(close, LB)), lowest( low, LB), 1) plot(R, title = "壓力", color = color.green) plot(S, title = "支撐", color = color.red) //==定義輸出結果==// Trend_up = crossover(close, R) ? 1 : 0 Trend_dn = crossunder(close, S) ? -1 : 0 //==設定出場規則==// Enter = Trend_up == 1 and Trend_up[1] == 0 ? Trend_up : na Exit = Trend_dn == -1 and Trend_dn[1] == 0 ? Trend_dn : na strategy.entry("多", strategy.long, when = Enter) strategy.entry("空", strategy.short, when = Exit)