In my strategy, I enter shorts/longs using EnterShortLimit/EnterLongLimit, respectively. I have a main profit target set with setProfitTarget as well as a stop loss set with setStopLoss. I also have trims through my way to my main profit target using exitShort/exitLong. My question is, is there a way, in a managed approach, to modify my profit target and stop loss order's quantities to reflect the trims that have been made?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy getting short after exiting due to taking trims on a managed approach
Collapse
X
-
Strategy getting short after exiting due to taking trims on a managed approach
Good evening,
In my strategy, I enter shorts/longs using EnterShortLimit/EnterLongLimit, respectively. I have a main profit target set with setProfitTarget as well as a stop loss set with setStopLoss. I also have trims through my way to my main profit target using exitShort/exitLong. My question is, is there a way, in a managed approach, to modify my profit target and stop loss order's quantities to reflect the trims that have been made?Tags: None
-
Hello jrebollar,
If you are using Set methods like SetStopLoss(), these would adjust automatically.
If you are using exit methods like ExitLongStopMarket(), you can adjust the order when the entry / exits fill from OnExecutionUpdate().
Below is a link to an example.
Chelsea B.NinjaTrader Customer Service
-
Good morning Chelsea,
I do use SetStopLoss() and here is an example of what happened yesterday evening:
Looking at the examples in the link you sent, since profit target is not filled when I am scaling out of my position, could I just use ChangeOrder to change the order quantity to Position.Quantity?
Comment
-
Hello jrebollar,
If you are attempting to scale in and out, use separate entry orders with unique signal names and attach exits for the entire quantity of each entry.
Below is a link to an example.
How do I set up Strategy builder to scale out of a 3 contract order? Say close 1 @ 5 ticks, close 1 @ 15 ticks and trail 1 at 25 ticks? Do you have a video
You cannot use ChangeOrder() on orders submitted with Set methods, but you can change orders submitted with entry or exit methods.
The order must be assigned to a variable from OnOrderUpdate(), and then that variable supplied to ChangeOrder().
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello jrebollar,
This may be due to using multiple exit orders on the same entry order, which we do not advise. Instead we suggest using multiple entry orders which each order having a quantity that you want to scale out of a position.
If you must adjust the exit quantity, I would recommend using exit orders or the unmanaged approach.Chelsea B.NinjaTrader Customer Service
Comment
-
Understood. I appreciate your help Chelsea. Another question, is it okay to use public variables? I created a class and the only way I've been able to get access to them is using public variables.
Example
Code:class testClass { public double var1{get; set;} public double var2 {get; set;} public DateTime time {get; set;} }
Comment
-
Hello jrebollar,
In a custom class everything would need to be public to be accessible. The class instance doesn't have to be public, but can be if you want it to.
private testClass myTestClassInstance;
myTestClassInstance = new testClass();
From the indicator or strategy class, anything public will be made into a property and will be attempted to be saved in xml.
Use the XmlIgnore() attribute if the public variable is a data type is not a bool, number (like int or double), string, or enum.
Use Browsable(false) if you do not want the variable to be a property in the UI.
Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
139 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|
Comment