I used the code with ES #F (1000 barsback) and got only the value of 128 for countbars....
With FromTo, everything is ok!
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;
using PowerLanguage.Function;
namespace PowerLanguage.Strategy {
public class CST_DTest : SignalObject {
public CST_DTest(object _ctx):base(_ctx){}
VariableSeries<double> close;
VariableSeries<DateTime> time;
VariableObject<double> test;
protected override void Create()
{
close = new VariableSeries<double>(this);
time = new VariableSeries<DateTime>(this);
test = new VariableObject<double>(this);
}
protected override void StartCalc()
{
Output.Clear();
InstrumentDataRequest Req;
Req = Bars.Request;
Req.Subscribe2RT = true;
IDataLoaderResult iRes = DataLoader.BeginLoadData(Req, ResultCallback, null);
}
protected override void CalcBar()
{
//Output.WriteLine("{0}, {1}",close.Value,test.Value);
}
void ResultCallback(IDataLoaderResult Result) {
if (Result.IsCompleted)
{
int countbars = Result.Data.Length;
Output.WriteLine("{0}", countbars);
switch (Result.Event)
{
case DataLoadedEvent.History:
{
break;
}
case DataLoadedEvent.RTNewBar:
{
close.Value = Result.RTData.Value.Close;
break;
}
}
}
}
}
}