strange error

Created at 05 Apr 2018, 10:35
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!
TR

travkinsm1

Joined 05.04.2018

strange error
05 Apr 2018, 10:35


Hello! I've been writing for a year on the calgo. But this has not happened to me for a long time. In the simplest program I rechecked everything probably 20 times - in what a mistake I can not understand. The program hangs. Help me please!

using System;
using System.Linq;
using System.Windows;
using System.Runtime.InteropServices;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class Candles : Robot
    {
        [Parameter("Depth of analise in hour", DefaultValue = 720)]
        public int depthInHour { get; set; }
        public static int historyLength = 30000;
        public struct history
        {
            public double result;
            public double price;
            public int direction;
            public DateTime date;
        }
        public struct streem
        {
            public int minNum, maxNum, countPlus, countMinus;
            public history[] historyDatas
            {
                get { return new history[historyLength]; }
            }
        }
        public struct datas
        {
            public double balance, dropdown, dropdownNew, max, maxDropdown, maxDropdownNew;
            public DateTime DateDropdown, DateDropdownNew;
            public int transactions;
            public streem transactionHistory;
        }

        public int minCandleCount = 4, maxCandleCount = 12, stepCandleCount = 1;
        public int minCandleInOption = 1, maxCandleInOption = 4, stepCandleInOption = 1;
        public double minReliability = 2.5, maxReliability = 4, stepReliability = 0.5;
        public double minVolatility = 0.0001, maxVolatility = 0.0004, stepVolatility = 0.0001;
        public int countCandleCount, countCandleInOption, countReliability, countVolatility;
        public int curCandleCount, arrCandleCount, curCandleInOption, arrCandleInOption, arrReliability, arrVolatility;
        public double curVolatility, curReliability;

        public datas[,,,] arr;
        public double price;
        public DateTime TransTime;
        public struct parameters
        {
            public int CandleCount;
            public int CandleInOption;
            public double Reliability;
            public double Volatility;
        }
        public parameters bestParameters;
        public double bestResult;
        public DateTime depth;
        public int direction = 0;
        protected override void OnStart()
        {
            Int64 t = new TimeSpan(depthInHour, 0, 0).Ticks;
            depth = new DateTime(t);

            countCandleCount = 9;
            countCandleInOption = 4;
            countReliability = 4;
            countVolatility = 4;

            arr = new datas[countCandleCount, countCandleInOption, countReliability, countVolatility];
            int k = 100;
            for (curCandleCount = minCandleCount,arrCandleCount = 0; curCandleCount <= maxCandleCount; curCandleCount += stepCandleCount,arrCandleCount++)
            {
                Print("1 ", curCandleCount);
                for (curCandleInOption = minCandleInOption,arrCandleInOption = 0; curCandleInOption <= maxCandleInOption; curCandleInOption += stepCandleInOption,arrCandleInOption++)
                {
                    Print("2 ", curCandleInOption);
                    for (curReliability = minReliability,arrReliability = 0; curReliability <= maxReliability; curReliability += stepReliability,arrReliability++)
                    {
                        Print("3 ", curReliability);
                        for (curVolatility = minVolatility,arrVolatility = 0; curVolatility <= maxVolatility; curVolatility += stepVolatility,arrVolatility++)
                        {
                            Print("4 ", curVolatility);
                            int i = MarketSeries.OpenTime.Count - k;
                            DateTime dt = MarketSeries.OpenTime[i];
                            Print(dt);
                            while (dt.AddMinutes(30).Ticks < DateTime.Now.Ticks)
                            {
                                Print(dt, " ", dt.AddMinutes(30).Ticks, " ", DateTime.Now.Ticks, " ", i, " ", MarketSeries.OpenTime.Count);
                                dt = MarketSeries.OpenTime[++i];
                            }
                        }
                    }
                }
            }
            Print("The end");
        }
        protected override void OnTick()
        {
            //OnStop();
        }

        protected override void OnStop()
        {

            // Put your deinitialization logic here
        }
        protected int Frame()
        {
            if (TimeFrame == TimeFrame.Minute15)
                return 15;
            else if (TimeFrame == TimeFrame.Minute5)
                return 5;
            else if (TimeFrame == TimeFrame.Minute4)
                return 4;
            else if (TimeFrame == TimeFrame.Minute3)
                return 3;
            else if (TimeFrame == TimeFrame.Minute2)
                return 2;
            else if (TimeFrame == TimeFrame.Minute5)
                return 1;
            else
                return 0;
        }
    }
}

 


@travkinsm1
Replies

PanagiotisCharalampous
05 Apr 2018, 14:35

Hi travkinsm1,

Thanks for posting in our forum. When you say it hangs, what do you mean? Does in throw an exception? Can you send us screenshots? Could you also provide us with parameters that we can use to reproduce your problem?

Best Regards,

Panagiotis


@PanagiotisCharalampous