双动能均线交易策略是一种联合使用OTT指标和Wavetrend振荡器指标的策略。它结合使用Anıl Özekşi老师开发的OTT指标和lonestar108的Wavetrend振荡器指标,形成一个成功的交易指标。该策略可以在双向市场中进行做多做空操盘。
双动能均线交易策略首先计算布林带中轨,也就是移动平均线MAvg。然后根据用户设定的百分比范围和周期,计算出长停损位longStop和短停损位shortStop。当价格突破上轨时做多,突破下轨时做空。关闭信号是价格重新回到均线附近。
具体来说,该策略的核心指标是OTT指标。OTT指标由均线和边界线组成,是根据一定算法根据市场波动程度调整边界线的位置。当价格跌破下边界线OTT时,做空;当价格涨破上边界线OTT时,做多。
该策略同时使用Wavetrend指标判断价格趋势方向,如果判断为向下的趋势,则只做空不做多;如果判断为向上的趋势,则只做多不做空。
双动能均线交易策略结合了移动平均线、布林带和OTT指标的优点,可以自动调整止损位置,降低了止损被激活的概率。同时结合趋势判断指标,避免在震荡趋势中被套。
具体来说,该策略的主要优势有:
双动能均线交易策略也存在一定的风险,主要集中在以下几个方面:
对策方式主要是:
双动能均线交易策略仍有进一步优化的空间:
双动能均线交易策略整合了多种指标的优点,可以自动调整止损位,判断反转信号,识别趋势方向。它具有风险控制能力强,容易理解使用等优势。但也存在被套、信号不准等风险。该策略可以进一步优化,与其他指标组合使用,研究自适应算法等。总体来说,双动能均线交易策略是一种实用的突破类交易策略。
/*backtest start: 2023-02-12 00:00:00 end: 2024-02-18 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy(title="Bugra trade strategy", shorttitle="Bugra trade strategy", overlay=true) // Kullanıcı Girdileri length = input(5, title="Period", minval=1) percent = input(1, title="Sihirli Yüzde", type=input.float, step=0.1, minval=0) mav = input(title="Hareketli Ortalama Türü", defval="VAR", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"]) wt_n1 = input(10, title="Kanal Periyodu") wt_n2 = input(21, title="Averaj Uzunluğu") src = close // Tarih Aralığı Girdileri startDate = input(20200101, title="Başlangıç Tarihi (YYYYMMDD)") endDate = input(20201231, title="Bitiş Tarihi (YYYYMMDD)") // Tarih Filtresi Fonksiyonu isDateInRange() => true // Özel Fonksiyonlar Var_Func(src, length) => valpha = 2 / (length + 1) vud1 = src > src[1] ? src - src[1] : 0 vdd1 = src < src[1] ? src[1] - src : 0 vUD = sum(vud1, length) vDD = sum(vdd1, length) vCMO = (vUD - vDD) / (vUD + vDD) varResult = 0.0 varResult := nz(valpha * abs(vCMO) * src + (1 - valpha * abs(vCMO)) * nz(varResult[1])) varResult Wwma_Func(src, length) => wwalpha = 1 / length wwma = 0.0 wwma := wwalpha * src + (1 - wwalpha) * nz(wwma[1]) wwma Zlema_Func(src, length) => zxLag = floor(length / 2) zxEMAData = src + (src - src[zxLag]) zlema = ema(zxEMAData, length) zlema Tsf_Func(src, length) => lrc = linreg(src, length, 0) lrs = lrc - linreg(src, length, 1) tsf = lrc + lrs tsf getMA(src, length) => ma = mav == "SMA" ? sma(src, length) : mav == "EMA" ? ema(src, length) : mav == "WMA" ? wma(src, length) : mav == "TMA" ? sma(sma(src, ceil(length / 2)), floor(length / 2) + 1) : mav == "VAR" ? Var_Func(src, length) : mav == "WWMA" ? Wwma_Func(src, length) : mav == "ZLEMA" ? Zlema_Func(src, length) : mav == "TSF" ? Tsf_Func(src, length) : na // Strateji Hesaplamaları MAvg = getMA(src, length) fark = MAvg * percent * 0.01 longStop = MAvg - fark longStopPrev = nz(longStop[1], longStop) longStop := MAvg > longStopPrev ? max(longStop, longStopPrev) : longStop shortStop = MAvg + fark shortStopPrev = nz(shortStop[1], shortStop) shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop dir = 1 dir := nz(dir[1], dir) dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dir MT = dir==1 ? longStop: shortStop OTT = MAvg > MT ? MT*(200+percent)/200 : MT*(200-percent)/200 plot(OTT, title="BugRA", color=color.rgb(251, 126, 9)) // Alım ve Satım Koşulları longCondition = crossover(src, OTT) and isDateInRange() shortCondition = crossunder(src, OTT) and isDateInRange() // Strateji Giriş ve Çıkış Emirleri if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.close("Long")