None of my indicators will work on other charts

Created at 20 Feb 2013, 06:23
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
lec0456's avatar

lec0456

Joined 14.11.2012

None of my indicators will work on other charts
20 Feb 2013, 06:23


Recently, the indicators that I built will compile and work with the instance attached to the indicator.  But when I try to select the indicator from the custom indicator list in ctrader or one of the other instances in cAlgo, it will not work??

Any ideas what is going on?


@lec0456
Replies

lec0456
20 Feb 2013, 06:25

RE:
lec0456 said:

Recently, the indicators that I built will compile and work with the instance attached to the indicator.  But when I try to select the indicator from the custom indicator list in ctrader or one of the other instances in cAlgo, it will not work??

Any ideas what is going on?

Correction, overlay indicators work.  histogram indicators or indicators where IsOverlay =false will not work


@lec0456

admin
20 Feb 2013, 09:31

Hello,

You may send us the code so that we can investigate it at engage@ctrader.com.


@admin

lec0456
20 Feb 2013, 11:17

RE:
admin said:

Hello,

You may send us the code so that we can investigate it at engage@ctrader.com.

Its not the code its all my custom indicators that are not Overlays.  I also tryed pulling it up from other broker platforms and I get the same thing, a blank indicator...


@lec0456

lec0456
20 Feb 2013, 11:20

Anyway, here is the code for one...
using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators 
{
    [Indicator(IsOverlay = false, ScalePrecision = 3, AutoRescale=true)]
    public class myMultiMADifferential: Indicator
    {
		[Parameter(DefaultValue = 10)]
        public int paramLimit { get; set; }
        [Parameter(DefaultValue = 60)]
        public int MA2Periods { get; set; }
        [Parameter(DefaultValue = 120)]
        public int MA3Periods { get; set; }
        [Parameter(DefaultValue = 240)]
        public int MA4Periods { get; set; }
		       
        [Output("MA1MA4Diff", PlotType = PlotType.Histogram, Thickness = 2, Color = Colors.Purple)]
        public IndicatorDataSeries MA1MA4Diff { get; set; }
        [Output("MA1MA3Diff", PlotType = PlotType.Line, Thickness = 1, Color = Colors.MediumPurple)]
        public IndicatorDataSeries MA1MA3Diff { get; set; }
        [Output("MA1MA2Diff", PlotType = PlotType.Line, Thickness = 2, Color = Colors.Yellow)]
        public IndicatorDataSeries MA1MA2Diff { get; set; }
        
        [Output("MA2MA4Diff", PlotType = PlotType.Line, Thickness = 1, Color = Colors.Navy)]
        public IndicatorDataSeries MA2MA4Diff { get; set; }
        [Output("MA2MA3Diff", PlotType = PlotType.Line, Thickness = 2, Color = Colors.Blue)]
        public IndicatorDataSeries MA2MA3Diff { get; set; }
        [Output("MA3MA4Diff", PlotType = PlotType.Line, Thickness = 2, Color = Colors.Red)]
        public IndicatorDataSeries MA3MA4Diff { get; set; }
  
        [Output("UpperLimit", PlotType = PlotType.Line, LineStyle=LineStyle.DotsRare,Thickness = 1, Color = Colors.Red)]
        public IndicatorDataSeries UpperLimit { get; set; }
        [Output("LowerLimit", PlotType = PlotType.Line, LineStyle=LineStyle.DotsRare, Thickness = 1, Color = Colors.Red)]
        public IndicatorDataSeries LowerLimit { get; set; }

		private LinearRegressionForecast linreg;
		private SimpleMovingAverage MA1;
		private SimpleMovingAverage MA2;
		private SimpleMovingAverage MA3;
        private SimpleMovingAverage MA4;
       

        protected override void Initialize()
        {
            linreg= Indicators.LinearRegressionForecast(MarketSeries.Open,9);
            MA1= Indicators.SimpleMovingAverage(linreg.Result,5);
            MA2 = Indicators.SimpleMovingAverage(MarketSeries.Open,MA2Periods);
            MA3 = Indicators.SimpleMovingAverage(MarketSeries.Open,MA3Periods);
            MA4 = Indicators.SimpleMovingAverage(MarketSeries.Open,MA4Periods);
        }

        public override void Calculate(int index)
        {			
			if(double.IsNaN(MA1.Result[index]))return; //** skip printing bar until moving average data is calculated
			if(double.IsNaN(MA2.Result[index]))return;
            if(double.IsNaN(MA3.Result[index]))return;
			if(double.IsNaN(MA4.Result[index]))return;

	        double MA1_MA2=Math.Round((MA1.Result[index]-MA2.Result[index])/Symbol.PipSize,3);  // Difference
			double MA1_MA3=Math.Round((MA1.Result[index]-MA3.Result[index])/Symbol.PipSize,3);
			double MA1_MA4=Math.Round((MA1.Result[index]-MA4.Result[index])/Symbol.PipSize,3);
			double MA2_MA3=Math.Round((MA2.Result[index]-MA3.Result[index])/Symbol.PipSize,3);  // Difference
			double MA2_MA4=Math.Round((MA2.Result[index]-MA4.Result[index])/Symbol.PipSize,3); 
			double MA3_MA4=Math.Round((MA3.Result[index]-MA4.Result[index])/Symbol.PipSize,3);  // Difference
			
			UpperLimit[index]=paramLimit;
			LowerLimit[index]=-paramLimit;
			
			MA1MA4Diff[index]=MA1_MA4;
			MA1MA2Diff[index]=MA1_MA2;
			MA2MA3Diff[index]=MA2_MA3;
			MA1MA3Diff[index]=MA1_MA3;
			MA3MA4Diff[index]=MA3_MA4;
			MA2MA4Diff[index]=MA2_MA4;
		}
    }
}

 


@lec0456