crypto-trading-bot
crypto-trading-bot copied to clipboard
Enable short/long trades without exit of open trade
Tradingview allows strategies to switch long/short without exit of current position. This update allow same thing. It checks if there is open position, then if we want to switch from side, it adds position amount to calculated order size. This works on Bitfinex, have not tested on other exchanges.
I had doupts if this should be added directly in executeOrder method, or in CalculateOrderSize. But was bit afraid to touch it.
i will implement it in a more generic way. So simply by just adding and removing a given "amount". So the idea would be to store the current position size (or 0 on none) and the difference must be bought or sold.
By this is possible to have targets, profits and multiple entries, also your use case would be directly possible
Hi @Haehnchen, do you have some ETA for this feature? It's bit annoying to keep this as separate branch and merge into prod :)
@egisz how it will be implemented in strategy? something like if(lastSignal = "short" ) { signal = "long"} (lastSignal = "long" ) { signal = "short"} ?
@egisz how it will be implemented in strategy? something like if(lastSignal = "short" ) { signal = "long"} (lastSignal = "long" ) { signal = "short"} ?
Hi, it's not required to check last signal, it will trade only if last signal != current signal. You can simply skip "close" signal and directly go from short to long and vice versa.