Skip to content

Commit 44aa88b

Browse files
authored
Merge pull request #2518 from Ruuudy1/feature-alternative-equity-adx-trend-filter
Add manual indicator alternative for equity-adx-trend-filter
2 parents f035eeb + 7608b2f commit 44aa88b

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

  • project-templates
    • csharp/equity-adx-trend-filter
    • python/equity-adx-trend-filter

project-templates/csharp/equity-adx-trend-filter/Main.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,25 @@ public override void Initialize()
7272
SetStartDate(2024, 9, 1);
7373
SetEndDate(2024, 12, 31);
7474
SetCash(100000);
75+
// AutomaticIndicatorWarmUp only supports automatic indicators, not manual indicators.
7576
Settings.AutomaticIndicatorWarmUp = true;
7677
_spy = AddEquity("SPY").Symbol;
7778
var fastEma = EMA(_spy, 50, Resolution.Daily);
7879
var slowEma = EMA(_spy, 200, Resolution.Daily);
7980
_trend = fastEma.Minus(slowEma);
81+
// Alternatively, use a manual indicator.
82+
// var fastEma = new ExponentialMovingAverage(50);
83+
// WarmUpIndicator<IndicatorDataPoint>(_spy, fastEma, Resolution.Daily);
84+
// RegisterIndicator(_spy, fastEma, Resolution.Daily);
85+
// var slowEma = new ExponentialMovingAverage(200);
86+
// WarmUpIndicator<IndicatorDataPoint>(_spy, slowEma, Resolution.Daily);
87+
// RegisterIndicator(_spy, slowEma, Resolution.Daily);
88+
// _trend = fastEma.Minus(slowEma);
8089
_adx = ADX(_spy, 14, Resolution.Daily);
90+
// Alternatively, use a manual indicator.
91+
// _adx = new AverageDirectionalIndex(14);
92+
// WarmUpIndicator(_spy, _adx, Resolution.Daily);
93+
// RegisterIndicator(_spy, _adx, Resolution.Daily);
8194
PlotIndicator("Trend", _trend);
8295
PlotIndicator("ADX", _adx);
8396
Schedule.On(

project-templates/python/equity-adx-trend-filter/main.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@ def initialize(self) -> None:
99
self.set_start_date(2024, 9, 1)
1010
self.set_end_date(2024, 12, 31)
1111
self.set_cash(100000)
12+
# automatic_indicator_warm_up only supports automatic indicators, not manual indicators.
1213
self.settings.automatic_indicator_warm_up = True
1314
self._spy = self.add_equity("SPY")
1415
self._trend = IndicatorExtensions.minus(
15-
self.ema(self._spy, 50, Resolution.DAILY),
16+
self.ema(self._spy, 50, Resolution.DAILY),
1617
self.ema(self._spy, 200, Resolution.DAILY)
1718
)
19+
# Alternatively, use a manual indicator.
20+
# self._ema_fast = ExponentialMovingAverage(50)
21+
# self.warm_up_indicator(self._spy, self._ema_fast, Resolution.DAILY)
22+
# self.register_indicator(self._spy, self._ema_fast, Resolution.DAILY)
23+
# self._ema_slow = ExponentialMovingAverage(200)
24+
# self.warm_up_indicator(self._spy, self._ema_slow, Resolution.DAILY)
25+
# self.register_indicator(self._spy, self._ema_slow, Resolution.DAILY)
26+
# self._trend = IndicatorExtensions.minus(self._ema_fast, self._ema_slow)
1827
self._adx = self.adx(self._spy, 14, Resolution.DAILY)
28+
# Alternatively, use a manual indicator.
29+
# self._adx = AverageDirectionalIndex(14)
30+
# self.warm_up_indicator(self._spy, self._adx, Resolution.DAILY)
31+
# self.register_indicator(self._spy, self._adx, Resolution.DAILY)
1932
self.plot_indicator("Trend", self._trend)
2033
self.plot_indicator("ADX", self._adx)
2134
self.schedule.on(

0 commit comments

Comments
 (0)