-
Notifications
You must be signed in to change notification settings - Fork 0
Strategy
The Kingbot does the following:
- monitor Telegram for signals,
- create orders on the exchange,
- move the Break-even.
Move the stop loss for a position on the exchange by:
- grouping multi-order positions into "families",
- listening for Take-profit events,
- moving the Stop-loss for all orders in the family to slightly better than the entry.
An asset position may be comprised of multiple orders. A family is a group of orders all with the exact same stop loss. Each order in the position would have its own take-profit price.
The sole purpose of the bot is to monitor the position and when a take-profit price is reached then the stop loss is moved for all orders in the family to a better level.
There is NO storage that keeps track of meta-data about orders. When a trade event happens (close, for example, due to take-profit) we only know about that specific trade which may be part of a multi-order position.
Take the following received trade event that XTB sends:
symbol: 'BITCOIN'
open_price: 67458.03
close_price: 66861.86
position: 316522733
comment: '[T/P]'
profit: 59.62
sl: 67206.15
tp: 66863.15
volume: 0.1
That's all the bot knows. It doesn't know about the other orders (in the "family") and their TP levels. Instead the bot reasons about what to do solely from the single trade event information that the server sends.
Once the bot is listening for trades it will spot orders closed because of take profit which will signal him to adjust the stop loss for all remaining orders in the "family".
When the first TP level is reached the stop loss moves to 0.03% better than the open price.
When TP2 is reached the bot moves to halfway between the open-price and the close-price for this order.
For example: Say we have three orders in a "family" all with a stop loss of
70239.44:
SL 70239.44 SELL BITCOIN TPs=[ 67133.03, 66998.09, 66863.15 ]
First we hit TP1:
symbol : 'BITCOIN'
open_price : 67458.03
close_price: 67122.13
position : 316522734
comment : '[T/P]'
profit : 33.59
volume : 0.1
sl : 70239.44
tp : 67133.03
The bot moves stop loss from 70239.44 to 67437.79 = 67458.03 - 20.24 for two
(2) orders.
Then we hit TP2:
symbol : 'BITCOIN'
open_price : 67458.03
close_price: 66994.74
position : 316522735
comment : '[T/P]'
profit : 46.33
volume : 0.1
sl :67437.79
tp :66998.09
The bot moves stop loss from
67437.79 to 67206.15 = (67458.03 + 66994.74 / 2) - 20.24 for one (1) order.
Then TP3 (the last order) does not move any stop loss since there are none left in the family, perhaps sadly; but, don't get emotional.