DataLoader Question

Questions about MultiCharts .NET and user contributed studies.
Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

DataLoader Question

Postby Alexxx » 16 Oct 2014

Code: Select all

InstrumentDataRequest Request = Bars.Request;
Request.Range.RequestType = DataRequestType.FromTo;
Request.Range.To = new DateTime(Bars.Time[0].Year, Bars.Time[0].Month, Bars.Time[0].Day, 23, 59, 59);
Request.Range.From = new DateTime(Bars.Time[0].Year, Bars.Time[0].Month, Bars.Time[0].Day, 0, 0, 0).AddDays(-1 * DaysBackStartCalc);
Request.FilterOutOfRangeData = false;
Request.Resolution = new Resolution { Size = 1, Type = EResolution.Tick };

Request.QuoteField = RequestQuoteField.Trade;
DataLoader.BeginLoadData(Request, OnData, null);

Request.QuoteField = RequestQuoteField.Ask;
DataLoader.BeginLoadData(Request, OnData, null);

Request.QuoteField = RequestQuoteField.Bid;
DataLoader.BeginLoadData(Request, OnData, null);
How to Control that DataLoader.BeginLoadData is ending loading?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: DataLoader Question

Postby Henry MultiСharts » 17 Oct 2014

Hello Alexxx,

Some users have added thread blocking code to do that. We still recommend using sleeps (Thread.Sleep(100);). Waiting can also be implemented with the help of events. Please check the attached code.
Attachments
Test_DataLoaderWaitingLoading.pln
(1.61 KiB) Downloaded 469 times

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: DataLoader Question

Postby Alexxx » 25 Oct 2014

Can u advice me?

I`m using Dataloader to load stream trade/ask/bid in period Bars.Time[31] => Bars.Time[1] on every close bar in tick resolution. In Dataloader using Thread.Sleep(200) for waiting full data on last 30 bars. But its so long testing on playback.
How I can optimize speed of testing?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: DataLoader Question

Postby Henry MultiСharts » 27 Oct 2014

In order to get the best performance please use the events instead of sleeps.

RJay33
Posts: 4
Joined: 21 Oct 2014
Has thanked: 2 times

Re: DataLoader Question

Postby RJay33 » 27 Oct 2014

Hi,

Is there a way to capture the price, volume and timestamp updates to the method OnData and display them in the output screen for the previously posted code shown below?

Request.QuoteField = RequestQuoteField.Trade;
DataLoader.BeginLoadData(Request, OnData, null);

Request.QuoteField = RequestQuoteField.Ask;
DataLoader.BeginLoadData(Request, OnData, null);

Request.QuoteField = RequestQuoteField.Bid;
DataLoader.BeginLoadData(Request, OnData, null);

Thanks

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: DataLoader Question

Postby Alexxx » 27 Oct 2014

Thanks. I did as you said.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: DataLoader Question

Postby Henry MultiСharts » 28 Oct 2014

Hi,

Is there a way to capture the price, volume and timestamp updates to the method OnData and display them in the output screen for the previously posted code shown below?

Request.QuoteField = RequestQuoteField.Trade;
DataLoader.BeginLoadData(Request, OnData, null);

Request.QuoteField = RequestQuoteField.Ask;
DataLoader.BeginLoadData(Request, OnData, null);

Request.QuoteField = RequestQuoteField.Bid;
DataLoader.BeginLoadData(Request, OnData, null);

Thanks
You can use Output.WriteLine to do that.

A sample code that subscribes to realtime data and outputs the realtime bar values in Output tab of PLEditor window can be found here.

Releated article in MultiCharts.NET-Programming Guide:
4.7.4 Receiving the data for any symbol and any resolution. DataLoader.

RJay33
Posts: 4
Joined: 21 Oct 2014
Has thanked: 2 times

Re: DataLoader Question

Postby RJay33 » 30 Oct 2014

Hi,

Thank you for your response.

I am still unable to make the code work.

The working example you provided deals with "Bar" data.

I am requesting a working example of "RequestQuoteField" data.

I need " Volume, Price, and TimeStamp" for Bid, Ask, and Trade updates from the data provider.

Also the instructions on collecting QuoteField data uses different instruments for bid and ask.

I need bid and ask for the same instrument.

What is the correct symbol name for CL?

I tried "CLEZ14" and "CLE/Z14" but neither complied.

Thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: DataLoader Question

Postby Henry MultiСharts » 31 Oct 2014

RJay33, which instrument do you use ?
Please provide the code you are using and specify the particular difficulty you have with it.

RJay33
Posts: 4
Joined: 21 Oct 2014
Has thanked: 2 times

Re: DataLoader Question

Postby RJay33 » 31 Oct 2014

Hi,

I just want to let you guys know that I am a 3rd party developer on another trading platform.

I was requested to branch out onto your platform by someone looking to private label your .NET platform.

To get a feel for your platform I took on two projects.

------------------------------------------------------------------------------------------------------
First, create an indicator that duplicates the time and sales window in the output window.

I needed Bid, Ask, and Trade data from the exchange in real time to make this happen.

I could not find this data on your platform. This project is at a standstill.
------------------------------------------------------------------------------------------------------
This led to project two. Build a Method that allows for easy access to the exchange data that updates in real time.

I am trying to use your dataloader to create this Method.

Here is the code so far.

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using System.Collections.Generic;

namespace PowerLanguage.Indicator{

public class BidAskDataLoader : IndicatorObject
{

public BidAskDataLoader(object _ctx):base(_ctx){}

public delegate void LoadDataCallback(IDataLoaderResult Result);

private IDataLoaderResult iRes;

private IPlotObject plot1;

private IPlotObject m_spreadPlot;



protected override void Create() {

plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
m_spreadPlot = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}

protected override void StartCalc() {

Output.Clear();
iRes = null;

InstrumentDataRequest Req = Bars.Request;
Req.Resolution = new Resolution { Size = 1, Type = EResolution.Tick };
Req.Subscribe2RT = true;

Req.Range = DataRequest.CreateBarsBack(DateTime.Now, 1);
Req.FilterOutOfRangeData = true;
Req.Subscribe2RT = true;

Req.QuoteField = RequestQuoteField.Trade;
// Request.Symbol = "CLEZ14";
DataLoader.BeginLoadData(Req, OnData, null);


Req.QuoteField = RequestQuoteField.Ask;
// Request.Symbol = "CLEZ14";
DataLoader.BeginLoadData(Req, OnData, null);


Req.QuoteField = RequestQuoteField.Bid;
// Request.Symbol = "CLE/Z14";
DataLoader.BeginLoadData(Req, OnData, null);

}

public void OnData(IDataLoaderResult Result)
{
if (Result.Request.QuoteField == RequestQuoteField.Ask)Output.WriteLine("Bars.StatusLine.Ask = {0}", RequestQuoteField.Ask );

if (Result.Request.QuoteField == RequestQuoteField.Bid)Output.WriteLine("Bars.StatusLine.Bid = {0}", RequestQuoteField.Bid );

if (Result.Request.QuoteField == RequestQuoteField.Trade)Output.WriteLine("Bars.StatusLine.Trade = {0}", RequestQuoteField.Trade );

Output.WriteLine("-------------------");

}


protected override void CalcBar(){
// indicator logic
plot1.Set(Bars.Close[0]);
}
}
}

Symbol fields are commented out because the symbols will not compile.

What are the correct symbol names for CL, TF, and ES?

Because I have never been to school to learn programming, I need a little help.

I know which updates are Bid, Ask, and Trade.

I do not know how to access the Price, Volume, and TimeStamp of each update from the exchange.

The platform I currently use provides a Method that has all this information that programmers can access in real time when the markets are open.

If possible, please provide code of a working example of how to access these updates from the exchange on this platform for the benefit of all coders here and please consider adding it to your platform as a standard feature in the future.

Thanks

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: DataLoader Question

Postby Alexxx » 03 Nov 2014

Hi,

I just want to let you guys know that I am a 3rd party developer on another trading platform.

I was requested to branch out onto your platform by someone looking to private label your .NET platform.

To get a feel for your platform I took on two projects.

------------------------------------------------------------------------------------------------------
First, create an indicator that duplicates the time and sales window in the output window.

I needed Bid, Ask, and Trade data from the exchange in real time to make this happen.

I could not find this data on your platform. This project is at a standstill.
------------------------------------------------------------------------------------------------------
This led to project two. Build a Method that allows for easy access to the exchange data that updates in real time.

I am trying to use your dataloader to create this Method.

Here is the code so far.

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using System.Collections.Generic;

namespace PowerLanguage.Indicator{

public class BidAskDataLoader : IndicatorObject
{

public BidAskDataLoader(object _ctx):base(_ctx){}

public delegate void LoadDataCallback(IDataLoaderResult Result);

private IDataLoaderResult iRes;

private IPlotObject plot1;

private IPlotObject m_spreadPlot;



protected override void Create() {

plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
m_spreadPlot = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}

protected override void StartCalc() {

Output.Clear();
iRes = null;

InstrumentDataRequest Req = Bars.Request;
Req.Resolution = new Resolution { Size = 1, Type = EResolution.Tick };
Req.Subscribe2RT = true;

Req.Range = DataRequest.CreateBarsBack(DateTime.Now, 1);
Req.FilterOutOfRangeData = true;
Req.Subscribe2RT = true;

Req.QuoteField = RequestQuoteField.Trade;
// Request.Symbol = "CLEZ14";
DataLoader.BeginLoadData(Req, OnData, null);


Req.QuoteField = RequestQuoteField.Ask;
// Request.Symbol = "CLEZ14";
DataLoader.BeginLoadData(Req, OnData, null);


Req.QuoteField = RequestQuoteField.Bid;
// Request.Symbol = "CLE/Z14";
DataLoader.BeginLoadData(Req, OnData, null);

}

public void OnData(IDataLoaderResult Result)
{
if (Result.Request.QuoteField == RequestQuoteField.Ask)Output.WriteLine("Bars.StatusLine.Ask = {0}", RequestQuoteField.Ask );

if (Result.Request.QuoteField == RequestQuoteField.Bid)Output.WriteLine("Bars.StatusLine.Bid = {0}", RequestQuoteField.Bid );

if (Result.Request.QuoteField == RequestQuoteField.Trade)Output.WriteLine("Bars.StatusLine.Trade = {0}", RequestQuoteField.Trade );

Output.WriteLine("-------------------");

}


protected override void CalcBar(){
// indicator logic
plot1.Set(Bars.Close[0]);
}
}
}

Symbol fields are commented out because the symbols will not compile.

What are the correct symbol names for CL, TF, and ES?

Because I have never been to school to learn programming, I need a little help.

I know which updates are Bid, Ask, and Trade.

I do not know how to access the Price, Volume, and TimeStamp of each update from the exchange.

The platform I currently use provides a Method that has all this information that programmers can access in real time when the markets are open.

If possible, please provide code of a working example of how to access these updates from the exchange on this platform for the benefit of all coders here and please consider adding it to your platform as a standard feature in the future.

Thanks
1. Better if you will programming in Visual Studio
2. Price, Time and Volume of update in "Result.RTData.Value"

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: DataLoader Question

Postby Henry MultiСharts » 05 Nov 2014

RJay33, the "Request" variable is not declared in your code.

RJay33
Posts: 4
Joined: 21 Oct 2014
Has thanked: 2 times

Re: DataLoader Question

Postby RJay33 » 05 Nov 2014

Thanks guys,

These posts give me something to chew on.

I have another question that is a little off topic for this thread.

In the OnData Method displayed in prior post, I would like to call an update to the CalcBar() Method.

It looks like this:

public void OnData(IDataLoaderResult Result)
{
if(xxxxxxxxxxx)CalcBar();
}

It compiles ok but when I add the study to the chart, I get a popup error message attached below.
CaptureCalcBar.PNG
(10.61 KiB) Downloaded 1130 times
Any suggestions on a resolution?

Thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: DataLoader Question

Postby Henry MultiСharts » 05 Nov 2014

RJay33, CalcBar cannot be called from a different thread. While OnData is called from a different thread. You need to create a singleton class, feed the data into it using OnData, read the data from it using CalcBar. In order to call CalcBar more often - you can use RecalcLastbarAfter.


Return to “MultiCharts .NET”