I then applied the same dataloader study to a 15 minute chart. I noticed that there were 130 bars on the 15 minute chart going back 5 days and there were only 104 bars on Renko chart going back 5 days. So for the first 104 bars, the close of the dataloader study matched the close of the Renko chart that I originally applied it to. But on the 15 minute chart there were an additional 26 bars that were being calculated with Renko data. I am not sure where the data is coming from. On the renko chart bar 104 was the close on March 31st but bar 104 on the 15 minute chart was the close on March 30.
I tried changing the datarequest a few times to only download 5 days of data or maybe 104 days of data just to see if anything changes. But nothing seems to work
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using System.Threading;
using System.Collections.Generic;
namespace PowerLanguage.Indicator
{
public class Test_DataLoaderWaitingLoading2 : IndicatorObject
{
public Test_DataLoaderWaitingLoading2(object _ctx):base(_ctx){}
private IPlotObject plot1;
private List<Bar> m_home = new List<Bar>();
WaitHandle [] waitHandles = new WaitHandle[]
{
new AutoResetEvent(false)
};
protected override void Create()
{
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}
protected override void StartCalc()
{
Output.Clear();
}
protected override void CalcBar()
{
InstrumentDataRequest Req = Bars.Request;
Req.Subscribe2RT = true;
Req.Resolution = Resolution.CreateRenko(EResolution.Tick, 1, RenkoBoxSizeType.FIXEDPRICE,.1, true, false, true, false);
Req.Resolution.Attributes.Add(1090,0);
var dataReq = new DataRequest(DateTime.Now, Bars.FullSymbolData.Count, DataRequestType.DaysBack, DateTime.MinValue);
Req.FilterOutOfRangeData = true;
Req.Range.ToAlwaysIsNow = false;
IDataLoaderResult iRes = DataLoader.BeginLoadData(Req, _Result, waitHandles[0]);
WaitHandle.WaitAny(waitHandles); // Waiting for data
DataLoader.EndLoadData(iRes);
if (Bars.Status == EBarState.Close)
{
int index = (Bars.CurrentBar - 1);//, (m_home.Count - 1));
if (index > 0)
{
plot1.Set(m_home[index].Close);
}
}
;
}
protected void _Result( IDataLoaderResult _res )
{
AutoResetEvent _are = (AutoResetEvent)_res.State;
if (_res.IsCompleted)
{
switch (_res.Event)
{
case DataLoadedEvent.History:
m_home.AddRange(_res.Data);
break;
case DataLoadedEvent.RTNewBar:
if(_res.RTData.HasValue)
m_home.Add(_res.RTData.Value);
break;
default:
break;
}
}
else
Output.WriteLine("------> No Data");
_are.Set();
}
}
}