Add WaveTrend Oscillator indicator#9429
Open
AlexCatarino wants to merge 1 commit intoQuantConnect:masterfrom
Open
Add WaveTrend Oscillator indicator#9429AlexCatarino wants to merge 1 commit intoQuantConnect:masterfrom
AlexCatarino wants to merge 1 commit intoQuantConnect:masterfrom
Conversation
Implement WaveTrendOscillator (bar indicator) per the linked issue. Adds the indicator class, the WTO helper in QCAlgorithm.Indicators.cs, unit tests inheriting CommonIndicatorTests<IBaseDataBar>, and the reference CSV under Tests/TestData/. The oscillator is computed from the typical price (HLC/3): an EMA smooths it (ESA), a second EMA tracks its absolute deviation (D), the normalized channel index (HLC3 - ESA) / (0.015 * D) is smoothed by a third EMA to produce WT1, and an SMA of WT1 produces the signal line WT2. Crossovers between WT1 and WT2 are commonly used as entry and exit signals for momentum reversals. Reference values were generated with TA-Lib (talib.EMA + talib.SMA) following the script posted by @LouisSzeto in the issue thread. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1162eb7 to
6900147
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements
WaveTrendOscillator(extendsBarIndicator) per the linked issue. Adds the indicator class, theWTOhelper inQCAlgorithm.Indicators.cs, unit tests inheritingCommonIndicatorTests<IBaseDataBar>, and the reference CSV underTests/TestData/.The main line (WT1) is an EMA of a normalized channel index derived from HLC3 and its EMA; the signal line (WT2) is a short SMA of the main line:
Each sub-indicator (
ChannelAverage,ChannelDeviation,ChannelIndexAverage,Signal) is a public read-only property so callers can plot or chain them.IsReadybecomes true only onceSignalhas accumulatedsignalPeriodsamples downstream of the chained EMAs (WarmUpPeriod = 2 * channelPeriod + averagePeriod + signalPeriod - 3).Related Issue
Closes #6411
Motivation and Context
The WaveTrend Oscillator is a widely-followed momentum oscillator on TradingView for identifying overbought/oversold conditions and main/signal crossovers. Issue #6411 requested it as a first-class LEAN indicator so algorithms can use it without hand-rolling the EMA/SMA chain. Reference: https://www.tradingview.com/script/2KE8wTuF-Indicator-WaveTrend-Oscillator-WT/
Requires Documentation Change
Yes — QuantConnect/Documentation#2309
How Has This Been Tested?
dotnet build QuantConnect.Lean.slndotnet test Tests/QuantConnect.Tests.csproj --filter "FullyQualifiedName~WaveTrendOscillatorTests"— all 14 tests pass (main-line external-data comparison, signal-line external-data comparison, reset, warm-up, renko, volume-renko, time-moves-forward, constructor argument validation, sub-indicator readiness ordering, etc.).talib.EMA,talib.SMA) following the script posted by @LouisSzeto in Implement WaveTrend Oscillator Indicator #6411; main and signal lines match within1e-4.The reference CSV at
Tests/TestData/spy_wto.csvwas produced with the script below. Reviewers can paste it into a file and re-run to reproduce the expected values:Test data generator
Types of changes
Checklist:
feature-<issue>-<description>