Back

Need help with debugging custom indicator

I'm trying to re-create AwesomeOscillator into QC style so could use it with my backtesting strategies. Recentry I've found out that you can use Debug only inside class which has Initialize method. 

So, here is my AwesomeOscillator class

namespace QuantConnect {
public class AwesomeOscillator : BarIndicator, IIndicatorWarmUpPeriodProvider{
private readonly int _period;

public int WarmUpPeriod { get; }
public override bool IsReady => _slow_sma_queue.Count() == _period_slow;

public int _period_fast;
public int _period_slow;
private List<decimal> _fast_sma_queue = new List<decimal>();
private List<decimal> _slow_sma_queue = new List<decimal>();

public AwesomeOscillator(string name, int period_fast = 5, int period_slow = 34) : base(name){
_period_fast = period_fast;
_period_slow = period_slow;

}
protected override decimal ComputeNextValue(IBaseDataBar input){
// Calculation AO = sma((high+low)/2, lengthAO1) - sma((high+low)/2, lengthAO2)

decimal CurrentQueue = ((input.Low + input.High)/ 2);
decimal fast_sma = 0m;
decimal slow_sma = 0m;
if(_period_fast >= _fast_sma_queue.Count()){
_fast_sma_queue.Add(CurrentQueue);
} else {
fast_sma = _fast_sma_queue.Sum() / _period_fast;
}

if(_period_slow >= _slow_sma_queue.Count()){
_slow_sma_queue.Add(CurrentQueue);
} else {
slow_sma = _slow_sma_queue.Sum() / _period_slow;
}
return (fast_sma - slow_sma);
}
}
}

It gives me nothing as a result, but I cannot even debug it. 

Would love to read some of your advices, thanks

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.


Hi Super,

I created a sample project with your indicator and I was able to debug it correctly, see the attached image, sharing the sample project I used. The issue you experienced could have been related to the way the indicator is being registered/setup - If you can share the complete algorithm used we might be able to provide more help.

37136_1566418948.jpg

 

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.


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