这是一个非常简单的趋势跟随策略。它会在出现多头型公平价差时做多,出现空头型公平价差时平仓或做空。它在盘整行情下表现不佳,但在趋势行情中可以获得非常丰厚的利润。
该策略的核心逻辑是识别公平价差形态。所谓“公平价差”,是指当天的最高价低于前一天的最低价,或当天的最低价高于前一天的最高价,会形成一个“突破的间隙”。这通常预示着可能的趋势转折。具体来说,策略规则是:
这里使用了两个lag,也就是前两根K线的高低价来判断公平价差,这样避免被假突破或短期回调影响,提高形态判断的可靠性和信号质量。
本策略识别公平价差的形成来判断趋势可能发生反转,属于基本的趋势跟随策略。优点是捕捉趋势反转的时机较为精准,但也存在一定的误报率。可以通过止损与过滤来控制风险,也可以结合更多因子来提高判断的准确性。总的来说,这是一个非常简单实用的趋势交易策略,值得拓展与优化。
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
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/
// © Greg_007
//@version=5
strategy("Fair Value Gap Strategy", "FVG Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding = 1)
var longOnly = input.bool(false, "Take only long trades?")
var pyramid = input.bool(false, "Since this can generate a lot of trades, make sure to fill in the commission (if applicable) for a realistic ROI.", group = "REMINDERS")
var pyramid2 = input.bool(false, "Modify pyramiding orders to increase the amount of trades.", group = "REMINDERS")
var bearFVG = false
var bullFVG = false
var plotBull = false
var plotBear = false
var bearTrend = false
var bullTrend = false
//BEARISH FVG
if high < low[2] and close[1] < low[2]
bullFVG := false
bearFVG := true
plotBear := true
if not longOnly
strategy.entry("Short", strategy.short)
else
strategy.close_all()
else
//BULLISH FVG
if low > high[2] and close[1] > high[2]
bullFVG := true
bearFVG := false
plotBull := true
strategy.entry("Long", strategy.long)
// plotshape(plotBull, style=shape.labeldown, location=location.abovebar, color=color.green, text="FVG",textcolor=color.white, size=size.tiny, title="Bull FVG", display=display.all - display.status_line)
// plotshape(plotBear, style=shape.labelup, location=location.belowbar, color=color.red, text="FVG",textcolor=color.white, size=size.tiny, title="Bear FVG", display=display.all - display.status_line)
// //reset the status
// plotBull := false
// plotBear := false