☰
Login
Signup
Home
›
Algorithms and Strategies
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.5K
All Categories
0
Incidents
136
Node JS client
39
Go client
778
.Net API client
367
Kite Publisher
535
.Net / VBA / Excel (3rd party)
447
Algorithms and Strategies
979
Java client
1K
API clients
402
PHP client
3.8K
Python client
335
Mobile and Desktop apps
1.3K
Market data (WebSockets)
3.2K
General
ATR Trailing Stop loss Strategy Python
simonofficial
May 31
in
Algorithms and Strategies
I'm trying to code ATR Trailing Stop loss. But the values are not matching with algo - back tested with streak / Trading view.
ATR Trailing stoploss (multiplier =1 and Period =5). I want to understand how it is calculated.
For example:
Close price crosses above ATR Trailing stoploss (What is the ATR Trailing stoploss here).
Is it previous close + (ATR*Multiplier) or Previous EMA 1 + (ATR*Multiplier)?
It will be helpful if anyone can help me with this part.
I do calculate ATR:
# Define a function to calculate ATR manually
def calculate_atr(df, window=5):
tr = pd.DataFrame()
tr['h-l'] = df['high'] - df['low']
tr['h-pc'] = np.abs(df['high'] - df['close'].shift())
tr['l-pc'] = np.abs(df['low'] - df['close'].shift())
atr = tr.max(axis=1).rolling(window=window).mean()
return atr
Am i doing it right or missing something? What to do with this ATR to get the condition close price crosses above ATR Trailing stop loss?
Tagged:
python
ATR
Average True Range
ATR Trailing Stoploss
Python Algo Trading
Sign In
or
Register
to comment.