Replies

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

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
08 Sep 2016, 11:15 ( Updated at: 21 Dec 2023, 09:20 )


@chkmitnb

chkmitnb
15 Jun 2016, 11:44

RE:

Spotware said:

Dear Trader,

Please have a look at the examples of the Last() Method.

Dear Spotware

      The Last() Method, I think the answer not complete . I would like compare between the open price bar No.1 and  Trend line as same period time bar No.1 by  the cAlgo. The Last() Method, The cAlgo can get the open price of bar No.1. But I not sure it can get the trendline price as same period time of Bar No.1. If the cAlgo can get the price each period time by the Last() Method , please show me the example.


@chkmitnb

chkmitnb
10 Jun 2016, 08:23

RE:

tmc. said:

Try this.

for (int i = 0; i < DaysToDraw; i++)
{
    var startOfDay = today.AddDays(i);
    var endOfDay = today.AddDays(i-1);

    ChartObjects.DrawLine("line" + i, startOfDay, high, endOfDay, high, Colors.Black, 1);
}

 

10/06/2016 11:43:43.296 | Crashed in OnTick with ArgumentException: The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly.  For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. Parameter name: sourceTimeZone

 

I try  the upper code, But it have some message. How  I can to do?.


@chkmitnb