Skip to content

Commit f035eeb

Browse files
authored
Merge pull request #2520 from Ruuudy1/feature-alternative-equity-atr-volatility-stop
Add manual indicator alternative for equity-atr-volatility-stop
2 parents 69f4782 + 4f143b8 commit f035eeb

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

  • project-templates
    • csharp/equity-atr-volatility-stop
    • python/equity-atr-volatility-stop

project-templates/csharp/equity-atr-volatility-stop/Main.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ public override void Initialize()
7272
SetStartDate(2022, 1, 1);
7373
SetEndDate(2024, 12, 31);
7474
SetCash(100000);
75+
// AutomaticIndicatorWarmUp only supports automatic indicators, not manual indicators.
7576
Settings.AutomaticIndicatorWarmUp = true;
7677

7778
_spy = AddEquity("SPY", Resolution.Minute);
7879
_atr = ATR(_spy.Symbol, 14);
80+
// Alternatively, use a manual indicator.
81+
// _atr = new AverageTrueRange(14);
82+
// WarmUpIndicator(_spy.Symbol, _atr);
83+
// RegisterIndicator(_spy.Symbol, _atr);
7984
_trailingHigh = 0m;
8085
_waitingToReenter = false;
8186

project-templates/python/equity-atr-volatility-stop/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ def initialize(self) -> None:
77
self.set_start_date(2022, 1, 1)
88
self.set_end_date(2024, 12, 31)
99
self.set_cash(100000)
10+
# automatic_indicator_warm_up only supports automatic indicators, not manual indicators.
1011
self.settings.automatic_indicator_warm_up = True
1112

1213
self._spy = self.add_equity("SPY", Resolution.MINUTE)
1314
self._atr = self.atr(self._spy.symbol, 14)
15+
# Alternatively, use a manual indicator.
16+
# self._atr = AverageTrueRange(14)
17+
# self.warm_up_indicator(self._spy, self._atr)
18+
# self.register_indicator(self._spy, self._atr)
1419
self._trailing_high: float = 0.0
1520
self._waiting_to_reenter = False
1621

0 commit comments

Comments
 (0)