![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jan 2009
Posts: 94
Thanks: 0
Thanked 14 times in 12 posts
|
Look in the Help Guide for 'IExecution', there is a 'DateTime' property that you can use in your boolean trade logic conditional statements.
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |