NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 01-08-2008, 01:22 PM   #1
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default Starting a strategy in middle of session

How do I start a strategy in the middle of a session/day and get it to execute without regards to what my position would be if I had started the strategy at the beginning of the day?

I have read this post already.
http://www.ninjatrader-support.com/v...trategy+middle
dtf139 is offline  
Reply With Quote
Old 01-08-2008, 01:27 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Not sure what you mean by this. Could you elaborate?
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-08-2008, 04:30 PM   #3
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default

Market has been open for 3 hours but I do not have any open positions because I just turned my computer on after sleeping in late. I start my automated strategy hoping to take advantage of the gigantic uptrending day. After 5 minutes my strategy parameters are met and a buy should be triggered but, no order is placed because the strategy position is already long a imaginary/simulated position from earlier in the morning.
How do I get njt to ignore or disregard that earlier simulated trigger.
dtf139 is offline  
Reply With Quote
Old 01-08-2008, 04:37 PM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

You would need to programatically change your code in the first line of OnBarUpdate()

if (Historical)
return;;

This will only then run on real-time data.
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-09-2008, 12:48 PM   #5
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default

I'm confused as to what "Immediately submit live working historical orders" accomplishes. I've read the explanation in the help guide a bunch of times and it seems like having that option selected would address my problem. Of course, I have it selected and it ain't
dtf139 is offline  
Reply With Quote
Old 01-09-2008, 02:45 PM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

It means as you start a strategy, it will calculate its current position and order state. If there are working orders it will convert these to live orders.
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-09-2008, 06:45 PM   #7
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Ray View Post
It means as you start a strategy, it will calculate its current position and order state. If there are working orders it will convert these to live orders.
I'm sorry but I still dont understand what that translates to a non-programmer. What exactly is a "working order"?
dtf139 is offline  
Reply With Quote
Old 01-09-2008, 06:58 PM   #8
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default

What's really throwing me for a loop is that the other option is "wait until flat before executing live" The description given in the manual seems self explanatory in that the strategy has to have no open positions before it can execute any additional orders. So... since "immediately submit live working orders" is the alternative selection, it should not wait until the strategy is flat, it should go ahead and execute any orders the strategy triggers?
dtf139 is offline  
Reply With Quote
Old 01-09-2008, 08:08 PM   #9
Pete S
Senior Member
 
Join Date: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
Default

dtf139: This area really drove me nuts when I first started using NT. In essence, regardless of how you have that option set, NT is not going to place any "real" orders when catching up on historical data after you start your strategy. What it will do, however, is adjust its own internal position so that it thinks it is long or short depending on the value of that option. I gave a few other comments after figuring out how to handle it in my own strategies here: http://www.ninjatrader-support.com/v...ead.php?t=4062
Pete S is offline  
Reply With Quote
Old 01-09-2008, 08:32 PM   #10
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

When you run your strategy live -

- It will run a backtest on historical data
- On the current bar (right most bar on a chart) your strategy may be in a position and your strategy may have a stop and target to protect the position (for example)

"Immediately submit live" would submit (convert) these orders into live orders

"Wait until flat" will let the strategy play out in virtual simulation (just like a backtest) until flat before executing any live orders
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-09-2008, 09:06 PM   #11
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default

Okay! Thanks Ray, Pete. I finally got my head around it.
dtf139 is offline  
Reply With Quote
Old 02-04-2008, 04:45 PM   #12
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default

Could someone post a screen shot or describe in detail how to use "historical" in conjunction with OnBarUpdate? I'm not a programmer and dont have a clue as to the correct syntax and where exactly to place it in the line of code.

thanks!
dtf139 is offline  
Reply With Quote
Old 02-04-2008, 04:51 PM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Code:
if (Historical)
     return;
You would put this at the very beginning of your OnBarUpdate() method if you wish to not process your code if the data is historical.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-04-2008, 05:39 PM   #14
dtf139
Member
 
Join Date: Dec 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
Default

when you say "beginning" do you mean directly after OnBarUpdate on the same line, or on the next line down? Before or after the other lines of code that are in my strategy?
dtf139 is offline  
Reply With Quote
Old 02-04-2008, 06:02 PM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Right after the bracket.
NinjaTrader_Josh 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
Save each strategy with Session Start and end times. richa61416 Suggestions And Feedback 8 05-28-2008 11:56 PM
"Closes a position (left-click) or strategy (middle-click)" whitmark Strategy Development 1 11-08-2007 12:06 PM
Strategy Realised Profit and Loss on session exit richa61416 Strategy Development 2 10-09-2007 02:56 PM
Question about Session End time for strategy mazachan Strategy Development 1 09-21-2007 02:23 PM
strategy/auto trade problem: stops/etc. initiate upon starting of strategy scriabinop23 Automated Trading 14 05-30-2007 12:29 PM


All times are GMT -6. The time now is 04:41 AM.