i'm trying to download Data2 to get BarPriceLevels[] values for history. The value of result.Data2 is always null.
Can you check the code below to find where is the problem?
Is a data provider problem? now i'm using IQFeed .
Thanks so much
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator{
public class TestData2 : IndicatorObject
{
public TestData2(object _ctx):base(_ctx)
{}
private IPlotObject plot1;
private IDataLoaderResult _result;
protected override void Create()
{
// create variable objects, function objects, plot objects etc.
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}
private void ResultCallbackStorico( IDataLoaderResult result )
{
Output.WriteLine( "Evento " + result.Event.ToString() );
if ( result.Event == DataLoadedEvent.History )
{
Output.WriteLine( "Received " + result.Data.Length.ToString() + " historical bars... processing now..." );
if( result.IsCompleted )
{
Output.WriteLine( "Completato : " + result.Data.Length.ToString() );
DataLoader.EndLoadData(_result);
try
{
Output.WriteLine( "Controllo Data 2 " + result.Data2.Length.ToString() );
if( result.Data2 != null )
{
Output.WriteLine( "Valori Data 2 " + result.Data2.Length.ToString() );
}
}
catch( Exception ex )
{
Output.WriteLine( "Eccezione " + ex.Message );
}
}
}
}
protected override void StartCalc()
{
var request = Bars.Request;
request.Resolution = new Resolution {Size = 1, Type = EResolution.Tick};
request.Subscribe2RT = false;
request.Range = new DataRequest( DateTime.Now, 10, DataRequestType.FromTo, Bars.Time[0]);
_result = DataLoader.BeginLoadData( request, ResultCallbackStorico, null );
Output.WriteLine( "Subscribed Storico!" );
}
protected override void CalcBar()
{
// indicator logic
plot1.Set(Bars.Close[0]);
}
}
}