Bryan
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Can I submit orders by time series
Collapse
X
-
Can I submit orders by time series
Let's say my strategy conditions are met to place an order. My order size is 10 contracts. I want to split up the orders so that they get sent to the broker in 100 millisecond intervals, one contract at a time, regardless of the number of bar updates or ticks in that time period. Is this possible in a NinjaScript strategy?
BryanTags: None
-
Hello cassb, and thank you for your question. NinjaScript strategies are truly event driven. Tick data which drives the OnMarketData typically comes in more quickly than at 100 millisecond intervals, and DateTime.Now (rather than the time series) will allow you to determine whether 100 millisecond intervals have passed. Finally, the unmanaged order entry approach will give you greater flexibility and control over the timing trades are initialized. This is the extent of the built in support Ninja offers for what you are describing. Please let us know if there are any other ways we can help.Jessica P.NinjaTrader Customer Service
-
So the answer is that I am limited by the tick events that cause the OnBarUpdate or other routines to execute? And if the tick data comes in at great than 100 ms intervals, then it's not possible to force an order to go to the broker until the "next" tick is received by the strategy?
Comment
-
There was one more method I missed mentioning in my post earlier that is directly supported by Ninja. I would like to invite you to see the TriggerCustomEvent documentation for timed events.
Beyond this, MSDN C# does have some support available as well for firing events every 100 ms.
As far as how quickly events are actually processed, even if they are sent off every 100 ms, NinjaTrader uses many different APIs with many different web resources and desktop applications. NinjaScript offers a single interface into all of these, but shares limitations with different APIs.
The unmanaged order entry approach I mentioned earlier, documented here,
allows you to initiate orders as quickly as you'd like and to take over control and responsibility for order handling when the trade desk sends feedback back to NinjaTrader through the OnOrderUpdate and OnExecution(Update NT8) methods. The Managed approach handles a lot of this logic for you, but the cost to this convenience is that you lose the flexibility you would need to try approaches like the approach you are suggesting.Jessica P.NinjaTrader Customer Service
Comment
-
OK, thanks! I definitely want the Managed approach, so I'll have to work with its limitations. Thanks for the info!
Comment
-
Originally posted by cassb View PostSo the answer is that I am limited by the tick events that cause the OnBarUpdate or other routines to execute? And if the tick data comes in at great than 100 ms intervals, then it's not possible to force an order to go to the broker until the "next" tick is received by the strategy?
Comment
-
Ah, OK that sounds awesome then. I totally forgot about a Timer, but I think I've used it before in NinjaScript. I'll look into it, thank you! Any example script that you know of that I can take a look at?
Comment
-
Originally posted by cassb View PostAh, OK that sounds awesome then. I totally forgot about a Timer, but I think I've used it before in NinjaScript. I'll look into it, thank you! Any example script that you know of that I can take a look at?
Comment
-
Originally posted by cassb View PostAh, OK that sounds awesome then. I totally forgot about a Timer, but I think I've used it before in NinjaScript. I'll look into it, thank you! Any example script that you know of that I can take a look at?
You just need to split up the timer creation and assignation, event handler hookup and startup to the appropriate OnStateChange state.
Start the timer when your trade setup occurs, then send your orders based on the granularity that you want, and stop the timer.
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
Comment
-
Sheesh... I had a fire in Oct 2015 that destroyed all my computer equipment as well - started in the garage with smoldering wood ashes in a bucket. I luckily found a backup drive in the debris and paid $2500 to have it restored successfully.
And I just found out today that a co-worker also had a fire 3 years ago, started in the garage and destroyed all his woodworking tools. Weird coincidences!
Comment
-
This might help:
#region Using declarations
// add this
using System.Timers;
#endregion
#region Variables
// add this
private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
#endregion
// start your timer somewhere
timer.Tick += do_your_process; // name of your entry function
timer.Interval = 1000; // timer increment in milliseconds
timer.Start();
// don't forget to turn it off somewhere
timer.Stop();
timer.Tick -= do_your_process;
private void do_your_process(object sender, EventArgs e)
{
// your timer entry ... do something.
// yes you can have multiple timers: change timer to timer_1, timer_2, etc (with additional region variables to accommodate) ... with potentially different entry functions
}
Last edited by Bluepoint; 12-29-2016, 01:55 AM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by traderqz, Yesterday, 12:06 AM
|
11 responses
27 views
0 likes
|
Last Post Today, 05:11 AM | ||
Started by PaulMohn, Today, 03:49 AM
|
0 responses
8 views
0 likes
|
Last Post
by PaulMohn
Today, 03:49 AM
|
||
Started by inanazsocial, Today, 01:15 AM
|
1 response
10 views
0 likes
|
Last Post Today, 02:18 AM | ||
Started by rocketman7, Today, 02:12 AM
|
0 responses
11 views
0 likes
|
Last Post
by rocketman7
Today, 02:12 AM
|
||
Started by dustydbayer, Today, 01:59 AM
|
0 responses
4 views
0 likes
|
Last Post
by dustydbayer
Today, 01:59 AM
|
Comment