/api/guides/indicators Defect: Referencing Custom Indicators

Created at 27 Nov 2014, 06:37
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!
centracube's avatar

centracube

Joined 23.11.2014

/api/guides/indicators Defect: Referencing Custom Indicators
27 Nov 2014, 06:37


BUG REPORT:

Bug Name: Fail to compile example code from Indicator Guide.
Bug ID: (It will be automatically created by the BUG Tracking tool that your organization uses once you save this bug)
Area Path: /api/guides/indicators
Build Number: Software Version Number 1.27.133
Severity: ? (High/Medium/Low) or 1
Priority: ? (High/Medium/Low) or 1
Assigned to: 
Reported By: CentraCube
Reported On: 11-26-2014
Reason: Defect
Status: New/Open/Active (Depends on the Tool you are using)
Environment: Windows 8 64-bit

Description:
The unmodified application code fails to compile. 

Steps To Reproduce:


1) From Referencing Custom Indicators copy your example application code into a newly created indicator:

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
public class SampleReferenceSMA : Indicator
{
    [Parameter("Source")]
    public DataSeries Source { get; set; }
 
    [Parameter(DefaultValue = 14)]
    public int SmaPeriod { get; set; }
 
    [Output("Referenced SMA Output")]
    public IndicatorDataSeries refSMA { get; set; }
 
    private SampleSMA sma;
 
    protected override void Initialize()
    {
        sma = Indicators.GetIndicator(Source, SmaPeriod);
    }
 
    public override void Calculate(int index)
    {
        refSMA[index] = sma.Result[index];
    }
}

2. I assume you intend to have syntax compliant code examples:

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class SampleReferenceSMA : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter(DefaultValue = 14)]
        public int SmaPeriod { get; set; }

        [Output("Referenced SMA Output")]
        public IndicatorDataSeries refSMA { get; set; }

        private SampleSMA sma;

        protected override void Initialize()
        {
            sma = Indicators.GetIndicator(Source, SmaPeriod);
        }

        public override void Calculate(int index)
        {
            refSMA[index] = sma.Result[index];
        }
    }
}

3. Click the Manage References button,  In the Reference Manager select the Sample EMA and click Apply.

4. Click Build. 

Error CS0411: The type arguments for method 'cAlgo.API.Internals.IIndicatorsAccessor.GetIndicator<TIndicator>(params object[])' cannot be inferred from the usage. Try specifying the type arguments explicitly.

6. Reference your API document: /api/reference/internals/iindicatorsaccessor/getindicator-ff89

Syntax

public TIndicator GetIndicator(Object[] parameterValues)

7. Update your example code with the correct syntax. 

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class SampleReferenceSMA : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter(DefaultValue = 14)]
        public int SmaPeriod { get; set; }

        [Output("Referenced SMA Output")]
        public IndicatorDataSeries refSMA { get; set; }

        private SampleSMA sma;

        protected override void Initialize()
        {
            sma = Indicators.GetIndicator<SampleSMA>(Source, SmaPeriod);
        }

        public override void Calculate(int index)
        {
            refSMA[index] = sma.Result[index];
        }
    }
}

8. Build

Output: Build Successful

 

 


@centracube
Replies

centracube
03 Dec 2014, 02:57

Hello cTrader,

I took the time to write a detailed defect report so you can correct the issue. I understand your support organization is very busy. One of the benefits of community is the ability the receive free feedback from your customer base. Is anyone from your organization planning on acknowledging the issue and updating the status of the issue? 

CentraCube


@centracube

Spotware
03 Dec 2014, 15:31

Dear Trader,

Thank you for your report. The issue has been fixed.


@Spotware