NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 02-17-2012, 11:19 AM   #1
Ramon
Member
 
Join Date: Oct 2009
Location: Madrid (Spain)
Posts: 39
Thanks: 15
Thanked 1 time in 1 post
Default OnMarketData VS OnBarUpdate

Is there any difference between using OnBarUpdate

Code:
CalculateOnBarClose = False
..
last=Close[0];
bid = GetCurrentBid();
ask=GetCurrentAsk();
... and OnMarketData
Code:
if ( marketDataType.Last) last = e.Price
if ( marketDataType.Bid) bid = e.Price
if ( marketDataType.Ask) ask = e.Price
(Don't try to compile this at home)
Last edited by Ramon; 02-17-2012 at 11:23 AM.
Ramon is offline  
Reply With Quote
Old 02-17-2012, 11:45 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Ramon,
Thanks for writing in and I am happy to assist you.

NinjaTrader being multi-threaded with OnMarketData and OnBarUpdate being called in their own respective thread, there can be difference between GetCurrentAsk() and e.Price as ask price derived from OnMarketData.

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 02-17-2012, 12:04 PM   #3
Ramon
Member
 
Join Date: Oct 2009
Location: Madrid (Spain)
Posts: 39
Thanks: 15
Thanked 1 time in 1 post
Default

I supposed, however the latest crossed price should match in both methods . is it so? . I mean
(last) e.Price == Close[0]

or not?
Ramon is offline  
Reply With Quote
Old 02-17-2012, 12:35 PM   #4
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Ramon,
It may or may not match since Close and e.Price are updated on different thread.

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Old 02-18-2012, 01:36 AM   #5
Ramon
Member
 
Join Date: Oct 2009
Location: Madrid (Spain)
Posts: 39
Thanks: 15
Thanked 1 time in 1 post
Default

In times of Livermore, Mr. Investor bought a contract to 890.25 and the tape recorded this fact

Today Mr Investor Jr. buys a contract to 1342.75 and thanks to technology this fact depends on whether you use OBU or OMD.
I do not think that the fact that Livermore shot himself in the head has nothing to do with the progress of computers.

So , we better continue using OMD to record events in Level 1 (Time & Sales) ?
Ramon is offline  
Reply With Quote
Old 02-20-2012, 07:20 AM   #6
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Ramon,
OnMarketData and OnBarUpdate has its own pros and cons. We provide you options, and it depends on your exact requirement, on how you utilize it to its optimum.

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
onBarUpdate vs onMarketData danilam General Programming 7 11-17-2011 06:08 AM
OnMarketData and OnBarUpdate telbentel General Programming 5 12-20-2010 08:15 AM
OnMarketData vs OnBarUpdate kjackson Indicator Development 7 01-12-2010 10:11 AM
OnMarketData vs OnBarUpdate rt-trader General Programming 2 01-18-2009 03:07 PM
OnMarketData and OnBarUpdate svrz Indicator Development 6 12-23-2008 09:17 AM


All times are GMT -6. The time now is 08:50 AM.