ETickTradedSide
- Anna MultiCharts
- Posts: 560
- Joined: Jul 14 2017
- Has thanked: 42 times
- Been thanked: 141 times
Hello, Gann_Man!
Please refer to the code of this study as an example.
Please refer to the code of this study as an example.
- Attachments
-
- Test_DataLoaderRT_TickTradedSide.pln
- (1.29 KiB) Downloaded 526 times
-
- Posts: 85
- Joined: Jul 01 2007
- Location: Missouri
- Has thanked: 7 times
- Been thanked: 2 times
Thank you MC Team for providing such a great "working" example to learn from!
Here is the simple 'if' statement I was needing and now have working thanks to the example code.
All the code below is also necessary to accomplish the simple 'if' statement above or is there a more simple way of doing this with less code needed?
Again, thank you for solving my problem!
Here is the simple 'if' statement I was needing and now have working thanks to the example code.
Code: Select all
if (_Side.ToString() == "AskTraded")
{
//do stuff
}
else
{
//do other stuff
}
All the code below is also necessary to accomplish the simple 'if' statement above or is there a more simple way of doing this with less code needed?
Code: Select all
IDataLoaderResult iRes;
protected override void StartCalc()
{
InstrumentDataRequest Req = Bars.Request;
Req.Subscribe2RT = true;
Req.RequestStatusDetails = true;
iRes = DataLoader.BeginLoadData(Req, ResultCallback, null);
}
protected override void StopCalc()
{
DataLoader.EndLoadData(iRes);
}
ETickTradedSide _Side = ETickTradedSide.Undefined;
void ResultCallback(IDataLoaderResult Result)
{
if (Result.Event == DataLoadedEvent.RTNewBar)
if (Result.RTData != null)
_Side = Result.RTData.Value.TickTradedSide;
}
- Anna MultiCharts
- Posts: 560
- Joined: Jul 14 2017
- Has thanked: 42 times
- Been thanked: 141 times
Gann_Man,
No, there's no way to do this with less code
No, there's no way to do this with less code
-
- Posts: 85
- Joined: Jul 01 2007
- Location: Missouri
- Has thanked: 7 times
- Been thanked: 2 times
I've been testing the provided study example on a 1-tick bar chart against a Time & Sales Window. The Date, Time, Price and Bid/Ask Side, match-up perfectly. However, I've tried 3 different ways to try and match the tick trade Volume with no luck. I do not see a 'Result.RTData.Value.TrueVolume'. What changes are needed to match the Volume also? Thank you!Hello, Gann_Man!
Please refer to the code of this study as an example.
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
public class Test_DataLoaderRT : IndicatorObject
{
public Test_DataLoaderRT(object _ctx) : base(_ctx) { }
private ISeries<Double> barsTotalVolume;
protected override void Create()
{
}
IDataLoaderResult iRes;
protected override void StartCalc()
{
barsTotalVolume = Bars.TrueVolume();
InstrumentDataRequest Req = Bars.Request;
Req.Subscribe2RT = true;
Req.RequestStatusDetails = true;
iRes = DataLoader.BeginLoadData(Req, ResultCallback, null);
}
protected override void StopCalc()
{
DataLoader.EndLoadData(iRes);
}
protected override void CalcBar()
{
if (Environment.IsRealTimeCalc)
{
if(_Side != ETickTradedSide.Undefined)
Output.WriteLine("{0}: {1}, {2}, {3}, {4}, {5}", _time, _Value, _Side, _Volume1, _Volume2, _Volume3);
}
}
double _Value = 0;
double _Volume1 = 0;
double _Volume2 = 0;
double _Volume3 = 0;
DateTime _time;
ETickTradedSide _Side = ETickTradedSide.Undefined;
void ResultCallback(IDataLoaderResult Result)
{
if (Result.Event == DataLoadedEvent.RTNewBar)
{
if (Result.RTData != null)
{
_Value = Result.RTData.Value.Close;
_time = Result.RTData.Value.Time;
_Side = Result.RTData.Value.TickTradedSide;
_Volume1 = Result.RTData.Value.TotalVolume;
_Volume2 = Result.RTData.Value.UpVolume + Result.RTData.Value.DownVolume;
_Volume3 = barsTotalVolume[0];
}
}
}
}
}
-
- Posts: 85
- Joined: Jul 01 2007
- Location: Missouri
- Has thanked: 7 times
- Been thanked: 2 times
private ISeries<Double> barsTrueVolume;
barsTrueVolume = Bars.TrueVolume();
barsTrueVolume[0]
Not entirely sure, but appears Bars.TrueVolume() may be working correctly using a 1-tick bar chart with "Update on every tick" unchecked and "Skip identical ticks" checked, but it's still not working correctly using a 1-tick scanner window.
I need to somehow have access to accurate "1-tick Trade Volume" using a 1-tick scanner window that matches Time & Sales Volume. I don't know if it's possible to access VolumeProfile data using a scanner window, is it?
I've tried these methods without success using a 1-tick scanner window:
Result.RTData.Value.TotalVolume;
Result.RTData.Value.UpVolume + Result.RTData.Value.DownVolume;
barsTrueVolume[0];
Bars.StatusLine.LastVolume;
Bars.VolumeValue;
Bars.Volume[0];
barsTrueVolume = Bars.TrueVolume();
barsTrueVolume[0]
Not entirely sure, but appears Bars.TrueVolume() may be working correctly using a 1-tick bar chart with "Update on every tick" unchecked and "Skip identical ticks" checked, but it's still not working correctly using a 1-tick scanner window.
I need to somehow have access to accurate "1-tick Trade Volume" using a 1-tick scanner window that matches Time & Sales Volume. I don't know if it's possible to access VolumeProfile data using a scanner window, is it?
I've tried these methods without success using a 1-tick scanner window:
Result.RTData.Value.TotalVolume;
Result.RTData.Value.UpVolume + Result.RTData.Value.DownVolume;
barsTrueVolume[0];
Bars.StatusLine.LastVolume;
Bars.VolumeValue;
Bars.Volume[0];
-
- Posts: 85
- Joined: Jul 01 2007
- Location: Missouri
- Has thanked: 7 times
- Been thanked: 2 times
Further testing today revealed that by turning off (unchecked) "Update on every tick" and turning on (checked) "Skip identical ticks" on both a 1-tick bar chart and scanner window improved accuracy significantly using the "barsTrueVolume[0]" Method! This method is now producing 90+% accuracy.
I continue to be baffled why "Result.RTData.Value.TotalVolume" isn't the most accurate. Results using this method is still nowhere close to being correct in my testing.
I continue to be baffled why "Result.RTData.Value.TotalVolume" isn't the most accurate. Results using this method is still nowhere close to being correct in my testing.
- Anna MultiCharts
- Posts: 560
- Joined: Jul 14 2017
- Has thanked: 42 times
- Been thanked: 141 times
Gann_Man,
Our engineers tested this on our end following the steps you provided, and they received matching results, no discrepancies.
If you’d like to demonstrate this to us on your PC by remote connection please come to our Live Chat Mon-Fri from 6:30 AM to 12:00 PM EST (11:30 AM to 5:00 PM GMT)
Our engineers tested this on our end following the steps you provided, and they received matching results, no discrepancies.
If you’d like to demonstrate this to us on your PC by remote connection please come to our Live Chat Mon-Fri from 6:30 AM to 12:00 PM EST (11:30 AM to 5:00 PM GMT)
-
- Posts: 85
- Joined: Jul 01 2007
- Location: Missouri
- Has thanked: 7 times
- Been thanked: 2 times
I'm still unable to get the DataLoader TotalVolume to match the volume in a Time & Sales Window:Gann_Man,
Our engineers tested this on our end following the steps you provided, and they received matching results, no discrepancies.
Code: Select all
_TotalVolume = Result.RTData.Value.TotalVolume;
barsTrueVolume[0]
Bars.TicksValue
Bars.VolumeValue
Bars.Volume[0]
Bars.StatusLine.LastVolume
Also a cumulative view for comparision:
Sum_TotalVolume += _TotalVolume;
Sum_BarsTrueVolume0 += BarsTrueVolume0;
Sum_BarsTicksValue += BarsTicksValue;
Sum_BarsVolumeValue += BarsVolumeValue;
Sum_BarsVolume0 += BarsVolume0;
Sum_BarsStatusLineLastVolume += BarsStatusLineLastVolume;
It appears the 'barsTrueVolume[0]' and 'Bars.TicksValue' methods produce the same and most accurate results.
Would you please review my code to see what I'm doing wrong or post the code your engineers successfully tested with.
I need the DataLoader _TotalVolume method to confirm the accuracy of the other methods.
Thank you for your help.
- Attachments
-
- _Test_DataLoaderRT.png
- (682.88 KiB) Downloaded 1398 times
-
- _Test_DataLoaderRT.wsp
- (90.5 KiB) Downloaded 476 times
-
- _Test_DataLoaderRT.pln
- (1.71 KiB) Downloaded 486 times
- Anna MultiCharts
- Posts: 560
- Joined: Jul 14 2017
- Has thanked: 42 times
- Been thanked: 141 times
Hello, Gann_Man!
DataLoader receives new ticks in packs upon events, and the study is calculated at once for all of them. The time of study calculation on DataLoader data may not be in sync with the study calculation on the chart.
You can add the following trace for the DataLoader events and it should help you understand the difference you see:
void ResultCallback(IDataLoaderResult Result)
{
if (Result.Event == DataLoadedEvent.RTNewBar)
{
if (Result.RTData != null)
{
_Price = Result.RTData.Value.Close;
_Time = Result.RTData.Value.Time;
_Side = Result.RTData.Value.TickTradedSide;
_TotalVolume = Result.RTData.Value.TotalVolume;
Output.WriteLine("{0}, {1}, {2}", _Time.ToString("M/dd/yyyy HH:mm:ss.fff"), _Price, _TotalVolume);
}
}
}
DataLoader and Status Line volumes come in RT and therefore coincide.
BarsVolumeValue and BarsVolume0 will only return the values for UpVol and will return 0 for DnVol.
To get the same volume as in Time and Sales you need to use BarsTrueVolume0 which returns the total volume (UpVol+DnVol) value and it doesn’t take chart resolution into account.
DataLoader receives new ticks in packs upon events, and the study is calculated at once for all of them. The time of study calculation on DataLoader data may not be in sync with the study calculation on the chart.
You can add the following trace for the DataLoader events and it should help you understand the difference you see:
void ResultCallback(IDataLoaderResult Result)
{
if (Result.Event == DataLoadedEvent.RTNewBar)
{
if (Result.RTData != null)
{
_Price = Result.RTData.Value.Close;
_Time = Result.RTData.Value.Time;
_Side = Result.RTData.Value.TickTradedSide;
_TotalVolume = Result.RTData.Value.TotalVolume;
Output.WriteLine("{0}, {1}, {2}", _Time.ToString("M/dd/yyyy HH:mm:ss.fff"), _Price, _TotalVolume);
}
}
}
DataLoader and Status Line volumes come in RT and therefore coincide.
BarsVolumeValue and BarsVolume0 will only return the values for UpVol and will return 0 for DnVol.
To get the same volume as in Time and Sales you need to use BarsTrueVolume0 which returns the total volume (UpVol+DnVol) value and it doesn’t take chart resolution into account.
-
- Posts: 53
- Joined: Feb 18 2011
- Has thanked: 11 times
- Been thanked: 13 times
I have been following along for a while on this topic. I have an interest, as I am in the beginning stages for creating an indicator that accumulates, the ticks that come in to simulate putting back together a large trade that gets reported as a few /many small trades. So my intention is to take all ticks that come in within 'x' milliseconds and show them on a chart/indicator as one trade. The goal of this is to show the 'real' large trades that are happening, vs the machine gun list of small trades used to hide the actual volume that a Large Player is actually trading.
So, my question is this. GannMan showed what he thought was multiple ways to get "Volume for each tick". Then as part of your response you gave a way that matches up to the Time/Sale Window. My interest / concern is as part of your response you said what I think are conflicting statements. In the opening line of your response, you say
"DataLoader receives new ticks in packs upon events, and the study is calculated at once for all of them. "
Then in the last paragraph,m you state, something different.
"DataLoader and Status Line volumes come in RT and therefore coincide."
Can you state what different events need to happen to get the various forms of volume that GannMan showed above? What event is needed to occur, and what amount of ticks are in what I am getting?
So, If I really want to be able to see every tick as it comes in, and capture its volume and time, What are the events I need to make my code activate on to accomplish this?
Hope this makes sense, if not we can have a support chat session if that would be easier. I also think since there seems to be 5 or 6 ways to get volume, it would be helpful for you to add as part of the documentation, what events cause that variable to change and what value it would contain. Example, it is a single tick as sent from the exchanges or it is an accumulation of ticks that have occurred since the last event.
Lastly, as a 'not super c# coder' yet, it would be extremely helpful if there were more complete examples / snippets of code to see what the various parts of MC.Net are doing and are needed to set up to get them to work, vs the single line of code that is needed to make the method call or use the data value. I would think you have all of this, as it is needed to test before you deliver a product. competing products, like NT and SC have much better documentation. Maybe it is already there, but I have not found it all yet.
Sorry if I am rambling.
John
So, my question is this. GannMan showed what he thought was multiple ways to get "Volume for each tick". Then as part of your response you gave a way that matches up to the Time/Sale Window. My interest / concern is as part of your response you said what I think are conflicting statements. In the opening line of your response, you say
"DataLoader receives new ticks in packs upon events, and the study is calculated at once for all of them. "
Then in the last paragraph,m you state, something different.
"DataLoader and Status Line volumes come in RT and therefore coincide."
Can you state what different events need to happen to get the various forms of volume that GannMan showed above? What event is needed to occur, and what amount of ticks are in what I am getting?
So, If I really want to be able to see every tick as it comes in, and capture its volume and time, What are the events I need to make my code activate on to accomplish this?
Hope this makes sense, if not we can have a support chat session if that would be easier. I also think since there seems to be 5 or 6 ways to get volume, it would be helpful for you to add as part of the documentation, what events cause that variable to change and what value it would contain. Example, it is a single tick as sent from the exchanges or it is an accumulation of ticks that have occurred since the last event.
Lastly, as a 'not super c# coder' yet, it would be extremely helpful if there were more complete examples / snippets of code to see what the various parts of MC.Net are doing and are needed to set up to get them to work, vs the single line of code that is needed to make the method call or use the data value. I would think you have all of this, as it is needed to test before you deliver a product. competing products, like NT and SC have much better documentation. Maybe it is already there, but I have not found it all yet.
Sorry if I am rambling.
John
- Anna MultiCharts
- Posts: 560
- Joined: Jul 14 2017
- Has thanked: 42 times
- Been thanked: 141 times
Hello, johnromeronc!
If you need to get full volume for a bar, then you need to use barsTrueVolume() – it doesn’t miss any ticks out and returns true full volume.
As for the events – CalcBar method call is the event of a new tick arrival for the data series upon which a study is calculated.
If you need to get full volume for a bar, then you need to use barsTrueVolume() – it doesn’t miss any ticks out and returns true full volume.
As for the events – CalcBar method call is the event of a new tick arrival for the data series upon which a study is calculated.