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

I wonder What self.bar_executed means??



  •     def notify_order(self, order):
             self.bar_executed = len(self)
       def next(self)
            if len(self) >= (self.bar_executed + 5):
    

    I am studying Backtrader Quickstart Guide in a and I wonder what each of the above functions means.

    From what I understand, the meaning of if len(self) >= (self.bar_executed + 5): was close price >= close price within 5 minutes.

    Could you tell me what the exact meaning is?

    Thank you in advance to all the people who answered.



  • self.bar_executed records the length of the data feed at the moment when order related notification issued.

    @황윤태 said in I wonder What self.bar_executed means??:

    if len(self) >= (self.bar_executed + 5):

    this just compare if length of the data feed in current next() call is more than self.bar_executed + 5, no prices are involved, no minutes are involved.



  • Thank you . your reply !
    if my data is follows:

    date                     close
    2020.04.05           100  
    2020.04.06           101         
    2020.04.07           102
    2020.04.08           101
    2020.04.09           105
    2020.04.10           120
    
    
    if len(self) >= (self.bar_executed + 5):
    

    Does the above code mean that you will use one of the prices from April 5, 2020 to April 9, 2020?



  • @ab_trader Thank you . your reply !
    if my data is follows:

    date                     close
    2020.04.05           100  
    2020.04.06           101         
    2020.04.07           102
    2020.04.08           101
    2020.04.09           105
    2020.04.10           120
    
    if len(self) >= (self.bar_executed + 5):
    

    Does the above code mean that you will use one of the prices from April 5, 2020 to April 9, 2020?

    @ab_trader said in I wonder What self.bar_executed means??:

    self.bar_executed records the length of the data feed at the moment when order related notification issued.

    @황윤태 said in I wonder What self.bar_executed means??:

    if len(self) >= (self.bar_executed + 5):

    this just compare if length of the data feed in current next() call is more than self.bar_executed + 5, no prices are involved, no minutes are involved.



  • The code shown in the post doesn't use prices. It counts length of the data feed itself.



  • @ab_trader Thank you your response!!
    But I don't understand why you're using it.

    For example, if the length of the data is from April 1st to April 30th, 2004, does if len(self) >= (self.bar_executed + 5) mean that the transaction will be made on a 5th basis?



  • It is used to generate sell order on the fifth bar after position open.



  • @ab_trader wow!!! I understand thank you !!!!!!!!! thank you!!



  • I think it is just a tracker, to do something within 5 bars after u bought. So within that if statement, u can do something like if stochastics go up, add more or stochastics down, reduce position.

    Likewise u can reverse that if statement, so u do nothing and calm down for 5 bars, then only take action after 5 bars.



  • Is there a way to track how long you have been out of position in a similar manner to this?



  • @B-U I believe that it is easier to count bars for which condition not self.position is True and reset the counter every time the position exists. Something like

    def __init__(self):
        outofposition = 0
    
    def next(self):
        if not self.position:
            outofposition +=1
        else:
            outofposition = 0
    

Log in to reply
 

});