karlwancl / Trady

Trady is a handy library for computing technical indicators, and it targets to be an automated trading system that provides stock data feeding, indicator computing, strategy building and automatic trading. It is built based on .NET Standard 2.0.
https://lppkarl.github.io/Trady
Apache License 2.0
545 stars 184 forks source link

Indicator Volume NVI ( negative Volume) #71

Closed jotab24 closed 6 years ago

jotab24 commented 6 years ago

Hi! i'm improving to create my own indicator, but i don't know how i can do.

the formula is easy:

NVI = Previous NVI + {[(Today's Closing Price-Yesterday's Closing Price)/Yesterday's Closing Price)] x Previous NVI}.

can you help me?? Thanks!!!

karlwancl commented 6 years ago

Hi @jotab24, You may create a class that inherits from CumulativeNumericAnalyzableBase<IOhlcv, decimal?, AnalyzableTick<decimal?>>.

In your constructor, call base class with parameters (inputs, c => c.Close) to allow the indicator to use only the close price in the computation step.

Then, override ComputeInitialValue, you should have the 1st calculated value (NVI) without previous NVI value.

And, also override the ComputeCumulativeValue with your formula: prevOutputToMap + (mappedInputs[index] - mappedInputs[index - 1])/mappedInputs[index - 1]) * prevOutputToMap

It is a drafted steps for creating a new indicator, i will be updating the document later as I am busy with my work right now. If there's anything you are unable to figure out, please let me know.

jotab24 commented 6 years ago

ok i have a new class from CumulativeNumericAnalyzableBase, but i need the last NVI value... the formula is in this website. Calculation If today's volume is less than yesterday's volume then:

image

If today's volume is greater than or equal to yesterday's volume then: image

the info is from this website: https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/nvi

Can you help me to do it?I wait for the document with desire

thanks a lot

karlwancl commented 6 years ago

@jotab24 ok. maybe i will do it this weekend.

jotab24 commented 6 years ago

thanks a lot!If I understand the manual I will make new indicators!!

karlwancl commented 6 years ago

@jotab24 NVI/PVI are added, please help to test the indicator.

jotab24 commented 6 years ago

Thanks you so much I will test tomorrow!

jotab24 commented 6 years ago

works as expected!!!Thanks!