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

Stoploss on a different timeframe



  • Hi,

    My strategy is based on the 5-minute timeframe but I want to execute the stop loss as soon as it is triggered (1-minute timeframe).
    What is the best way to achieve this?

    1. Timers
    2. Multiple data feeds (one for 1-minute and one for 5-minute)
    3. Something else?

    The plan is to run this strategy for multiple instruments so the second option is resulting in some performance issues. Is there some other way to do this?

    Thanks



  • I read through Replay and feel that it is a better way to implement what I want to achieve.

    I just wanted to ask if this is the right way to go about implementing it-
    I need to check if len(self) changed or not and only then execute my strategy. For stop-loss, I can implement the exit code outside this if statement.



  • all imho: you can use 5 min bars for stop order execution without going to 1 min bars. unless you trade some really non-liquid stocks or futures.

    also you will need to execute all the orders on the 1 min time frame, not stop orders only. bt will treat 1 min and 5 min data feeds as separate data feeds even they belong to the single ticker.



  • @ab_trader said in Stoploss on a different timeframe:

    all imho: you can use 5 min bars for stop order execution without going to 1 min bars. unless you trade some really non-liquid stocks or futures.

    also you will need to execute all the orders on the 1 min time frame, not stop orders only. bt will treat 1 min and 5 min data feeds as separate data feeds even they belong to the single ticker.

    Now that I read your comment, I realize that replay will not work for my case as it will not have the correct RSI value on the 5 minute time frame. I can probably write my own code to compute the indicators on the 5 minute time frame but that I feel that there might be something better already baked in.
    I understand that there isn't much difference when comparing 5 minute and 1 minute, but it makes a difference if the strategy is using 1-day bars. In that case, I need the stop-loss to trigger immediately.



  • @rohan said in Stoploss on a different timeframe:

    but it makes a difference if the strategy is using 1-day bars.

    I assumed you use 5 min bars, but it seems another layer is hidden.


Log in to reply
 

});