0bps

Strategy vault / Trend following

Vegas Trend Wave Strategy

This strategy calculates percentage price difference between multiple EMA pairs to determine trend direction, and trades based on the Vegas wave. Specifically, it computes percentage price differences between current…

Author
ChaoZhang
Complexity
Starter · 49 lines
Parameters
3
Backtest bar
1m · intraday
Tested on
BTC/USDT · futures

This strategy calculates percentage price difference between multiple EMA pairs to determine trend direction, and trades based on the Vegas wave.

Specifically, it computes percentage price differences between current price, 144-period EMA, 169-period EMA and 233-period EMA. Long signals are generated when all three meet the preset positive difference threshold. Shorts are triggered when price falls below all three EMAs and 144-period EMA crosses below 233-period EMA.

The EMA combo filters more false breaks compared to single EMA. Also, the Vegas wave itself contains multiple EMAs for robust trend analysis.

However, EMAs have inherent lag and cannot identify optimal entries. And there is subjectivity in wave theory, with performance relying largely on parameter optimization. Prudent assessment of live results is required.

Overall, the Vegas trend wave strategy synergizes EMA analysis and wave theory for good results in trending markets. But risk management remains crucial for long-term application.

Parameters

NameDefaultWhat it controls
v_input_10.1EMA144 percent difference from EMA233
v_input_20.1EMA169 percent difference from EMA233
v_input_30.1Current price percent difference from EMA233

Source Pine Script

/*backtest
start: 2023-09-03 00:00:00
end: 2023-09-10 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Vegas Wave Strategy", overlay=true)

ema144 = ema(close, 144)
ema169 = ema(close, 169)
ema233 = ema(close, 233)

current = close

upd144 = input(title="EMA144 percent difference from EMA233", type=float, defval=0.1)
upd169 = input(title="EMA169 percent difference from EMA233", type=float, defval=0.1)
upd_current = input(title="Current price percent difference from EMA233", type=float, defval=0.1)

//pDiff - Percentage Difference
pDiff(x, y) =>
    ((x-y)/x)*100

gtDiff(x, y) =>
    x > y


pd144 = pDiff(ema144, ema233)
pd169 = pDiff(ema169, ema233)
pd_current = pDiff(current,ema233)

plot(ema144,color=orange, linewidth=2, transp=0, title="144 EMA")
plot(ema169,color=blue,linewidth=2, transp=0, title="169 EMA")
plot(ema233,color=red,linewidth=2, transp=0, title="233 EMA")


//plot(current, color=white, title="Current Candle")


if (gtDiff(pd_current, upd_current) and gtDiff(pd144, upd144) and gtDiff(pd169, upd169))
    strategy.entry("buy", strategy.long, when=strategy.position_size <=0)

// if (ema8 > ema55 and ema13 > ema55 and ema21 > ema55 and current > ema55 and pd_current > upd_current)
//     strategy.entry("buy", strategy.long, 10000, when=strategy.position_size <=0)
    
if (current < ema144 and current < ema169 and current < ema233 and ema144 <= ema233)
    strategy.entry("sell", strategy.short, when=strategy.position_size > 0)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-11. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Vegas-Trend-Wave-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open