uniVocity / univocity-trader

open-source trading framework for java, supports backtesting and live trading with exchanges
577 stars 140 forks source link

CrossOver function #32

Closed mouhamed-o closed 4 years ago

mouhamed-o commented 4 years ago

Hi,

I'm very interest by what you made, and i'm looking for the way to check when a indicator crossover up or down an other indicator or a value.

Thanks

jbax commented 4 years ago

You need to code how to produce signals yourself in your own implementation of IndicatorStrategy.getSignal.

mouhamed-o commented 4 years ago

I think you din't understand my need. When i talk about crossover function. I will give you an example : before last tick RSI value = 29 last tick RSI value = 32 My strategy will buy when the value crossOver up 30. this will generate one signal. If i use the comparator > , it will be always true if my RSI value is upper than 30 for example, the issue is i can get false signal like this. I don't know if you understand what i'm talking about.

crosserover will compare before last and last tick and the comparator > will use only the last tick value and if the value is upper, it will be always true

mouhamed-o commented 4 years ago

With the current indicator implementation, we can't get oldest values of the indicator.

jbax commented 4 years ago

You need to store the older values yourself if you want them. Nothing is kept in memory by the indicators unless it's required to perform a calculation. All the calculations done by the framework are done on the fly to optimize performance and memory usage.

jbax commented 4 years ago

You can probably use the CircularList to help you. It will keep track a number n of recent values.