Get data valiable double type form the Indicator class

Created at 03 Jan 2017, 09:29
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!
CH

chkmitnb

Joined 25.01.2016

Get data valiable double type form the Indicator class
03 Jan 2017, 09:29


Dear Sir

      I try get the valiablre  double type from the  Indicator class. But the data as get the Indicator class incorrect. I don't know, What is wrong. Please help me for this wrong.

///////////////////////////////// Indicator class

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class test_1 : Indicator
    {
        [Parameter("Data 1", DefaultValue = 0)]
        public int Data1 { get; set; }

        [Parameter("Data 2", DefaultValue = 0)]
        public int Data2 { get; set; }

        [Output("Result1")]
        public double Result_1 { get; set; }

        [Output("Result2")]
        public double Result_2 { get; set; }

        protected override void Initialize()
        {
            // Initialize and create nested indicators
            //      Data1 = 30;
            //     Data2 = 10;
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...

            Result_1 = Data1 + Data2;
            Result_2 = Data1 - Data2;

        }
    }
}

////////////////////////////////// cBot Class

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ddd : Robot
    {
        [Parameter("Data 1", DefaultValue = 0)]
        public int Data1 { get; set; }

        [Parameter("Data 2", DefaultValue = 0)]
        public int Data2 { get; set; }


        test_1 test;
        protected override void OnStart()
        {
            // Put your initialization logic here
            test = Indicators.GetIndicator<test_1>(Data1, Data2);
        }

        protected override void OnTick()
        {
            // Put your core logic here
            Print("Result_1 ={0}", test.Result_1);
            Print("Result_2 ={0}", test.Result_2);
            Stop();
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 

//////////////////////////////////

 

 

 

 


@chkmitnb
Replies

chkmitnb
03 Jan 2017, 09:29

RE:
chkmitnb said:

Dear Sir

      I try get the valiablre  double type from the  Indicator class. But the data as get the Indicator class incorrect. I don't know, What is wrong. Please help me for this wrong.

///////////////////////////////// Indicator class

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class test_1 : Indicator
    {
        [Parameter("Data 1", DefaultValue = 0)]
        public int Data1 { get; set; }

        [Parameter("Data 2", DefaultValue = 0)]
        public int Data2 { get; set; }

        [Output("Result1")]
        public double Result_1 { get; set; }

        [Output("Result2")]
        public double Result_2 { get; set; }

        protected override void Initialize()
        {
            // Initialize and create nested indicators
            //      Data1 = 30;
            //     Data2 = 10;
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...

            Result_1 = Data1 + Data2;
            Result_2 = Data1 - Data2;

        }
    }
}

////////////////////////////////// cBot Class

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ddd : Robot
    {
        [Parameter("Data 1", DefaultValue = 0)]
        public int Data1 { get; set; }

        [Parameter("Data 2", DefaultValue = 0)]
        public int Data2 { get; set; }


        test_1 test;
        protected override void OnStart()
        {
            // Put your initialization logic here
            test = Indicators.GetIndicator<test_1>(Data1, Data2);
        }

        protected override void OnTick()
        {
            // Put your core logic here
            Print("Result_1 ={0}", test.Result_1);
            Print("Result_2 ={0}", test.Result_2);
            Stop();
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 

//////////////////////////////////

 

 

 

 



@chkmitnb

chkmitnb
03 Jan 2017, 09:30 ( Updated at: 21 Dec 2023, 09:20 )

RE:

chkmitnb said:

Dear Sir

      I try get the valiablre  double type from the  Indicator class. But the data as get the Indicator class incorrect. I don't know, What is wrong. Please help me for this wrong.

///////////////////////////////// Indicator class

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class test_1 : Indicator
    {
        [Parameter("Data 1", DefaultValue = 0)]
        public int Data1 { get; set; }

        [Parameter("Data 2", DefaultValue = 0)]
        public int Data2 { get; set; }

        [Output("Result1")]
        public double Result_1 { get; set; }

        [Output("Result2")]
        public double Result_2 { get; set; }

        protected override void Initialize()
        {
            // Initialize and create nested indicators
            //      Data1 = 30;
            //     Data2 = 10;
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...

            Result_1 = Data1 + Data2;
            Result_2 = Data1 - Data2;

        }
    }
}

////////////////////////////////// cBot Class

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ddd : Robot
    {
        [Parameter("Data 1", DefaultValue = 0)]
        public int Data1 { get; set; }

        [Parameter("Data 2", DefaultValue = 0)]
        public int Data2 { get; set; }


        test_1 test;
        protected override void OnStart()
        {
            // Put your initialization logic here
            test = Indicators.GetIndicator<test_1>(Data1, Data2);
        }

        protected override void OnTick()
        {
            // Put your core logic here
            Print("Result_1 ={0}", test.Result_1);
            Print("Result_2 ={0}", test.Result_2);
            Stop();
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 

//////////////////////////////////

 

 

 

 


@chkmitnb

... Deleted by UFO ...