For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Buying at the High of a Bar
-
I am trying to write the order code where the program will buy at the high when my signal occurs. Below is the code I am using for order placement.
self.order = self.buy(exectype=bt.Order.Stop, size=100, price=self.data.high[0], valid=dt.timedelta(days=1))
For some reason, if the high is not met, the order is not getting canceled, and if there is another signal at a later time, instead of buying 100 shares, the program then buys 200, which means it is combining the share count. Does anyone know how to fix this?
-
Maybe some of this thread helps? https://community.backtrader.com/topic/2/limit-order-with-a-day-valid-never-gets-executed-220/13