该策略主要通过监测K线的高低点形成的箱体的突破,判断市场的方向和力度。当出现向上的箱体突破时,策略会在突破点附近设定一个正向的入场点;当出现向下的箱体突破时,策略会在突破点附近设定一个反向的入场点。一旦形成交易信号,策略就会下单建仓,并设置止损点和止盈点来控制风险。
策略会定义一个交易时间段,只在该时间段内运作寻找交易机会。
策略会在每一个K线形成后判断前两根K线的最高价和最低价是否出现了显著的突破。
2.1 如果第二根K线的最低价高于第一根K线的最高价,就出现了向上的箱体突破。
2.2 如果第二根K线的最高价低于第一根K线的最低价,就出现了向下的箱体突破。
在确认箱体突破信号后,策略会在当根K线的最高价或最低价附近设置正向或反向的入场点。
一旦形成仓位,策略会根据突破幅度的两倍进行止盈设置,通过此方法来捕捉趋势的加速。
策略还会在第二根K线的最低价或最高价位置设置止损点,降低亏损风险。
该策略具有如下优势:
原理简单易懂,容易执行。
使用K线箱体突破判断市场方向和力度,准确率较高。
通过止盈水平的设定可以捕捉趋势加速的机会。止盈倍数是可调整的。
有明确的止损逻辑,可以控制单笔亏损。
策略思路灵活,可以根据个人风格进行定制。
然而,策略也存在一定的风险:
突破信号可能是假突破,不能完全避免亏损的发生。
止损位置靠近入场点可能会被激进的市场轻易触发。
无法判断趋势格局,在震荡行情中止损可能频繁被触发。
没有考虑交易品种和时间段差异性造成的影响。
为进一步优化该策略,可以从以下几个方面入手:
根据不同品种和时间段设置适应性止损止盈参数。
增加对趋势判断的技术指标进行配合,避免在震荡行情中被套。
设置后续加仓机会来追踪趋势运行。
结合量能指标来判断突破的真假以过滤信号。
增加机器学习算法来辅助判断趋势方向。
该策略基于简单的突破原理设计,通过捕捉突破后的加速运行获取超额收益。利用止损和止盈设置控制风险。策略容易理解和实施,可根据个人需求和市场环境进行调整优化,具有很强的实用性。
/*backtest
start: 2024-01-07 00:00:00
end: 2024-01-14 00:00:00
period: 3m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Dvitash
//@version=5
strategy("Casper SMC Silver Bullet", shorttitle = "Casper SB", overlay=true, calc_on_order_fills = true)
startTime = input(defval = "1000", title = "Start Time")
endTime = input(defval = "1600", title = "End Time")
contractAmt = input.int(defval = 2, title = "Contract Amount")
fvgCol = input.color(defval = color.rgb(63, 61, 179, 41), title = "FVG Color")
borderCol = input.color(defval = color.rgb(35, 33, 172, 41), title = "FVG Border Color")
fvgExtendLength = input.int(defval = 0, minval = 0, title = "FVG Extend Length")
allowedTime = not na(time(timeframe.period, startTime + "-" + endTime +":23456", "America/New_York"))
newDay = bool(ta.change(time('D')))
h = hour(time('1'), "America/New_York")
var bool fvgDrawn = na
var float entryPrice = na
var float stopPrice = na
var float tpPrice = na
if newDay
fvgDrawn := false
// a_allBoxes = box.all
// if array.size(a_allBoxes) > 0
// for i = 0 to array.size(a_allBoxes) - 1
// box.delete(array.get(a_allBoxes, i))
if allowedTime and barstate.isconfirmed and h <= 16
//Long FVG
if high[2] < low and not fvgDrawn
// box.new(bar_index[2], low, bar_index + fvgExtendLength, high[2], bgcolor = fvgCol, border_color = borderCol)
stopPrice := low[2]
entryPrice := low
tpPrice := entryPrice + (math.abs(low[2] - entryPrice) * 2)
// log.info("SL: " + str.tostring(stopPrice) + " Entry: " + str.tostring(entryPrice) + " TP: " + str.tostring(tpPrice))
strategy.entry("long", strategy.long, contractAmt, limit = entryPrice, comment = "Long Entry")
fvgDrawn := true
if low[2] > high and not fvgDrawn
// box.new(bar_index[2], high, bar_index + fvgExtendLength, low[2], bgcolor = fvgCol, border_color = borderCol)
stopPrice := high[2]
entryPrice := high
tpPrice := entryPrice - (math.abs(high[2] - entryPrice) * 2)
// log.info("SL: " + str.tostring(stopPrice) + " Entry: " + str.tostring(entryPrice) + " TP: " + str.tostring(tpPrice))
strategy.entry("short", strategy.short, contractAmt, limit = entryPrice, comment = "Short Entry")
fvgDrawn := true
if h >= 16
strategy.close_all()
strategy.cancel_all()
strategy.exit("long exit", from_entry = "long", qty = contractAmt, limit = tpPrice, stop = stopPrice, comment = "Long Exit")
strategy.exit("short exit", from_entry = "short", qty = contractAmt, limit = tpPrice, stop = stopPrice, comment = "Short Exit")