Accessing volume tick by tick

Questions about MultiCharts .NET and user contributed studies.
MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Accessing volume tick by tick

Postby MidKnight » 04 Sep 2014

Hi there,

I'm trying to create a study that will be displayed on any regular chart but it will require all its calculations on a tick by tick basis of the data within each tick. I had thought this would be simple to code but I can't see how I access the volume of each tick. Yeah I could do the ugliness of adding a 1 tick data stream, but there must be a tidier way of doing this.....

With kind regards,
MK

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Accessing volume tick by tick

Postby JoshM » 04 Sep 2014

I'm trying to create a study that will be displayed on any regular chart but it will require all its calculations on a tick by tick basis of the data within each tick. I had thought this would be simple to code but I can't see how I access the volume of each tick. Yeah I could do the ugliness of adding a 1 tick data stream, but there must be a tidier way of doing this.....
Volume data can only be accessed per bar, so volume data based on 1 tick would also require a 1 tick data series as far as I know.

Do you mean visual ugliness or programmatic ugliness? Because if you do not want the chart to be visually impacted from a 1 tick data stream, this data can also be loaded with the DataLoader. That way the chart scaling is not affected.

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Accessing volume tick by tick

Postby MidKnight » 04 Sep 2014

Bugger. ;(

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Accessing volume tick by tick

Postby JoshM » 04 Sep 2014

You could also put the code in a strategy with the Bar Magnifier set to 1 tick. The script will then be calculated on every historical tick, without the need for the DataLoader or an additional data series on the chart.

But then you cannot plot on the historical price bars, I think (depending on how this works with Bar Magnifier).

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

Re: Accessing volume tick by tick

Postby Henry MultiСharts » 04 Sep 2014

That is possible to receive the volume of a new tick in a bar.
Attachments
Test_lastTickVolume.pln
(1.14 KiB) Downloaded 674 times

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Accessing volume tick by tick

Postby MidKnight » 07 Sep 2014

OK, so I've been trying the dataloader route because Henry's previous suggestion looks to me like it will only work on real-time data. I need something that will work on both historical and real-time. I tried my best to follow the example here:
https://www.multicharts.com/trading-sof ... DataLoader

But unfortunately I ended up with my dataloader series printing 1 tick into the future of the main data series. I don't really understand why this is happening. I would have thought my dataloaded List<Bar> container would match that of the main series, but it doesn't seem to. I had to actually mimic your calcbar() example code from the webpage above just to stop getting exceptions when loading the indicator. Here is my calcbar() code:

Code: Select all

int index = Math.Min(Bars.CurrentBar, m_tickData.Count - 1);
if (index > 0)
{
plot1.Set(m_tickData[index].Close);
}


Attached is a screen showing the issue.

Any ideas?

With thanks in advance,
MK
Attachments
MK_2014-09-07_205322.png
(26.28 KiB) Downloaded 1600 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Accessing volume tick by tick

Postby JoshM » 07 Sep 2014

I would have thought my dataloaded List<Bar> container would match that of the main series, but it doesn't seem to.
Are you already on version 9? There's a new class in that version, `CustomInstrument`, that should solve this problem (I'm not yet on that version, so can't really say it would work in this situation). There's an example here.
But unfortunately I ended up with my dataloader series printing 1 tick into the future of the main data series.
Can't say I have experienced that specific situation, but did had the DataLoader run "out of line" with the chart (it seemed to lag in my case).

Henry then helped me with saying:
DataLoader loads the data asynchronously. I.e. calling the Dataloader cannot guarantee that you will have the data loaded on the same calculation.

You need to wait until it loads the data. Here is a sample code for that.

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Accessing volume tick by tick

Postby MidKnight » 07 Sep 2014

Thanks for the reply JoshM.

No, I am not using version 9. Trading is hard enough without needing to use unstable beta software.

This issue with the dataloader data being out of sync with the data1 stream is hugely serious and if it is well known and there is a well known way around it, why hasn't the MC team documented that in my webpage link where they describe how to use the dataloader with an example. This same dataloader example they use in the programming guide.

Also, Henry's posted example does not match the documented example of how to use the dataloader. If the MC team would be consistent, it would be a lot easier for people to learn the recommended dataloader usage.

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

Re: Accessing volume tick by tick

Postby Henry MultiСharts » 08 Sep 2014

MidKnight, that is hard to comment this situation using a screenshot only. For example the plot can be starting from the wrong bar. DataLoader was not designed to provide a series tied to bars from the box. DataLoader provides ability to the user to create his own series with all of the customizable parameters. If you want the DataLoader results to be tied to bars of the main data series - you can use the CustomInstrument functionality introduced in MultiCharts .NET 9.0. There were also other important improvements like new class DataLoaderCache (DataLoader singleton service. Caches LoadData requests to avoid requesting the same data again (increases the speed of script calculation)). MultiCharts .NET 9.0 beta 3 is stable and can be used for strategy development and testing. Release Candidate version can be expected later this week.

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Accessing volume tick by tick

Postby MidKnight » 08 Sep 2014

Of course it needs to line up with the main datastream - that is the whole point of the study. If I didn't need it to line up then I'd just a 1 tick stream as the main data source and there would be no questions. But how are you gonna put any context within that 1 tick stream - its too detailed. It should be obvious that the use of a higher resolution but using tick by tick analysis would be useful.

So in short: accessing a datastream via dataloader for tick by tick analysis and expecting the obvious, that is, to match up with the mainstream is not possible unless I choose to use beta software? This is really really disappointing to learn.

You guys really really need to look at your competition for what they are offering.

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

Re: Accessing volume tick by tick

Postby Henry MultiСharts » 09 Sep 2014

So in short: accessing a datastream via dataloader for tick by tick analysis and expecting the obvious, that is, to match up with the mainstream is not possible unless I choose to use beta software? This is really really disappointing to learn.
That is possible to program using MultiCharts .NET 8.8. Please find a screenshot that confirms that attached. That is a lot easier and already done for you in MultiCharts .NET 9.0.
Image
Attachments
DL.png
(22.45 KiB) Downloaded 1698 times
Test_DataLoaderRT.pln
(1.27 KiB) Downloaded 611 times

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Accessing volume tick by tick

Postby MidKnight » 10 Sep 2014

Can you tell me what your code example is supposed to do? From my examination, this will not sync data with the main chart on both historical data and real-time.

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

Re: Accessing volume tick by tick

Postby Henry MultiСharts » 11 Sep 2014

This example just shows that the data on the chart and in the data loader is the same. You need to create your own code in order to synchronize it, or use CustomInstrument in MultiCharts .NET 9.0.


Return to “MultiCharts .NET”