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 03-28-2010, 11:41 PM   #1
tomkim
Junior Member
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default How do prevent selling of our position on the same day that it was opened?

I want my automatic trading strategy to not close a position on the same day that it was opened. How do I do this?

Thanks

Tom
tomkim is offline  
Reply With Quote
Old 03-29-2010, 04:42 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Tom, for this you would need to set ExitOnClose in the UI to false when running or backtesting your strategy -

http://www.ninjatrader-support.com/H...romAChart.html

http://www.ninjatrader-support.com/H...AStrategy.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-29-2010, 08:31 AM   #3
tomkim
Junior Member
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

ExitOnClose "Indicates if the strategy will cancel all strategy generated orders and close all open strategy positions at the close of the session."

This is not what I want to do. I only want the open order to execute no more than once per day and for sell order to not execute on the same day the open order was executed. Also I want to control this programatically.
tomkim is offline  
Reply With Quote
Old 03-29-2010, 08:40 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Tom, thanks for clarifying - you would then need to control this via a boolean flag included in your trade entry conditions that you reset each day to allow for new trades to be taken.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-29-2010, 09:09 AM   #5
borland
Member
 
Join Date: Jan 2009
Posts: 94
Thanks: 0
Thanked 14 times in 12 posts
Default

Look in the Help Guide for 'IExecution', there is a 'DateTime' property that you can use in your boolean trade logic conditional statements.
borland is offline  
Reply With Quote
Old 03-29-2010, 09:30 AM   #6
tomkim
Junior Member
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks looks like that will work.

Looks like you get the iExecution variable passed in on OnExecution. Can I save that to a global variable at that time and reference it later?

Another related question. Is there a new instance of the strategy running for each equity it is monitoring? In other words, if I save iExecution to a global variable, will it affect any other equities I'll be monitoring with the same strategy?

thanks
tomkim is offline  
Reply With Quote
Old 03-29-2010, 10:07 AM   #7
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Tom, yes you could save values returned to a custom variable.

Correct, this would only refer to the individual strategy instance, as NinjaScript strategies do not cross communicate.
NinjaTrader_Bertrand 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
Targets not selling dsraider Miscellaneous Support 2 01-23-2010 04:31 PM
Storing data when position is opened verge Strategy Development 4 10-08-2009 09:20 AM
simple question how to close one position when more is opened nicknamed ATM Strategies (Discretionary Trading) 1 07-27-2009 03:01 AM
Chart changing entry position at end of day b-rock Charting 3 09-20-2008 04:33 PM
I have opened position I cannot close maxima Miscellaneous Support 6 06-10-2008 02:36 AM


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