protected override void Initialize()
{
// Triggers the exit on close function 30 seconds prior to session end
[COLOR=#ffffff]ExitOnClose[/COLOR] = true;
ExitOnCloseSeconds = 30;
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Overriding the strategy parameters (using values hardcoded)
Collapse
X
-
Overriding the strategy parameters (using values hardcoded)
I see for the help on ExitOnClose that one can specify this in the initialize method:
When I do this, it seems that the value in the code is ignored and the value given in the strategy parameters (dialog box) is used. Is it possible to override these values? For example, sometimes I forget to change one of the values and I run my strategy and get unexpected results. If I can code them in the init method then I wouldn't have to worry about this.Code:Tags: None
-
Whatever value you set for ExitOnClose you in Initialize() would make it to the strategy properties dialog and thus would be effective if you didn't change it.
What probably confuses you is the fact, that the strategies property dialog maintains the last set of values. Unfortunately there is no way around.
-
ok this makes sense that it retains the values so that one wouldn't have to override them every time. So I will code up the values I use the most and then exit NT and then restart and from then on it should use my values that I code in intialize right? This seems like a logical way to have this, to make it easy to override but not require the user to type in the values.Originally posted by NinjaTrader_Dierk View PostWhatever value you set for ExitOnClose you in Initialize() would make it to the strategy properties dialog and thus would be effective if you didn't change it.
What probably confuses you is the fact, that the strategies property dialog maintains the last set of values. Unfortunately there is no way around.
Thanks
Comment
-
Exit Not On Close If strategy made profit
Hello
Is there a way within a strategy to change the ExitOnClose Flag
depending on if the strategy made profit today, or would you recommend exiting all positions by a specific time and not use the Exit On Close = true at all in strategies?
Regards
tradereight
Comment
-
Hello,
It may work but I recommend changing the code to exit at a certain time. Give it a try using a condition something like this:
if(ToTime(Time[0]) >= 93000)
{
ExitLong(....);
}
This link may help:
http://www.ninjatrader-support2.com/...ead.php?t=3226
DenNinjaTrader Customer Service
Comment
-
So you're recommending leaving the session begin/end time at midnight and using a filter on the trading hours? This is a good idea because my strategy is multi-instrument and different instruments have different trading hours. The only problem I see is indicators would be calculated based on non-trading hours data, which I don't think is what I want.
Originally posted by NinjaTrader_Ben View PostHello,
It may work but I recommend changing the code to exit at a certain time. Give it a try using a condition something like this:
if(ToTime(Time[0]) >= 93000)
{
ExitLong(....);
}
This link may help:
http://www.ninjatrader-support2.com/...ead.php?t=3226
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
65 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
41 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
23 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
26 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
52 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment