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

The order is not executed.



  • Hi, all.
    I want to execute on a market order first at the start, set a profit-taking on that order, and then set two buy-limits in the price range below it.

    Questions

    • Why is it that the orders seem to be working well, but only the first market order is executed?
    • Why doesn't buy_bracket work properly? (I'm commenting out now.)
    
    
        def __init__(self):
            self.is_firsttime = True
            self.close_num = 0
            self.order = None
            self.pos_interval_pips = 15.8
    
        def notify_order(self, order):
            print('-' * 50, 'ORDER BEGIN', datetime.datetime.now())
            print(order)
            print('-' * 50, 'ORDER END')
    
        def notify_trade(self, trade):
            print('-' * 50, 'TRADE BEGIN', datetime.datetime.now())
            print(trade)
            print('-' * 50, 'TRADE END')
    
            if trade.justopened:
                if self.order is not None:
                    # add TP (for first order)
                    self.sell(price=trade.price+self.pos_interval_pips*0.01, 
                                size=self.order.size, 
                                exectype=bt.Order.Limit, 
                                transmit=True, 
                                parent=self.order)
                    if self.close_num >= 0:
                        # add some buy limit order (below first order)
                        for i in range(2):
                            mainside = self.buy(
                                    price=trade.price-(self.pos_interval_pips*0.01*(i+1)),
                                    size=self.order.size,
                                    exectype=bt.Order.Limit,
                                    transmit=False
                                )
                            highside = self.sell(
                                    price=trade.price-(self.pos_interval_pips*0.01*i), 
                                    size=mainside.size, 
                                    exectype=bt.Order.Limit,
                                    transmit=True, 
                                    parent=mainside
                                )
                        
                            # Why doesn't work this?
                            # self.buy_bracket(
                            #         size=self.order.size,
                            #         exectype=bt.Order.Limit,
                            #         price=trade.price-(self.pos_interval_pips*0.01*(i+1)),
                            #         oargs={},
                            #         limitprice=trade.price-(self.pos_interval_pips*0.01*i)
                            #         limitexec=bt.Order.Limit,
                            #         limitargs={})
    
                        self.close_num-=1
                    self.order = None
            elif trade.isclosed:
                self.order = self.buy(price=trade.price, size=trade.size)
    
            self.close_num += 1
    
        def next(self):
            txt = list()
            txt.append('Data0')
            txt.append('%04d' % len(self.data0))
            dtfmt = '%Y-%m-%dT%H:%M:%S.%f'
            txt.append('{:f}'.format(self.data.datetime[0]))
            txt.append('%s' % self.data.datetime.datetime(0).strftime(dtfmt))
            txt.append('{:f}'.format(self.data.open[0]))
            txt.append('{:f}'.format(self.data.high[0]))
            txt.append('{:f}'.format(self.data.low[0]))
            txt.append('{:f}'.format(self.data.close[0]))
            txt.append('{:6d}'.format(int(self.data.volume[0])))
            txt.append('{:d}'.format(int(self.data.openinterest[0])))
            print(', '.join(txt))
    
            if self.is_firsttime:
                self.is_firsttime = False
                self.close_num = 0
                self.order = self.buy(size=1)
    
    

    My supposed orders
    Ref.144 BUY LIMIT 107.51(Market)
    -----Ref.145 SEL LIMIT 107.668

    Ref.146 BUY LIMIT 107.352
    -----Ref.147 SEL LIMIT 107.51

    Ref.148 BUY LIMIT 107.194
    -----Ref.149 SEL LIMIT 107.352

    Exchange data

    Dataname, Number, Datetime, Datetime, Open, High, Low, Close, Volume, OpenInterest
    Data0, 0002, 737611.916667, 2020-07-06T07:00:00.000000, 107.510000, 107.563000, 107.500000, 107.544000,    242, 0
    Data0, 0003, 737611.958333, 2020-07-06T08:00:00.000000, 107.542000, 107.599000, 107.540000, 107.588000,    488, 0
    Data0, 0004, 737612.000000, 2020-07-06T09:00:00.000000, 107.590000, 107.678000, 107.574000, 107.662000,   2705, 0
    Data0, 0005, 737612.041667, 2020-07-06T10:00:00.000000, 107.661000, 107.742000, 107.660000, 107.722000,   3089, 0
    Data0, 0006, 737612.083333, 2020-07-06T11:00:00.000000, 107.721000, 107.773000, 107.682000, 107.696000,   1685, 0
    Data0, 0007, 737612.125000, 2020-07-06T12:00:00.000000, 107.697000, 107.724000, 107.662000, 107.688000,   1729, 0
    Data0, 0008, 737612.166667, 2020-07-06T13:00:00.000000, 107.689000, 107.720000, 107.646000, 107.650000,   1188, 0
    Data0, 0009, 737612.208333, 2020-07-06T14:00:00.000000, 107.651000, 107.707000, 107.650000, 107.690000,   1548, 0
    Data0, 0010, 737612.250000, 2020-07-06T15:00:00.000000, 107.688000, 107.706000, 107.602000, 107.620000,   2095, 0
    Data0, 0011, 737612.291667, 2020-07-06T16:00:00.000000, 107.621000, 107.632000, 107.550000, 107.594000,   2736, 0
    Data0, 0012, 737612.333333, 2020-07-06T17:00:00.000000, 107.592000, 107.612000, 107.544000, 107.574000,   1958, 0
    Data0, 0013, 737612.375000, 2020-07-06T18:00:00.000000, 107.573000, 107.586000, 107.523000, 107.541000,   2129, 0
    Data0, 0014, 737612.416667, 2020-07-06T19:00:00.000000, 107.540000, 107.598000, 107.537000, 107.565000,   1953, 0
    Data0, 0015, 737612.458333, 2020-07-06T20:00:00.000000, 107.564000, 107.564000, 107.498000, 107.526000,   2019, 0
    Data0, 0016, 737612.500000, 2020-07-06T21:00:00.000000, 107.525000, 107.540000, 107.457000, 107.493000,   2174, 0
    Data0, 0017, 737612.541667, 2020-07-06T22:00:00.000000, 107.494000, 107.538000, 107.438000, 107.538000,   2952, 0
    Data0, 0018, 737612.583333, 2020-07-06T23:00:00.000000, 107.535000, 107.596000, 107.448000, 107.462000,   4547, 0
    Data0, 0019, 737612.625000, 2020-07-07T00:00:00.000000, 107.464000, 107.520000, 107.450000, 107.504000,   2554, 0
    

    Please help if possible.
    Thank you so much.



  • 返信: The order is not executed.
    Oh... I forgot to attach this log.

    Data0, 0001, 737611.875000, 2020-07-06T06:00:00.000000, 107.511000, 107.511000, 107.467000, 107.502000,     26, 0
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.912029
    Ref: 144
    OrdType: 0
    OrdType: Buy
    Status: 1
    Status: Submitted
    Size: 1
    Price: None
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 0
    ExecType: Market
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.913213
    Ref: 144
    OrdType: 0
    OrdType: Buy
    Status: 2
    Status: Accepted
    Size: 1
    Price: None
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 0
    ExecType: Market
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.913435
    Ref: 144
    OrdType: 0
    OrdType: Buy
    Status: 4
    Status: Completed
    Size: 1
    Price: None
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 0
    ExecType: Market
    CommInfo: <backtrader.comminfo.CommInfoBase object at 0x7fcd7411b978>
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: False
    -------------------------------------------------- ORDER END
    -------------------------------------------------- TRADE BEGIN 2020-08-01 07:44:12.913611
    ref:30
    data:<btoandav20.feeds.oandav20feed.OandaV20Data object at 0x7fcd5feaf0f0>
    tradeid:0
    size:1
    price:107.51
    value:107.51
    commission:0.0
    pnl:0.0
    pnlcomm:0.0
    justopened:True
    isopen:True
    isclosed:False
    baropen:2
    dtopen:737611.9166666666
    barclose:0
    dtclose:0.0
    barlen:0
    historyon:False
    history:[]
    status:1
    -------------------------------------------------- TRADE END
    Data0, 0002, 737611.916667, 2020-07-06T07:00:00.000000, 107.510000, 107.563000, 107.500000, 107.544000,    242, 0
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.915425
    Ref: 145
    OrdType: 1
    OrdType: Sell
    Status: 1
    Status: Submitted
    Size: -1
    Price: 107.668
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.917465
    Ref: 146
    OrdType: 0
    OrdType: Buy
    Status: 1
    Status: Submitted
    Size: 1
    Price: 107.352
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.917852
    Ref: 147
    OrdType: 1
    OrdType: Sell
    Status: 1
    Status: Submitted
    Size: -1
    Price: 107.51
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.918005
    Ref: 148
    OrdType: 0
    OrdType: Buy
    Status: 1
    Status: Submitted
    Size: 1
    Price: 107.194
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.918177
    Ref: 149
    OrdType: 1
    OrdType: Sell
    Status: 1
    Status: Submitted
    Size: -1
    Price: 107.352
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.918318
    Ref: 145
    OrdType: 1
    OrdType: Sell
    Status: 2
    Status: Accepted
    Size: -1
    Price: 107.668
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.918423
    Ref: 146
    OrdType: 0
    OrdType: Buy
    Status: 2
    Status: Accepted
    Size: 1
    Price: 107.352
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.918536
    Ref: 147
    OrdType: 1
    OrdType: Sell
    Status: 2
    Status: Accepted
    Size: -1
    Price: 107.51
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.918644
    Ref: 148
    OrdType: 0
    OrdType: Buy
    Status: 2
    Status: Accepted
    Size: 1
    Price: 107.194
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    -------------------------------------------------- ORDER BEGIN 2020-08-01 07:44:12.921550
    Ref: 149
    OrdType: 1
    OrdType: Sell
    Status: 2
    Status: Accepted
    Size: -1
    Price: 107.352
    Price Limit: None
    TrailAmount: None
    TrailPercent: None
    ExecType: 2
    ExecType: Limit
    CommInfo: None
    End of Session: 737612.6249999999
    Info: AutoOrderedDict()
    Broker: None
    Alive: True
    -------------------------------------------------- ORDER END
    Data0, 0003, 737611.958333, 2020-07-06T08:00:00.000000, 107.542000, 107.599000, 107.540000, 107.588000,    488, 0
    Data0, 0004, 737612.000000, 2020-07-06T09:00:00.000000, 107.590000, 107.678000, 107.574000, 107.662000,   2705, 0
    Data0, 0005, 737612.041667, 2020-07-06T10:00:00.000000, 107.661000, 107.742000, 107.660000, 107.722000,   3089, 0
    Data0, 0006, 737612.083333, 2020-07-06T11:00:00.000000, 107.721000, 107.773000, 107.682000, 107.696000,   1685, 0
    Data0, 0007, 737612.125000, 2020-07-06T12:00:00.000000, 107.697000, 107.724000, 107.662000, 107.688000,   1729, 0
    Data0, 0008, 737612.166667, 2020-07-06T13:00:00.000000, 107.689000, 107.720000, 107.646000, 107.650000,   1188, 0
    Data0, 0009, 737612.208333, 2020-07-06T14:00:00.000000, 107.651000, 107.707000, 107.650000, 107.690000,   1548, 0
    Data0, 0010, 737612.250000, 2020-07-06T15:00:00.000000, 107.688000, 107.706000, 107.602000, 107.620000,   2095, 0
    Data0, 0011, 737612.291667, 2020-07-06T16:00:00.000000, 107.621000, 107.632000, 107.550000, 107.594000,   2736, 0
    Data0, 0012, 737612.333333, 2020-07-06T17:00:00.000000, 107.592000, 107.612000, 107.544000, 107.574000,   1958, 0
    Data0, 0013, 737612.375000, 2020-07-06T18:00:00.000000, 107.573000, 107.586000, 107.523000, 107.541000,   2129, 0
    Data0, 0014, 737612.416667, 2020-07-06T19:00:00.000000, 107.540000, 107.598000, 107.537000, 107.565000,   1953, 0
    Data0, 0015, 737612.458333, 2020-07-06T20:00:00.000000, 107.564000, 107.564000, 107.498000, 107.526000,   2019, 0
    Data0, 0016, 737612.500000, 2020-07-06T21:00:00.000000, 107.525000, 107.540000, 107.457000, 107.493000,   2174, 0
    Data0, 0017, 737612.541667, 2020-07-06T22:00:00.000000, 107.494000, 107.538000, 107.438000, 107.538000,   2952, 0
    Data0, 0018, 737612.583333, 2020-07-06T23:00:00.000000, 107.535000, 107.596000, 107.448000, 107.462000,   4547, 0
    Data0, 0019, 737612.625000, 2020-07-07T00:00:00.000000, 107.464000, 107.520000, 107.450000, 107.504000,   2554, 0
    


  • It was hard to understand due to lack of data, so I added more data and put it in chronological order.
    No trades have been made except for the first market order.

    Data0, 0001, 737611.875000, 2020-07-06T06:00:00.000000, 107.511000, 107.511000, 107.467000, 107.502000,     26, 0
    
    ORDER   Ref: 174    BUY Submitted->Accepted->Completed
    TRADE   Ref: 174->ref:34    BUY 107.51
    
    Data0, 0002, 737611.916667, 2020-07-06T07:00:00.000000, 107.510000, 107.563000, 107.500000, 107.544000,    242, 0
    
    ORDER   Ref: 175    SEL 107.668 Submitted->Accepted(This is TP for Ref: 174)
    
    ORDER   Ref: 176    BUY 107.352 Submitted->Accepted
    ORDER   Ref: 177    SEL 107.51  Submitted->Accepted(This is TP for Ref: 176)
    
    ORDER   Ref: 178    BUY 107.194 Submitted->Accepted
    ORDER   Ref: 179    SEL 107.352 Submitted->Accepted(This is TP for Ref: 178)
    
    Data0, 0003, 737611.958333, 2020-07-06T08:00:00.000000, 107.542000, 107.599000, 107.540000, 107.588000,    488, 0
    Data0, 0004, 737612.000000, 2020-07-06T09:00:00.000000, 107.590000, 107.678000, 107.574000, 107.662000,   2705, 0
    Data0, 0005, 737612.041667, 2020-07-06T10:00:00.000000, 107.661000, 107.742000, 107.660000, 107.722000,   3089, 0
    Data0, 0006, 737612.083333, 2020-07-06T11:00:00.000000, 107.721000, 107.773000, 107.682000, 107.696000,   1685, 0
    Data0, 0007, 737612.125000, 2020-07-06T12:00:00.000000, 107.697000, 107.724000, 107.662000, 107.688000,   1729, 0
    Data0, 0008, 737612.166667, 2020-07-06T13:00:00.000000, 107.689000, 107.720000, 107.646000, 107.650000,   1188, 0
    Data0, 0009, 737612.208333, 2020-07-06T14:00:00.000000, 107.651000, 107.707000, 107.650000, 107.690000,   1548, 0
    Data0, 0010, 737612.250000, 2020-07-06T15:00:00.000000, 107.688000, 107.706000, 107.602000, 107.620000,   2095, 0
    Data0, 0011, 737612.291667, 2020-07-06T16:00:00.000000, 107.621000, 107.632000, 107.550000, 107.594000,   2736, 0
    Data0, 0012, 737612.333333, 2020-07-06T17:00:00.000000, 107.592000, 107.612000, 107.544000, 107.574000,   1958, 0
    Data0, 0013, 737612.375000, 2020-07-06T18:00:00.000000, 107.573000, 107.586000, 107.523000, 107.541000,   2129, 0
    Data0, 0014, 737612.416667, 2020-07-06T19:00:00.000000, 107.540000, 107.598000, 107.537000, 107.565000,   1953, 0
    Data0, 0015, 737612.458333, 2020-07-06T20:00:00.000000, 107.564000, 107.564000, 107.498000, 107.526000,   2019, 0
    Data0, 0016, 737612.500000, 2020-07-06T21:00:00.000000, 107.525000, 107.540000, 107.457000, 107.493000,   2174, 0
    Data0, 0017, 737612.541667, 2020-07-06T22:00:00.000000, 107.494000, 107.538000, 107.438000, 107.538000,   2952, 0
    Data0, 0018, 737612.583333, 2020-07-06T23:00:00.000000, 107.535000, 107.596000, 107.448000, 107.462000,   4547, 0
    Data0, 0019, 737612.625000, 2020-07-07T00:00:00.000000, 107.464000, 107.520000, 107.450000, 107.504000,   2554, 0
    Data0, 0020, 737612.666667, 2020-07-07T01:00:00.000000, 107.502000, 107.506000, 107.438000, 107.439000,   1230, 0
    Data0, 0021, 737612.708333, 2020-07-07T02:00:00.000000, 107.437000, 107.442000, 107.378000, 107.406000,   1068, 0
    
    ORDER   Ref: 176    BUY 107.352 Completed
    
    Data0, 0022, 737612.750000, 2020-07-07T03:00:00.000000, 107.405000, 107.406000, 107.258000, 107.293000,   1417, 0
    Data0, 0023, 737612.791667, 2020-07-07T04:00:00.000000, 107.292000, 107.381000, 107.287000, 107.378000,   1483, 0
    Data0, 0024, 737612.833333, 2020-07-07T05:00:00.000000, 107.376000, 107.407000, 107.358000, 107.388000,    837, 0
    Data0, 0025, 737612.875000, 2020-07-07T06:00:00.000000, 107.370000, 107.379000, 107.352000, 107.372000,     39, 0
    Data0, 0026, 737612.916667, 2020-07-07T07:00:00.000000, 107.374000, 107.400000, 107.353000, 107.376000,    395, 0
    Data0, 0027, 737612.958333, 2020-07-07T08:00:00.000000, 107.374000, 107.380000, 107.342000, 107.360000,    430, 0
    Data0, 0028, 737613.000000, 2020-07-07T09:00:00.000000, 107.358000, 107.370000, 107.260000, 107.288000,   3141, 0
    Data0, 0029, 737613.041667, 2020-07-07T10:00:00.000000, 107.290000, 107.355000, 107.246000, 107.352000,   2349, 0
    Data0, 0030, 737613.083333, 2020-07-07T11:00:00.000000, 107.353000, 107.410000, 107.343000, 107.396000,   2283, 0
    Data0, 0031, 737613.125000, 2020-07-07T12:00:00.000000, 107.396000, 107.412000, 107.357000, 107.397000,   1556, 0
    Data0, 0032, 737613.166667, 2020-07-07T13:00:00.000000, 107.396000, 107.396000, 107.353000, 107.364000,   1393, 0
    
    ORDER   Ref: 177    SEL 107.51  Completed
    
    Data0, 0033, 737613.208333, 2020-07-07T14:00:00.000000, 107.363000, 107.532000, 107.361000, 107.526000,   2234, 0
    Data0, 0034, 737613.250000, 2020-07-07T15:00:00.000000, 107.524000, 107.579000, 107.502000, 107.576000,   2420, 0
    Data0, 0035, 737613.291667, 2020-07-07T16:00:00.000000, 107.578000, 107.638000, 107.535000, 107.632000,   2883, 0
    Data0, 0036, 737613.333333, 2020-07-07T17:00:00.000000, 107.634000, 107.692000, 107.602000, 107.686000,   3070, 0
    Data0, 0037, 737613.375000, 2020-07-07T18:00:00.000000, 107.686000, 107.792000, 107.682000, 107.736000,   3117, 0
    Data0, 0038, 737613.416667, 2020-07-07T19:00:00.000000, 107.736000, 107.742000, 107.665000, 107.707000,   2732, 0
    Data0, 0039, 737613.458333, 2020-07-07T20:00:00.000000, 107.708000, 107.718000, 107.672000, 107.714000,   2042, 0
    Data0, 0040, 737613.500000, 2020-07-07T21:00:00.000000, 107.715000, 107.718000, 107.599000, 107.611000,   1507, 0
    Data0, 0041, 737613.541667, 2020-07-07T22:00:00.000000, 107.612000, 107.674000, 107.599000, 107.658000,   3058, 0
    Data0, 0042, 737613.583333, 2020-07-07T23:00:00.000000, 107.656000, 107.658000, 107.498000, 107.550000,   5027, 0
    Data0, 0043, 737613.625000, 2020-07-08T00:00:00.000000, 107.550000, 107.592000, 107.511000, 107.532000,   3091, 0
    Data0, 0044, 737613.666667, 2020-07-08T01:00:00.000000, 107.534000, 107.535000, 107.498000, 107.516000,   1770, 0
    Data0, 0045, 737613.708333, 2020-07-08T02:00:00.000000, 107.518000, 107.552000, 107.505000, 107.542000,   1547, 0
    Data0, 0046, 737613.750000, 2020-07-08T03:00:00.000000, 107.541000, 107.568000, 107.504000, 107.520000,   1668, 0
    Data0, 0047, 737613.791667, 2020-07-08T04:00:00.000000, 107.519000, 107.567000, 107.512000, 107.561000,   1324, 0
    Data0, 0048, 737613.833333, 2020-07-08T05:00:00.000000, 107.560000, 107.562000, 107.516000, 107.520000,    805, 0
    Data0, 0049, 737613.875000, 2020-07-08T06:00:00.000000, 107.552000, 107.599000, 107.523000, 107.551000,    136, 0
    Data0, 0050, 737613.916667, 2020-07-08T07:00:00.000000, 107.547000, 107.566000, 107.528000, 107.560000,    182, 0
    Data0, 0051, 737613.958333, 2020-07-08T08:00:00.000000, 107.562000, 107.606000, 107.562000, 107.574000,    419, 0
    Data0, 0052, 737614.000000, 2020-07-08T09:00:00.000000, 107.573000, 107.708000, 107.572000, 107.700000,   1730, 0
    Data0, 0053, 737614.041667, 2020-07-08T10:00:00.000000, 107.702000, 107.710000, 107.642000, 107.668000,   1212, 0
    Data0, 0054, 737614.083333, 2020-07-08T11:00:00.000000, 107.669000, 107.675000, 107.627000, 107.629000,    954, 0
    Data0, 0055, 737614.125000, 2020-07-08T12:00:00.000000, 107.630000, 107.642000, 107.608000, 107.618000,    819, 0
    Data0, 0056, 737614.166667, 2020-07-08T13:00:00.000000, 107.620000, 107.621000, 107.512000, 107.522000,    990, 0
    Data0, 0057, 737614.208333, 2020-07-08T14:00:00.000000, 107.523000, 107.570000, 107.518000, 107.568000,    895, 0
    Data0, 0058, 737614.250000, 2020-07-08T15:00:00.000000, 107.566000, 107.570000, 107.516000, 107.544000,   1583, 0
    Data0, 0059, 737614.291667, 2020-07-08T16:00:00.000000, 107.545000, 107.545000, 107.428000, 107.482000,   2347, 0
    Data0, 0060, 737614.333333, 2020-07-08T17:00:00.000000, 107.480000, 107.584000, 107.473000, 107.576000,   2259, 0
    Data0, 0061, 737614.375000, 2020-07-08T18:00:00.000000, 107.575000, 107.604000, 107.544000, 107.566000,   2423, 0
    Data0, 0062, 737614.416667, 2020-07-08T19:00:00.000000, 107.567000, 107.592000, 107.529000, 107.562000,   1058, 0
    Data0, 0063, 737614.458333, 2020-07-08T20:00:00.000000, 107.564000, 107.576000, 107.500000, 107.516000,   1286, 0
    Data0, 0064, 737614.500000, 2020-07-08T21:00:00.000000, 107.516000, 107.598000, 107.502000, 107.550000,   2071, 0
    Data0, 0065, 737614.541667, 2020-07-08T22:00:00.000000, 107.552000, 107.565000, 107.456000, 107.494000,   3492, 0
    Data0, 0066, 737614.583333, 2020-07-08T23:00:00.000000, 107.495000, 107.528000, 107.423000, 107.507000,   4013, 0
    Data0, 0067, 737614.625000, 2020-07-09T00:00:00.000000, 107.509000, 107.530000, 107.386000, 107.392000,   3407, 0
    Data0, 0068, 737614.666667, 2020-07-09T01:00:00.000000, 107.390000, 107.406000, 107.290000, 107.300000,   2084, 0
    Data0, 0069, 737614.708333, 2020-07-09T02:00:00.000000, 107.298000, 107.332000, 107.228000, 107.250000,   1722, 0
    Data0, 0070, 737614.750000, 2020-07-09T03:00:00.000000, 107.252000, 107.262000, 107.206000, 107.208000,   1785, 0
    Data0, 0071, 737614.791667, 2020-07-09T04:00:00.000000, 107.206000, 107.268000, 107.202000, 107.226000,   1270, 0
    Data0, 0072, 737614.833333, 2020-07-09T05:00:00.000000, 107.228000, 107.272000, 107.223000, 107.260000,    491, 0
    Data0, 0073, 737614.875000, 2020-07-09T06:00:00.000000, 107.299000, 107.319000, 107.264000, 107.290000,     67, 0
    Data0, 0074, 737614.916667, 2020-07-09T07:00:00.000000, 107.295000, 107.299000, 107.264000, 107.286000,    475, 0
    Data0, 0075, 737614.958333, 2020-07-09T08:00:00.000000, 107.284000, 107.322000, 107.273000, 107.286000,    877, 0
    
    ORDER   Ref: 178    BUY 107.194 Completed
    
    Data0, 0076, 737615.000000, 2020-07-09T09:00:00.000000, 107.287000, 107.302000, 107.182000, 107.290000,   3074, 0
    
    ORDER   Ref: 179    SEL 107.352 Completed
    
    Data0, 0077, 737615.041667, 2020-07-09T10:00:00.000000, 107.291000, 107.364000, 107.281000, 107.316000,   3025, 0
    Data0, 0078, 737615.083333, 2020-07-09T11:00:00.000000, 107.315000, 107.341000, 107.286000, 107.310000,   2255, 0
    Data0, 0079, 737615.125000, 2020-07-09T12:00:00.000000, 107.309000, 107.314000, 107.241000, 107.246000,   1563, 0
    Data0, 0080, 737615.166667, 2020-07-09T13:00:00.000000, 107.245000, 107.279000, 107.228000, 107.277000,   2099, 0
    Data0, 0081, 737615.208333, 2020-07-09T14:00:00.000000, 107.279000, 107.315000, 107.260000, 107.272000,   1376, 0
    Data0, 0082, 737615.250000, 2020-07-09T15:00:00.000000, 107.274000, 107.276000, 107.208000, 107.266000,   1982, 0
    Data0, 0083, 737615.291667, 2020-07-09T16:00:00.000000, 107.268000, 107.320000, 107.222000, 107.246000,   3287, 0
    Data0, 0084, 737615.333333, 2020-07-09T17:00:00.000000, 107.248000, 107.286000, 107.198000, 107.286000,   2936, 0
    Data0, 0085, 737615.375000, 2020-07-09T18:00:00.000000, 107.287000, 107.340000, 107.267000, 107.296000,   3312, 0
    Data0, 0086, 737615.416667, 2020-07-09T19:00:00.000000, 107.294000, 107.398000, 107.290000, 107.354000,   2766, 0
    Data0, 0087, 737615.458333, 2020-07-09T20:00:00.000000, 107.356000, 107.356000, 107.280000, 107.290000,   2307, 0
    Data0, 0088, 737615.500000, 2020-07-09T21:00:00.000000, 107.288000, 107.293000, 107.201000, 107.210000,   3321, 0
    Data0, 0089, 737615.541667, 2020-07-09T22:00:00.000000, 107.212000, 107.282000, 107.099000, 107.130000,   5041, 0
    Data0, 0090, 737615.583333, 2020-07-09T23:00:00.000000, 107.132000, 107.312000, 107.099000, 107.268000,   8560, 0
    Data0, 0091, 737615.625000, 2020-07-10T00:00:00.000000, 107.270000, 107.363000, 107.220000, 107.265000,   6630, 0
    
    
    
    


  • The only thing unclear to me is why your 1st limit order was not executed on 2020-07-06 9:00. High of that bar (107.678) is higher than 107.668 price of the initial limit order. Other buy and sell limit orders are executed as expected.



  • @ab_trader
    Thanks.
    In fact, the Ref: 175 order has not been completed.
    if you know, please tell me.
    Is it possible to set a limit on an order once it is executed?



  • I don't understand the question.



  • @ab_trader
    Oh, sorry!
    Ref: 174 has already been executed on the market.
    Then I added a limit order for T/P in notify_trade.
    Is this correct?



  • Is this sell order correct?

    self.sell(price=trade.price+self.pos_interval_pips*0.01, 
                                size=self.order.size, 
                                exectype=bt.Order.Limit, 
                                transmit=True, 
                                parent=self.order)
    


  • Sees correct. Try to run the script without parent and transmit for the 1st limit order. Maybe this will fix an issue.



  • @ab_trader Thank you for your reply!!
    But it's a little different from what I want to do.
    First, I want to issue a market order.
    After the price of that order has been determined, I want to set a limit order(TP).



  • I don;t think you need to use parent and transmit for this.


Log in to reply
 

});