Indicator on indicator
#1
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
  Reply
#2
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
  Reply
#3
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?
  Reply
#4
Can you be more specific?

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

https://github.com/askmike/gekko/blob/de...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/de...RSI.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.
  Reply
#5
(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/de...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/de...RSI.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
  Reply


Forum Jump:


Users browsing this thread: