Gekko Forum
Indicator on indicator - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Strategy Development (https://forum.gekko.wizb.it/forum-12.html)
+--- Thread: Indicator on indicator (/thread-57731.html)



Indicator on indicator - kmohammad - 10-22-2018

Hi
How I can write an indicator that uses other indicator result as input? I mean like tradingview.com who has "apply indicator on Ichimoku" for instance.
thanks


RE: Indicator on indicator - cubit - 10-22-2018

Hi!

If you look at the strategies/indicators folder you will see code for the indicators.
If you look at (for example) DEMA.js or MACD.js they both use the EMA.js indicator from the same folder.

So you can write an indicator, then write a second indicator that includes the first.

RSI.js is an example of an indicator that's using 2 x SMMA.js indicators which themselves use the SMA.js indicator.

Hope this is what you meant! Smile


RE: Indicator on indicator - kmohammad - 10-27-2018

In update function of indicators, you only can pass candle and price.
how I can send something different like the other indicator result to update function?


RE: Indicator on indicator - askmike - 10-31-2018

Can you be more specific?

The EMA indicator for example takes a single parameter which is called "price":

https://github.com/askmike/gekko/blob/develop/strategies/indicators/EMA.js#L10

But you don't have to put in the candle close, you can put in the output of another indicator.

------

Another way to do what you want is to simply use the results of an indicator directly in the strategy. This is done by the StochRSI strategy for example:

https://github.com/askmike/gekko/blob/develop/strategies/StochRSI.js#L48

Since calculating stoch is so simple we didn't wrap that into an indicator class. Keep in mind that indicators are just simple math equations, with Gekko you can run any javascript code on every new candle. You can implement it however you want, but a nice convention is to put indicator logic into an indicator class. If you want to do funky stuff like run an indicator over another indicator manually glue them together and don't use the `this.addIndicator` interface.


RE: Indicator on indicator - kmohammad - 11-18-2018

(10-31-2018, 09:26 AM)askmike Wrote: Can you be more specific?

The EMA indicator for example takes a single parameter which is called "price":

https://github.com/askmike/gekko/blob/develop/strategies/indicators/EMA.js#L10

But you don't have to put in the candle close, you can put in the output of another indicator.

------

Another way to do what you want is to simply use the results of an indicator directly in the strategy. This is done by the StochRSI strategy for example:

https://github.com/askmike/gekko/blob/develop/strategies/StochRSI.js#L48

Since calculating stoch is so simple we didn't wrap that into an indicator class. Keep in mind that indicators are just simple math equations, with Gekko you can run any javascript code on every new candle. You can implement it however you want, but a nice convention is to put indicator logic into an indicator class. If you want to do funky stuff like run an indicator over another indicator manually glue them together and don't use the `this.addIndicator` interface.

thanks a lot Heart