NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-01-2011, 10:30 AM   #1
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,353
Thanks: 24
Thanked 1,301 times in 1,064 posts
Send a message via Skype™ to koganam
Default OnMarketData() versus "OnBarUpdate() + COBC = false"

I have been thinking about this recently, and wondering whether apart from registering an extra event, the end-of-bar tick in the latter case, is there really any difference between using,
  1. OnBarUpdate() with COBC = false
  2. OnBarUpdate() with COBC = true, and OnMarketData() for tick processing
I do understand that MarketDataEventArgs exposes tick times even on fixed-time-interval based charts, where OnBarUpdate() shows only the time of the end-of-bar.

Given such, might it not make more sense to use the latter as the programming paradigm.
koganam is offline  
Reply With Quote
Old 10-03-2011, 06:23 AM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Good morning,

Not sure I understand exactly the question so let me know if the below does not answer.

However the only difference between the two is that OnMarketData only works in realtime(Not historical) and is direct access to the streaming data.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 10-03-2011, 07:01 AM   #3
bukkan
Senior Member
 
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
Default

from the help files
With NinjaTrader being multi-threaded, you should not rely on any particular sequence of events like OnMarketData() always being called before OnBarUpdate() or vice versa.


as such FirtTickOfBar wont be registered in OnMarketData.

OnMarketData is very useful when COBC is set to true but you still need to calculate/tract some stuffs in RT (say stops/targets in a strategy).
bukkan is offline  
Reply With Quote
Old 10-03-2011, 07:35 AM   #4
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,353
Thanks: 24
Thanked 1,301 times in 1,064 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Good morning,

Not sure I understand exactly the question so let me know if the below does not answer.

However the only difference between the two is that OnMarketData only works in realtime(Not historical) and is direct access to the streaming data.

Let me know if I can be of further assistance.
Well, that is certainly a difference.

Given that answer then, does it mean that it will produce no usable results if a strategy the uses OnMarketData() for order generation is run through the Strategy Analyzer for backtest or optimization?
koganam is offline  
Reply With Quote
Old 10-03-2011, 07:38 AM   #5
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Correct, right would not run in historical. Only runs in live only mode.
NinjaTrader_Brett is offline  
Reply With Quote
Old 10-03-2011, 07:40 AM   #6
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,353
Thanks: 24
Thanked 1,301 times in 1,064 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by bukkan View Post
from the help files
With NinjaTrader being multi-threaded, you should not rely on any particular sequence of events like OnMarketData() always being called before OnBarUpdate() or vice versa.


as such FirtTickOfBar wont be registered in OnMarketData. ...
Yes, I did read that. That will be handled by a boolean flag set on the close of the bar, and turned off when OnMarketData() is done. If the flag is not set, OnMarketData() will return with no action. A pretty handy way to force precedence.
koganam is offline  
Reply With Quote
Old 10-03-2011, 07:44 AM   #7
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,353
Thanks: 24
Thanked 1,301 times in 1,064 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Correct, right would not run in historical. Only runs in live only mode.
How then would one go about optimizing such a strategy? Hand optimization by manually adjusting parameters per each run, hardly seems workable. Or are you saying that such a strategy cannot be optimized, as there is no way to run any kind of backtest, with a reasonable permutation of parameters?
koganam is offline  
Reply With Quote
Old 10-03-2011, 07:49 AM   #8
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

You can't optimize or backtest a strategy that uses live data stream access.
NinjaTrader_Brett is offline  
Reply With Quote
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
when is OnBarUpdate() called when the "CalculateOnBarClose" property is set to true? clearpicks General Programming 1 12-12-2010 10:15 AM
Timing sequence for "OnBarUpdate=True" AnotherTrader Automated Trading 3 08-06-2010 07:00 AM
Strategy COBC=false, Indicator COBC=true? MXASJ Version 7 Beta General Questions & Bug Reports 2 06-28-2010 05:35 AM
summary of "strategy realized" is not equal "account performance, total net profit"" Fragolino Miscellaneous Support 1 02-19-2009 04:12 AM
OnBarUpdate "context" in user defined method kgillis23 General Programming 3 01-08-2008 08:40 PM


All times are GMT -6. The time now is 09:40 PM.