该策略基于日线的最高价和最低价绘制两条线,作为多空判断的依据。当价格上穿最高价线时,做多;当价格下穿最低价线时,做空。可以自动进行多空切换。
该策略主要利用了日线的枢轴点来判断多空。所谓“枢轴”,就是昨日的最高价和最低价。这两条线构成一个交易区间,如果今日的价格突破这两个点中的任一个,那么就可以判断趋势发生转折。
具体来说,策略主要逻辑如下:
这样,通过最高、最低价的突破来捕捉趋势,实现自动的多空切换。
该策略主要有以下几个优势:
该策略也存在一些风险:
针对这些风险,我们可以从以下几个方面进行优化:
该策略还有进一步优化的空间:
总的来说,该策略基于简单的日线枢轴思路,实现了多空自动切换。策略逻辑清晰易懂,通过优化可以进一步提高稳定性。投资者可以根据自己的风险偏好,选择合适的参数应用于实盘交易。
/*backtest start: 2023-12-01 00:00:00 end: 2023-12-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //Noro //2019 //@version=3 strategy(title = "Noro's DEX Strategy", shorttitle = "DEX 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(false, defval = false, title = "Short") capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Lot") showlines = input(true, title = "Show lines") showbg = input(false, title = "Show background") showday = input(false, title = "Show new day") 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") //New day trand bar = close > open ? 1 : close < open ? -1 : 0 newday = request.security(syminfo.tickerid, 'D', time) //Lines uplevel = request.security(syminfo.tickerid, 'D', high) dnlevel = request.security(syminfo.tickerid, 'D', low) upcolor = uplevel == uplevel[1] and showlines ? lime : na dncolor = dnlevel == dnlevel[1] and showlines? red : na plot(uplevel, offset = 1, linewidth = 2, color = upcolor) plot(dnlevel, offset = 1, linewidth = 2, color = dncolor) //Background size = strategy.position_size col = time == newday + 86400000 and showday ? blue : showbg and size > 0 ? lime : showbg and size < 0 ? red : na bgcolor(col) //Orders lot = 0.0 lot := size != size[1] ? strategy.equity / close * capital / 100 : lot[1] truetime = true if uplevel > 0 and dnlevel > 0 strategy.entry("Long", strategy.long, needlong ? lot : 0, stop = uplevel, when = truetime) strategy.entry("Close", strategy.short, needshort ? lot : 0, stop = dnlevel, when = truetime)