How to reset the value of strategy parameter each day at the session start



  • Hi,
    I use intraday data in my strategy (e.g. 1H) but for each day the logic in the strategy depends on whether the price hit some precalculated value. This value is calculated at the begin of the daily session (actually, I am using an indicator that works on daily data).

    What is the best way how to reset the boolean variable which indicates if the intraday price hit some level during daily session? Can I just reset the value of the variable in the next() method when I detect the first hourly bar in the particular day or there is some better approach?

    Thanks



  • Check out this thread Submit order 30 minutes before market close

    @backtrader offered nice approach how to check time during the day inside the indicator class.



  • Thank you @ab_trader, I will check it out.


  • administrators

    In any case it seems that a "call a function at a given time", be it related to the session starting/ending times or totally unrelated (for example around midnight) is something people actually do. Seems like a proper add-on.


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.