Oscillation Strategy of High and Low TEMA Average
This strategy uses TEMA, VWMACD and HMA indicators to capture the downtrend of Bitcoin. Its main logic is to go short when VWMACD crosses below 0, price is below HMA and fast TEMA is below slow TEMA. It will exit the…

Overview
This strategy uses TEMA, VWMACD and HMA indicators to capture the downtrend of Bitcoin. Its main logic is to go short when VWMACD crosses below 0, price is below HMA and fast TEMA is below slow TEMA. It will exit the position when VWMACD crosses above 0, price is above HMA or fast TEMA crosses above slow TEMA.
Principle
First calculate VWMACD (the only difference from regular MACD is the way to calculate moving average) and plot it as histogram. Then add HMA as a trend filter. After that create and add fast TEMA (5 periods) and slow TEMA (8 periods), and calculate the difference between them to plot around 0. This is the key decision for going short.
The specific entry rule is: when VWMACD is below 0, price is below HMA and fast TEMA is below slow TEMA, go short.
The specific exit rule is: when VWMACD crosses above 0, price is above HMA or fast TEMA crosses above slow TEMA, close position.
Advantage Analysis
- Uses a combination of three indicators, improves reliability of trading signals.
- VWMACD can identify divergences and provide accurate trend judgements.
- HMAfilt as a trend filter, avoids noise interference.
- Fast and slow TEMA combo catches short-term reversal points.
- Adopts short-period parameters, suitable for high frequency trading, catches short-term downtrends.
Risk Analysis
- Multiple indicators combo, complex parameter tuning needed.
- Although having HMA filter, still need to prevent false breakouts in ranging markets.
- Short periods prone to market noise interference, wrong signals may occur.
- Need strict stop loss to prevent unexpected large losses.
- Need to focus on transaction cost control, high frequency trading easily hurt by friction.
Optimization Directions
- Can test different parameter combinations to find optimal parameters.
- Can add other indicators like RSI, KD for assistance.
- Can use adaptive parameters according to different market conditions.
- Can optimize stop loss strategy, like trailing stop loss.
- Can combine with volume indicators to avoid insufficient thrust.
Conclusion
This strategy uses the combination of VWMACD, HMA and fast/slow TEMA to capture short-term downtrends of Bitcoin. Its advantages are relatively reliable signals and suitability for high frequency trading. But it also has risks like complex parameter tuning, prone to noise interference. Further optimizing parameter combos and adding auxiliary indicators can make the strategy more stable and reliable. Overall, by utilizing multiple indicator confirmation and short period parameters, this strategy can make relatively accurate judgements on Bitcoin's short-term downtrends, and is an effective high frequency short strategy.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 2017 | Start Year |
| v_input_2 | 12 | Month |
| v_input_3 | 17 | Day |
| v_input_4 | 13 | Short period |
| v_input_5 | 21 | Long period |
| v_input_6 | 5 | Smoothing period |
| v_input_7 | 400 | HMA |
| v_input_8 | 5 | Fast moving TEMA |
| v_input_9 | 8 | Slow moving TEMA |
| v_input_10 | true | Take Profit (%) |
| v_input_11 | 4 | Stop Loss (%) |
Source Pine Script
/*backtest
start: 2022-11-08 00:00:00
end: 2023-11-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="TEMA_HMA_VWMACD short strategy", shorttitle="Short strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.018, currency='USD')
startP = timestamp(input(2017, "Start Year"), input(12, "Month"), input(17, "Day"), 0, 0)
end = timestamp(9999,1,1,0,0)
_testPeriod() =>
iff(time >= startP and time <= end, true, false)
slow = input(13, "Short period")
fast = input(21, "Long period")
signal = input(5, "Smoothing period")
Fast = ema( volume * close, fast ) / ema( volume, fast )
Slow = ema( volume * close, slow ) / ema( volume, slow )
Macd = Slow - Fast
Signal = ema(Macd, signal)
Hist=Macd-Signal
plot(Hist, color=color.silver, linewidth=1, style=plot.style_histogram)
plot(0, color=color.red)
length = input(400, minval=1, title = "HMA")
hullma = wma(2*wma(close, length/2)-wma(close, length), floor(sqrt(length)))
tema_length_1 = input(5, "Fast moving TEMA")
tema_length_2 = input(8, "Slow moving TEMA")
tema(sec, length)=>
tema1= ema(sec, length)
tema2= ema(tema1, length)
tema3= ema(tema2, length)
tema = 3*tema1-3*tema2+tema3
tema1 = tema(hlc3, tema_length_1)
tema2 = tema(hlc3, tema_length_2)
threshold = 0
tm = tema1 - tema2
plot_fast = plot(tm, color = tm > 0 ? color.green : color.red)
plot(threshold, color=color.purple)
up = crossover(tm, 0)
down = crossunder(tm, 0)
longCondition = (Hist < 0) and hullma > close and (tema1 < tema2) and _testPeriod()
strategy.entry('BUY', strategy.short, when=longCondition)
shortCondition = (Hist > 0) or hullma < close or up
strategy.close('BUY', when=shortCondition)
// Take profit
tp = input(1, type=input.float, title='Take Profit (%)')
sl = input(4, type=input.float, title='Stop Loss (%)')
strategy.exit('XLong', from_entry='BUY', profit=(close * (tp/100) * (1/syminfo.mintick)), loss=(close * (sl/100) * (1/syminfo.mintick)))Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-15. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Oscillation-Strategy-of-High-and-Low-TEMA-Average.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Bull Market Tracking SystemPine Script · Breakout · 1h
- MA Trendline Breakthrough StrategyPine Script · Breakout · 1d
- Momentum Breakout Moving Average StrategyPine Script · Breakout · 1d
- Momentum Breakout Trading Strategy 440964Pine Script · Breakout · 5m
- Moving Average Crossover and Upper Rail Breakthrough Impulse StrategyPine Script · Breakout · 1m
- Multi Technical Indicator Dynamic Wave Trading StrategyPine Script · Breakout · 1h