Topic: Strange error. The program hangs.
I apologize in advance for my English. I've been programming for a year, but this is the first time with me. Having reduced the error search area to 2 lines, I can not find it. Here is the code.
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;
}
}
}
After passing the first nested loop of the 4th level, the program hangs. I can not understand what's the matter. Help me please.