牛市追踪系统是一个基于趋势跟踪的机械交易系统。它利用4小时图形的趋势指标来过滤交易信号,而入场则根据15分钟图形的指标来判断。主要的指标包括RSI、随机指标和MACD。该系统的优点是多时间框架的组合可以有效过滤假信号,同时利用更低时间框架的指标来获取较精确的入场时机。但该系统也存在一些风险,比如容易产生过度交易和假突破的问题。
该系统的核心逻辑是结合不同时间框架的指标来识别趋势方向和入场时机。具体来说,4小时图形的RSI、随机指标和EMA均要符合条件,来判断总体趋势方向。这可以有效过滤掉多数的噪音。同时15分钟图形的RSI、随机指标、MACD和EMA也要同向看涨或看跌,来确定具体的入场时机。这样可以找到较好的买入卖出点位。当4小时和15分钟的判断都符合时,该系统才会发出交易信号。
对应地,可以从以下几个方面来优化该系统:
牛市追踪系统整体来说是一个非常实用的趋势跟踪机械交易系统。它利用多时间框架的组合指标来识别行情趋势和关键入场时机。通过合理的参数设置和持续的优化测试,该系统可以适应大部分行情环境,达到稳定盈利的效果。但我们也要意识到其中的一些潜在风险,采取积极的措施来防范和化解这些风险。
/*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"}]
*/
//@version=4
strategy("Cowabunga System from babypips.com", overlay=true)
// 4 Hour Stochastics
length4 = input(162, minval=1, title="4h StochLength"), smoothK4 = input(48, minval=1, title="4h StochK"), smoothD4 = input(48, minval=1, title="4h StochD")
k4 = sma(stoch(close, high, low, length4), smoothK4)
d4 = sma(k4, smoothD4)
//15 min Stoch
length = input(10, minval=1, title="15min StochLength"), smoothK = input(3, minval=1, title="15min StochK"), smoothD = input(3, minval=1, title="15min StochD")
k = sma(stoch(close, high, low, length), smoothK)
d= sma(k, smoothD)
//4 hour RSI
src1 = close, len1 = input(240, minval=1, title="4H RSI Length")
up1 = rma(max(change(src1), 0), len1)
down1 = rma(-min(change(src1), 0), len1)
rsi4 = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1))
//15 min RSI
src = close, len = input(9, minval=1, title="15M RSI Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi15 = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//MACD Settings
source = close
fastLength = input(12, minval=1, title="MACD Fast"), slowLength=input(26,minval=1, title="MACD Slow")
signalLength=input(9,minval=1, title="MACD Signal")
fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)
macd = fastMA - slowMA
signal = ema(macd, signalLength)
// Stops and Profit inputs
inpTakeProfit = input(defval = 1000, title = "Take Profit", minval = 0)
inpStopLoss = input(defval = 0, title = "Stop Loss", minval = 0)
inpTrailStop = input(defval = 400, title = "Trailing Stop", minval = 0)
inpTrailOffset = input(defval = 0, title = "Trailing Stop Offset", minval = 0)
// Stops and Profit Targets
useTakeProfit = inpTakeProfit >= 1 ? inpTakeProfit : na
useStopLoss = inpStopLoss >= 1 ? inpStopLoss : na
useTrailStop = inpTrailStop >= 1 ? inpTrailStop : na
useTrailOffset = inpTrailOffset >= 1 ? inpTrailOffset : na
//Specific Time to Trade
myspecifictradingtimes = input('0500-1600', title="My Defined Hours")
longCondition1 = time(timeframe.period, myspecifictradingtimes) != 0
longCondition2 = rsi4 <= 80
longCondition3 = k4 >= d4 and k4 <= 80
longCondition4 = ema(close, 80) >= ema(close, 162)
allLongerLongs = longCondition1 and longCondition2 and longCondition3 and longCondition4
longCondition5 = rsi15 <= 80
longCondition6 = k >= d and k <= 80 and fastMA >= slowMA
longCondition7 = ema(close, 5) >= ema(close, 10)
allLongLongs = longCondition5 and longCondition6 and longCondition7
if crossover(close, ema(close, 5)) and allLongerLongs and allLongLongs
strategy.entry("Long", strategy.long, comment="LongEntry")
shortCondition1 = time(timeframe.period, myspecifictradingtimes) != 0
shortCondition2 = rsi4 >= 20
shortCondition3 = k4 <= d4 and k4 >= 20
shortCondition4 = ema(close, 80) <= ema(close, 162)
allShorterShorts = shortCondition1 and shortCondition2 and shortCondition3 and shortCondition4
shortCondition5 = rsi15 >= 20
shortCondition6 = k <= d and k >= 20 and fastMA <= slowMA
shortCondition7 = ema(close, 5) <= ema(close, 10)
allShortShorts = shortCondition5 and shortCondition6 and shortCondition7
if crossunder(close, ema(close,5)) and allShorterShorts and allShortShorts
strategy.entry("Short", strategy.short, comment="ShortEntry")
strategy.exit("Exit Long", from_entry = "Long", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Short", from_entry = "Short", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)