![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
|
Hello,
What is the value of Time property on MarketDataEventArgs? In a first glance it should be the DateTime of every change, (Bid, Ask or prices) but it seems to be the DateTime of last trade. Is that right? Maybe there is not much difference in liquidity instruments but definitively there are a lot of differences in non-liquidity instruments. Regards |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
jbesada,
It should be the time of that particular OnMarketData call. Are you noticing something different?
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
|
Unfortunately yes, I have noticed that always change whit MarketDataType=Last, but not with Bid and Ask (it keeps previous value).
So, at the end, when you analyze a file data you can see always a change on Time if a Trade occurs: 1303 0 1303 1303.75 22 69 49345 1303 0 1303 1303.75 22 47 49345 1303 0 1303.25 1303.75 22 47 49345 1303 0 1303.25 1303.75 22 45 49345 1303 0 1303.25 1304 22 69 49345 1303 0 1303 1304 24 69 49345 1303 0 1303.25 1304 22 69 49345 1304 2 1303.25 1304 22 69 49760 As you can see, there is a big jump on last column (seconds from midnight). My guest, e.Time is not updated with ‘Bid’ and ‘Ask’ events, just with ‘Last’ event. Can you confirm it? I have reviewed my code deeply and I cannot find another explanation… Regards |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
jbesada,
There would only be second resolution here, so no milliseconds. Could you show me your code?
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
|
Here is my code. As you can see, every change is recorded creating a new line but Time changes with 'Last' type only:
protected override void OnMarketData(MarketDataEventArgs e) { string strMD="", strML=""; string strDate =""; long lLastVolume=0; bool bUpdate=false; try { lock(oLock) { switch(e.MarketDataType) { case MarketDataType.Bid: dBid=e.Price; lBidSize=e.Volume; bUpdate=true; break; case MarketDataType.Ask: dAsk=e.Price; lAskSize=e.Volume; bUpdate=true; break; case MarketDataType.Last: dLast=e.Price; lLastVolume=e.Volume; bUpdate=true; break; } if (bUpdate && dLast>0 && dBid>0 && dAsk>0) { TimeSpan ts = e.Time.ToUniversalTime() - DateTime.Now.Date; strDate= ts.TotalSeconds.ToString(); strMD = dLast.ToString().Replace(',', '.') +"\t" + lLastVolume + "\t" + dBid.ToString().Replace(',', '.') + "\t" + dAsk.ToString().Replace(',', '.') + "\t" + lBidSize + "\t" + lAskSize + "\t" + strDate; twMD.WriteLine(strMD); } } }catch(System.Exception ex) { Print("Something was wrong on OnMarketData! : " + ex.Message); } } |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
jbesada,
Here is example output for me : Code:
ASK : 6/25/2012 9:53:13 AM ASK : 6/25/2012 9:53:13 AM ASK : 6/25/2012 9:53:13 AM BID : 6/25/2012 9:53:13 AM ASK : 6/25/2012 9:53:13 AM ASK : 6/25/2012 9:53:13 AM ASK : 6/25/2012 9:53:13 AM LAST : 6/25/2012 9:53:14 AM BID : 6/25/2012 9:53:14 AM LAST : 6/25/2012 9:53:14 AM BID : 6/25/2012 9:53:14 AM BID : 6/25/2012 9:53:14 AM ASK : 6/25/2012 9:53:14 AM ASK : 6/25/2012 9:53:14 AM Here is an example of my code : Code:
protected override void OnMarketData(MarketDataEventArgs e)
{
if ( e.MarketDataType == MarketDataType.Ask)
{
Print("ASK : "+e.Time.ToString());
}
else if ( e.MarketDataType == MarketDataType.Bid)
{
Print("BID : "+e.Time.ToString());
}
else if ( e.MarketDataType == MarketDataType.Last)
{
Print("LAST : "+e.Time.ToString());
}
}
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
|
Hi Adam,
I know time have only resolution of seconds. I think I haven’t asked about milliseconds. My question is not related with it. My question is why always time changes (resolution of seconds) always with Last quote and NEVER with Bid/Ask quotes. Regards |
|
|
|
|
|
#8 |
|
Member
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
|
Hi Adam,
Any update of this issue? Regards Hi Adam, -------- I know time have only resolution of seconds. I think I haven’t asked about milliseconds. My question is not related with it. My question is why always time changes (resolution of seconds) always with Last quote and NEVER with Bid/Ask quotes. Regards |
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
Bid ask data may not be natively time stamped from the provider. Something the provider will need to follow up on. If its time stamped from the exchange then NT will order it in the format received. Last data is most likely time stamped from the server however bid and ask data is not guaranteed to be time stamped and I know with a lot of providers it is not.
-Brett
Brett
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to use weekly, monthly, yearly time frames in real time charting using 6.5 versi | qwert12 | Charting | 2 | 10-05-2010 04:35 PM |
| MarketDataEventArgs | pdwebb | General Programming | 1 | 10-21-2009 01:52 PM |
| Question regarding MarketDataEventArgs | davewolfs | General Programming | 1 | 08-26-2009 08:45 AM |
| MarketDataEventArgs - TimeStamp | davewolfs | General Programming | 3 | 08-25-2009 07:07 AM |
| Multi-time frame strategy - Longer-term real-time calculations | Shansen | Strategy Development | 1 | 04-19-2009 06:36 AM |