-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: Fix computing indicator start offset for 2d indicators
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains 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
1715c91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I Have a question about a problem that may be relating to this.
I wanted to pre calc TP and SL order levels:
ex.
def init(self):
#some indicators....
self.level_A = self.data.Low - self.ATR2 # pre calc's level for SL
self.level_B = self.data.High + self.ATR2 # pre calc's level for SL
def next(self):
if not self.position
# entry logic bla bla
self.buy(sl = self.level_A, tp= self.level_B)
I get the following error
AssertionError: For long orders should be: SL (108.79414877189056) < BUY PRICE (110.525) < TP (109.16585122810945)
yet if I manually add the SL and TP level formula I get no issues. Seems it is calling incorrect values from the array?
1715c91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamhot1 Since you're not passing an explicit price to
self.buy()
, it uses next bar's Open price, which happens to be above your TP. So upon long order filling, TP price (109) is lower than BUY PRICE (110), but for long orders it should be TP > BUY PRICE.Please consider testing/using #47! It should fix a lot of issues an be somewhat of an improvement still. 😅
1715c91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Still trying to get my head around the mechanics of it. much appreciate the pointers