Hey everyone, I am confused about using bracket order. As I know, the expectation of result should be similar profit and loss in every trades. The following is my code snippet and result. Any advises?
def next(self):
if not self.position:
if self.sma_fast[-1] > self.sma_slow[-1] and self.sma_fast[-2] < self.sma_slow[-2]:
# self.log('BUY CREATE, %.5f' % self.dataclose[0])
# self.order = self.buy()
entry = self.data.close[0]
long_tp = entry + 1000 * self.vpoint
long_sl = entry - 1000 * self.vpoint
print('[ORDER_SEND] BUY >> entry_price: %.5f tp: %.5f sl: %.5f' %
(entry, long_tp, long_sl))
self.order = self.buy_bracket(
price=entry, stopprice=long_tp, limitprice=long_sl)
pass
elif self.sma_fast[-1] < self.sma_slow[-1] and self.sma_fast[-2] > self.sma_slow[-2]:
# self.log('SELL CREATE, %.5f' % self.dataclose[0])
# self.order = self.sell()
entry = self.data.close[0]
short_tp = entry - 1000 * self.vpoint
short_sl = entry + 1000 * self.vpoint
print('[ORDER_SEND] SELL >> entry: %.5f tp: %.5f sl: %.5f' %
(entry, short_tp, short_sl))
self.order = self.sell_bracket(
price=entry, stopprice=short_tp, limitprice=short_sl)
pass
RESULT:
[ORDER_SEND] SELL >> entry: 1.16470 tp: 1.15470 sl: 1.17470
[NOTIFY_ORDER] 2017-10-27: Order ref: 31 / Type Sell / Status Submitted
[NOTIFY_ORDER] 2017-10-27: Order ref: 32 / Type Buy / Status Submitted
[NOTIFY_ORDER] 2017-10-27: Order ref: 33 / Type Buy / Status Submitted
[NOTIFY_ORDER] 2017-10-27: Order ref: 31 / Type Sell / Status Accepted
[NOTIFY_ORDER] 2017-10-27: Order ref: 32 / Type Buy / Status Accepted
[NOTIFY_ORDER] 2017-10-27: Order ref: 33 / Type Buy / Status Accepted
[NOTIFY_ORDER] 2017-10-27: Order ref: 31 / Type Sell / Status Completed
[NOTIFY_ORDER] 2017-10-27: Order ref: 32 / Type Buy / Status Completed
[NOTIFY_ORDER] 2017-10-27: Order ref: 33 / Type Buy / Status Canceled
[NOTIFY_TRADE] 2017-10-27 23:59:59.999989, Close Price: 1.1647, Profit, Gross 9.3, Net 9.3
[ORDER_SEND] BUY >> entry_price: 1.17653 tp: 1.18653 sl: 1.16653
[NOTIFY_ORDER] 2017-11-17: Order ref: 34 / Type Buy / Status Submitted
[NOTIFY_ORDER] 2017-11-17: Order ref: 35 / Type Sell / Status Submitted
[NOTIFY_ORDER] 2017-11-17: Order ref: 36 / Type Sell / Status Submitted
[NOTIFY_ORDER] 2017-11-17: Order ref: 34 / Type Buy / Status Accepted
[NOTIFY_ORDER] 2017-11-17: Order ref: 35 / Type Sell / Status Accepted
[NOTIFY_ORDER] 2017-11-17: Order ref: 36 / Type Sell / Status Accepted
[NOTIFY_ORDER] 2017-11-17: Order ref: 34 / Type Buy / Status Completed
[NOTIFY_ORDER] 2017-11-17: Order ref: 35 / Type Sell / Status Completed
[NOTIFY_ORDER] 2017-11-17: Order ref: 36 / Type Sell / Status Canceled
[NOTIFY_TRADE] 2017-11-17 23:59:59.999989, Close Price: 1.17653, Profit, Gross 13.0, Net 13.0
[ORDER_SEND] SELL >> entry: 1.17751 tp: 1.16751 sl: 1.18751
[NOTIFY_ORDER] 2017-12-12: Order ref: 37 / Type Sell / Status Submitted
[NOTIFY_ORDER] 2017-12-12: Order ref: 38 / Type Buy / Status Submitted
[NOTIFY_ORDER] 2017-12-12: Order ref: 39 / Type Buy / Status Submitted
[NOTIFY_ORDER] 2017-12-12: Order ref: 37 / Type Sell / Status Accepted
[NOTIFY_ORDER] 2017-12-12: Order ref: 38 / Type Buy / Status Accepted
[NOTIFY_ORDER] 2017-12-12: Order ref: 39 / Type Buy / Status Accepted
[NOTIFY_ORDER] 2017-12-12: Order ref: 37 / Type Sell / Status Completed
[NOTIFY_ORDER] 2017-12-12: Order ref: 38 / Type Buy / Status Completed
[NOTIFY_ORDER] 2017-12-12: Order ref: 39 / Type Buy / Status Canceled
[NOTIFY_TRADE] 2017-12-12 23:59:59.999989, Close Price: 1.17752, Profit, Gross 45.7, Net 45.7
[ORDER_SEND] BUY >> entry_price: 1.18710 tp: 1.19710 sl: 1.17710
[NOTIFY_ORDER] 2017-12-26: Order ref: 40 / Type Buy / Status Submitted
[NOTIFY_ORDER] 2017-12-26: Order ref: 41 / Type Sell / Status Submitted
[NOTIFY_ORDER] 2017-12-26: Order ref: 42 / Type Sell / Status Submitted
[NOTIFY_ORDER] 2017-12-26: Order ref: 40 / Type Buy / Status Accepted
[NOTIFY_ORDER] 2017-12-26: Order ref: 41 / Type Sell / Status Accepted
[NOTIFY_ORDER] 2017-12-26: Order ref: 42 / Type Sell / Status Accepted
[NOTIFY_ORDER] 2017-12-26: Order ref: 40 / Type Buy / Status Completed
[NOTIFY_ORDER] 2017-12-26: Order ref: 41 / Type Sell / Status Completed
[NOTIFY_ORDER] 2017-12-26: Order ref: 42 / Type Sell / Status Canceled
[NOTIFY_TRADE] 2017-12-26 23:59:59.999989, Close Price: 1.1871, Profit, Gross -0.1, Net -0.1