Found it hard to control buy and sell at the exact bar position/timing
-
Hi all,
I found it is difficult to use the APIs (together with COC and COO) to control buy and sell at different locations of the bars. For example, just for the sake of being able to control, I want to buy with market orders at the open of every bar and sell at the close at the same bar on odd days, and sell at the open with market orders and buy at the close at the same bar on even days. How can I implement that?
I cannot seem to find an easy way to do that easy strategy. Can anyone please help?
-
@jamespp An easy solution would be to use lower time frame inside the bars you want to "cheat" with coc & coo.
-
@emr thank you for replying to me. How to do generate that lower timeframe data? You meant to split the original bar into 2 (or maybe 3) bars which are right after open and right before close? do you have some example for doing that?
-
@EMR @backtrader could you experts help here please? I am stuck here. thank you
-
@jamespp To use lower time frame, you have to have lower time frame data. Ex. : instead of using 1 hour data, you can use 1 mn data, aggregate it to obtain 1 hour data and use the underlying 1 mn data to enter and exit trades.