Platform Freezing?
Platform Freezing?
24 Nov 2012, 09:49
I wrote a simple robot to inspect the data but it seems to be hanging my system. can you tell me if there is something wrong with this code:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot]
public class DataInspector : Robot
{
[Parameter("MA Type")]
public MovingAverageType MAType { get; set; }
[Parameter]
public DataSeries SourceSeries { get; set; }
private MovingAverage LT_Ma;
private MovingAverage ST_Ma;
private MovingAverage EMA200;
protected override void OnStart()
{
ST_Ma = Indicators.MovingAverage(SourceSeries, 10, MAType);
LT_Ma = Indicators.MovingAverage(SourceSeries, 50 , MAType);
EMA200 = Indicators.MovingAverage(SourceSeries, 200 , MAType);
Print(Server.Time.ToString("MM/dd/yyyy HH:mm")+" *******************************************************************Start************************************************************************");
}
protected override void OnBar()
{
Print(Server.Time.ToString("MM/dd/yyyy HH:mm")+" **********************************************************************Bar************************************************************************");
}
protected override void OnTick()
{
int t0 = ST_Ma.Result.Count - 1;
int t1 = ST_Ma.Result.Count - 2;
int t2 = ST_Ma.Result.Count - 3;
int t3 = ST_Ma.Result.Count - 4;
double ST_Ma0 = Math.Round(ST_Ma.Result[t0],5);
double ST_Ma1 = Math.Round(ST_Ma.Result[t1],5);
double ST_Ma2 = Math.Round(ST_Ma.Result[t2],5);
double ST_Ma3 = Math.Round(ST_Ma.Result[t3],5);
double LT_Ma0 = Math.Round(LT_Ma.Result[t0],5);
double LT_Ma1 = Math.Round(LT_Ma.Result[t1],5);
double LT_Ma2 = Math.Round(LT_Ma.Result[t2],5);
double LT_Ma3 = Math.Round(LT_Ma.Result[t3],5);
double EMA2000 = Math.Round(EMA200.Result[t0],5);
double EMA2001 = Math.Round(EMA200.Result[t1],5);
double EMA2002 = Math.Round(EMA200.Result[t2],5);
double EMA2003 = Math.Round(EMA200.Result[t3],5);
Print("T0 "+Server.Time.ToString("MM/dd/yyyy HH:mm")+" **********************************************************************Tick************************************************************************");
Print("{0,25}{1,19}{2,21}{3,20}{4,22}","Period","t-4","t-3","t-2","t-1");
Print("{0,22}{1,16:0.00000}{2,16:0.00000}{3,16:0.00000}{4,16:0.00000}","EMa200",EMA2003,EMA2002,EMA2001,EMA2000);
Print("{0,23}{1,16:0.00000}{2,16:0.00000}{3,16:0.00000}{4,16:0.00000}","LT_Ma",LT_Ma3,LT_Ma2,LT_Ma1,LT_Ma0);
Print("{0,22}{1,16:0.00000}{2,16:0.00000}{3,16:0.00000}{4,16:0.00000}","ST_Ma",ST_Ma3,ST_Ma2,ST_Ma1,ST_Ma0);
}//** End of OnTick **************************
}//** End of class **********
}//** End of namespace **********
Replies
lec0456
27 Nov 2012, 00:17
Well, it still cause cAlgo to "freeze" on my system. The memory consumption goes through the roof over about 1.5 gigs. But I used a work around that seems to work for my purposes, which is to inspect a sample of the data, especially upon starting the robot. I just placed a counter so that it only returns a fixed number of bars. I set it to 100 or 1000 and it works. Don't know why though. But since you say it works on your system maybe its something with my computer. Thanks!
@lec0456
admin
26 Nov 2012, 11:23
Your code is working properly. It may be a different issue.
If you are still experiencing problems let us know so that we can investigate further.
@admin