You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, I really like how backtesting.py is expanding my knowledge of backtesting trading strategies.
I have run into a problem I cannot figure out. I am new to the program as well as python and I find myself stumped.
I wrote a small Strategy that compares a few EMA's with different time frames, 1 & 5 min, using resample_apply. I am also using a 50 and 200 day EMA and SMA.
I realize EMA needs several bars to get warmed up, when I step through the lines of code, the first trade happens on the second bar.
However trades are not logged until both the 50 and 200 moving average are greater than 0. If those conditions are not needed ( I think i have set up things to account for this) then why do the trades appear to be dependant on them being positive?
I am most interested in why, but will be grateful for any insight on how to create a solution for future strategies.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First off, I really like how backtesting.py is expanding my knowledge of backtesting trading strategies.
I have run into a problem I cannot figure out. I am new to the program as well as python and I find myself stumped.
I wrote a small Strategy that compares a few EMA's with different time frames, 1 & 5 min, using resample_apply. I am also using a 50 and 200 day EMA and SMA.
I realize EMA needs several bars to get warmed up, when I step through the lines of code, the first trade happens on the second bar.
However trades are not logged until both the 50 and 200 moving average are greater than 0. If those conditions are not needed ( I think i have set up things to account for this) then why do the trades appear to be dependant on them being positive?
I am most interested in why, but will be grateful for any insight on how to create a solution for future strategies.
I hope someone can shed some light on my dilemma. I put the code on COLAB if anyone is interested.
https://colab.research.google.com/drive/1tBPGxRNX4pmfDJ_TiGjHFnAjjTwksDC2?usp=sharing
`
class EMACross(Strategy):
Beta Was this translation helpful? Give feedback.
All reactions