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

ploting StopLimit, StopTrail observers



  • Hello

    Question: how can I get value of actual limit of bt.Order.StopTrail (and bt.Order.Limit)?

    Goal: I want to plot actual limit of bt.Order.StopTrail (and bt.Order.Limit) - to see on the plot how it is changing during time.

    Details:
    I open bracket orders:

    os=self.buy_bracket(stopexec=bt.Order.Limit, stopprice=stopprice1,
                        limitexec=bt.Order.StopTrail, limitargs=dict(trailpercent=trailpercent1))
    

    and to make plot I use observer:

    class obsSellSLTS(bt.Observer):
        lines = ('StopLoss', 'TrailStop')
        plotinfo = dict(plot=True, subplot=False)
        plotlines = dict(
            StopLoss=dict(color='lime'),
            TrailStop=dict(color='gold')
        )
    
        def next(self):
            if len(self._owner.broker.orders)==3: #checking if bracket order is set
                 if self._owner.broker.orders[1].created.pricelimit is not None:
                     self.lines.StopLoss[0] = self._owner.broker.orders[1].created.pricelimit
                 if self._owner.broker.orders[2].created.pricelimit is not None:
                     self.lines.TrailStop[0] = self._owner.broker.orders[2].created.pricelimit
    

    but looks like ' self._owner.broker.orders[2].created.pricelimit' is not the right data
    So: which data should I use:

    self._owner.broker.orders[2].created.pclose,
    self._owner.broker.orders[2].created.plimit,
    self._owner.broker.orders[2].created.price,
    self._owner.broker.orders[2].created.pricelimit,
    

    or from 'executed'

    self._owner.broker.orders[2].executed.pclose,
    self._owner.broker.orders[2].executed.plimit,
    self._owner.broker.orders[2].executed.price,
    self._owner.broker.orders[2].executed.pricelimit,
    

    or in any other source?

    kind regards
    Pawel


  • administrators

    @silverbald said in ploting StopLimit, StopTrail observers:

    I want to plot actual limit of

    @silverbald said in ploting StopLimit, StopTrail observers:

    bt.Order.StopTrail

    This order type has no limit price. The actual order price is tracking the price of the asset. It will actually execute as a Market order when the price is met. The constantly updated price is stored in order.created.price



  • can be deleted



  • Hello

    Thank You to both of you. It helped me a lot.
    Sorry for late response but finally I found reason for issue and together with your suggestion it works well :-)

    thx
    S.



  • @silverbald I have the same issue, would you mind posting your solution that works? Thanks! J


  • administrators

    @jf said in ploting StopLimit, StopTrail observers:

    @silverbald I have the same issue,

    Since the development of the thread seems to indicate that the originally reported issue wasn't the actual issue, ...

    Would you care to let us know which issue are you facing?