ctubio / Krypto-trading-bot

Self-hosted crypto trading bot (automated high frequency market making) written in C++
https://127.0.0.1:3000
Other
3.35k stars 820 forks source link

Missing MANUAL: New trend protection proposal #347

Closed serzhiio closed 6 years ago

serzhiio commented 6 years ago

Hi guys! I have an idea of momentum trend protection. The problem is to stop bot sell while uptrend and buy while downtrend. Proposal is to use two extra EWMA ShortMicro(12)+ShortUltra(3)+Threshold(2) to quickly define current trend. sure they can be changed, but i'm testing 12+3+2. If it's downtrend and strength more then 2, stop bot selling, set pdiv to 0 and wait while stregth will be less then 2 and the same with downtrend.

Formula: STRENGTH = - ( ( ewmaMicro - ewmaUltra ) / ewmaMicro ) * 1000

Look at the chart, there are vertical bars green - uptrend, red - downtrend.

default

ctubio commented 6 years ago

sorry is this fully implemented at https://github.com/ctubio/Krypto-trading-bot/pull/351?

thanks for your time'¡

Camille92 commented 6 years ago

It looks very good @serzhiio thank you for your time!

Looking forward to try that :)

Are the parameters accessible in the web ui ?

serzhiio commented 6 years ago

Sure, all params can be set up through UI. Need all possible feedback.

Camille92 commented 6 years ago

Yes I was looking for the code and your formula, if I can make one feedback is:

Why don't you use the same formula than ewma crossover for the strength?

Here you're using the difference between the micro (longest) to the ultra (shortest) that make you deal with minus results all the time (and oblige you to put a - at the beginning).

I would argue for a formula to be:

STRENGTH = ((ewmaUltra * 100) / ewmaMicro ) - 100

This gives you the difference between ultra and micro in %, then just set a % in the settings (so something about 0,2 in your default settings).

Tell me what you think about that :)

serzhiio commented 6 years ago

Let's imagine 2 situation:

  1. Ultra = $10, Micro = $5
  2. Ultra = $5, Micro = $10

In first case Strength Classic formula: [(10100/5)-100 ] = 100 Original formula: [-((5-10)/5)1000] = 1000

In second case Strength Classic formula: [(5100/10)-100] = -50 Original formula: [-((10-5)/10)1000] = -500

Now I see that both formulas leads to different strength but it should be the same in down and uptrend because distances between Ultra and Micro in our cases are the same (5-10, 10-5).

That's why i propose new formula with classic ewma base, but at first we should define trend direction: Strength = (min(Micro,Ultra)*100/max(Micro,Ultra)) case 1: 50, sign + case 2: 50, sign -

Am I right?

Camille92 commented 6 years ago

Well so our formulas are the same, mine in % and yours in ‰ (per mille), I just think that % is more convenient.

And don't worry about the sign or the strength we can't do anything against math :p.

ctubio commented 6 years ago

merged but missing docs for new ewma trend at MANUAL.md :(

Camille92 commented 6 years ago

Why did you reopen the issue ?

Btw I think it's not necessary to turn pdiv to 0 when using this protection, as you will only buy from one side.

Let's say the market is up and TBP is full crypto but this protection detects a short term down trend movement.

If your pdiv is 0 then you will not sell anything (because that would go against your TBP) thus making this protection less efficient.

While if you don't put pdiv = 0 you will sell untill you reach TBP - pdiv and buy back when it's starting to go up again ;)

serzhiio commented 6 years ago

Hi Camille, I agree with you that it is not neccessary to set pDiv to 0 when trend is just local i will make a fix. And i ask you to think about multistage trend protection with different conditions. You are more expirienced in this field than I.

P.S.: Looking forward to chat with you about my losses with btc/usd rush these days :( P.P.S.: Let's create a developers group in Telegram or whatsApp or whatever except IRC (sorry Carles)