For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Strategy question / issue



  • I have 10 years 1-minute data starting at 09:01, ending at 16:00
    I'm resampling it to daily data and adding daily as the first dataset (data0), and the intraday - as data1.

    The strategy's indicators are using data0's OHLC values to calculate signals.

    What I want is - to use the daily data for a "starting" point of each day, and trade on the intraday data for that day only.
    For example - Start of 10.08.2020 09:00, place an order using order_target_percent() at 09:01 with the intraday data price for that time (i.e. order executed at 09:01 using the open price for the next minute), and then skip to the next day.

    What is the best way to achieve this ?

    I also noticed that when Backtrader starts, there is no action done on the very first day. I have the signals values and order_target_percent() should've been called (order placed), but it's not, it's placed on the next day. Why is that ?



  • Data - Multiple Timeframes
    Quoting from above article: The data with the smallest timeframe (and thus the larger number of bars) must be the 1st one to be added to the Cerebro instance

    The reason your strategy using daily (data0) instead of intraday (data1) because you inputted the daily bar first. Try input intraday (data1) first then resample back to daily (data0), this should solve your problem.



  • @barton05 said in Strategy question / issue:

    Data - Multiple Timeframes
    Quoting from above article: The data with the smallest timeframe (and thus the larger number of bars) must be the 1st one to be added to the Cerebro instance

    The reason your strategy using daily (data0) instead of intraday (data1) because you inputted the daily bar first. Try input intraday (data1) first then resample back to daily (data0), this should solve your problem.

    What about trading at specific time, instead of in next() ?



  • @chewbacca
    maybe a if in next can do?

    if self.datas[0].datetime.datetime.hour==9 and self.datas[0].datetime.datetime.minute==1:
        self.buy()```


  • @barton05 I used timers and the buy/sell logic @ notify_timer


Log in to reply
 

});