drpout / boilr

Price alarms for Bitcoin, cryptocurrencies, cryptoassets, futures and options.
http://boilr.mobi
GNU General Public License v3.0
128 stars 67 forks source link

Add trailing alarm #229

Open javieralmancevo opened 8 years ago

javieralmancevo commented 8 years ago

Hi

I just discovered boilr and it is a great app. I have a suggestion. One thing I am missing is having a trailing alarm, that would work like a trailing stop. For example, the price of BTCUSD is right now $407, and you put a trailing alarm of $5. At this point the alarm would sound if the price goes under $402. Then the price moves up to $410, now the trailing alarm would sound at $405. The price goes down to $408, the trailing alarm is still at $405. The price goes up to $412 (edited), the trailing alarm now moves to $407. You get the idea. Same in the opposite direction obviously.

dllud commented 8 years ago

Hi @javieralmancevo

Thanks for the suggestion!

I am a bit confused about how the trailing alarm should work. Can you tell us the formula to calculate the alarm level?

The following is what I got from your $5 alarm example. I am missing the reason for the last alarm levels.

# price alarm reason
1 407 402 407-5=402
2 410 405 410-5=405
3 408 405 ?
4 410 407 ?
algazarra commented 8 years ago

Trailing means the alarm updates according to price. As @javieralmancevo examplifies, the alarm would work in ranges of 5usd counting from the last high. If price goes up to 410usd, the alarm is updated to 405usd. If 410usd is crossed, a new high is set, and the alarm is updated again.

@dllud this requires both recognizing the last high and caching it

dllud commented 8 years ago

@algazarra Thanks for the clarification.

That explains step 3, but I'm still confused about step 4:

# price alarm reason
1 407 402 high: 407 -> 407-5=402
2 410 405 high: 410 -> 410-5=405
3 408 405 high: 410 -> 410-5=405
4 410 407 high: 410 -> ?
algazarra commented 8 years ago

In step 4. the alarm would stay the same, 407

dllud commented 8 years ago

But it was at 405. Please review the table above.

dllud commented 8 years ago

It seems to me the example provided by @javieralmancevo is wrong it its last step (step 4). To be correct it would be:

# price alarm reason
1 407 402 high: 407 -> 407-5=402
2 410 405 high: 410 -> 410-5=405
3 408 405 high: 410 -> 410-5=405
4 410 405 high: 410 -> 410-5=405

Right?

This way I got the mechanics of it. If things went on, it would look like this:

# price alarm reason
5 409 405 high: 410 -> 410-5=405
6 407 405 high: 410 -> 410-5=405
7 405 405 :bell: RING! high: 410 -> 410-5=405
8 404 400 high: 405 -> 405-5=400
javieralmancevo commented 8 years ago

@dllud what you wrote in your last message is correct. In my first message the last example is indeed incorrect, I mistyped. I am glad you have included the suggestion to the milestone. Thanks for your great work.