Back

Indicator chains - help!

I am just starting out with c# and I am trying to get my head around chainning indicators.

As a starting project I have chosen the ema crossover strategy.

What I am trying to do is simple:

take the two emas, calculate the difference between them, calculate an ema of that difference and finally cross the difference with its ema to generate a signal.

emaShort = EMA(symbol, 10, Resolution.Daily);
emaLong = EMA(symbol, 50, Resolution.Daily);
//Here is where things dont work my way
// What is intended is to get the difference between fast and slow
//ema and then get the ema of that difference.
emaDelta = emaShort.Minus(emaLong);
emaDeltaEma = emaDelta.EMA(5);

when I use those variables (emaDelta and emaDeltaEma) in the trading logic below, I get the error message that they dont exist in the context. Obviously I have to register them. But where and how exactly do I do that?

Being able to chain indicators together is a very fine thing and my trading logic relies on this very heavily, it would help me very  much if you could give me a helping hand here.

Andreas.

 

 

Update Backtest








@Andreas, the code snippet is correct, maybe you declared the emaDelta and emaDeltaEma variables incorrectly ?
 

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


@Stefano, thanks very very much man!
That was just what I was looking for.

Being a c# noob I had no idea that "

CompositeIndicator<IndicatorDataPoint>

"

was what the .Minus() extension needed to be declared.
I am still struggling with the documentation...
Also thanks for making it a fxcm forex template (that was two flies:)

I will most certainly soon have a bulk of new and follow-up questions, but it is very reassuring to know that helpful people like yourself are out there.
Andreas.

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed