该策略通过结合移平均线指标和市场交易便利指数这两个指标的信号,在判断到价格反转的时候进行买入或卖出操作,属于反转类交易策略。
该策略使用了两个指标进行信号判断。第一个指标是移平均线指标,具体为随机指标的快线和慢线的组合。当价格连续两个日内下跌,同时快线高于慢线时产生卖出信号;当价格连续两个日内上涨,同时快线低于慢线时产生买入信号。这样通过判断价格反转和随机指标的快慢线位置关系,预测价格可能反转的时机。
第二个指标是市场交易便利指数。该指数通过计算价格波动范围与成交量的关系,来判断市场的流动性和价格运行的效率。指数上升表明市场交易顺畅,运行效率高,可以判断为趋势行情;指数下降则表明市场流动性变差,运行效率降低,可能进入盘整震荡行情。
本策略通过结合两个指标的判断逻辑,在双指标同时发出买入或卖出信号时,对应产生买入和卖出操作。
如果行情进入长期单边上涨或下跌,将难以捕捉反转机会,无法进入场内
可以适当放宽反转指标的参数,增加买入和卖出的机会
也可以加大持仓规模,通过追踪趋势获取更多利润
反转信号可能出现误差,使策略失效
可以通过优化指标参数或增加确认周期来减少假信号
该策略结合了反转指标和趋势判断指标,在价格出现反转预警时进场,同时判断大趋势,避免逆势操作。通过双指标互证,可以有效减少假信号。但策略也存在行情单边行情时无获利机会和误判反转信号的风险。通过参数优化、止损策略、指标升级以及机器学习等方式还可进一步优化。
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 02/02/2021
// This is combo strategies for get a cumulative signal.
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
// The strategy sells at market, if close price is lower than the previous close price
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// The Market Facilitation Index is an indicator that relates price range to
// volume and measures the efficency of price movement. Use the indicator to
// determine if the market is trending. If the Market Facilitation Index increased,
// then the market is facilitating trade and is more efficient, implying that the
// market is trending. If the Market Facilitation Index decreased, then the market
// is becoming less efficient, which may indicate a trading range is developing that
// may be a trend reversal.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
vFast = sma(stoch(close, high, low, Length), KSmoothing)
vSlow = sma(vFast, DLength)
pos = 0.0
pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0)))
pos
MFI(BuyZone,SellZone) =>
pos = 0.0
xmyVol = volume
xmyhigh = high
xmylow = low
nRes = (xmyhigh - xmylow) / xmyVol * 10000
pos := iff(nRes > BuyZone, 1,
iff(nRes < SellZone, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal & Market Facilitation Index", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- MFI ----")
SellZone = input(6.2, minval=0.01, step = 0.01)
BuyZone = input(1, minval=0.01, step = 0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posMFI = MFI(BuyZone,SellZone)
pos = iff(posReversal123 == 1 and posMFI == 1 , 1,
iff(posReversal123 == -1 and posMFI == -1, -1, 0))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1 , 1, pos))
if (possig == 1 )
strategy.entry("Long", strategy.long)
if (possig == -1 )
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )