Is using an Unmanaged order the only way to accomplish this?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Unmanaged Orders
Collapse
X
-
Unmanaged Orders
I would like to be able to adjust the Profit Target and Stop Loss similar to entering an ATM order from the chart trader where you can drag the profit and stop on the chart.
Is using an Unmanaged order the only way to accomplish this?
Tags: None
-
Hello sdauteuil,
Thank you for your post.
Setting a Profit Target and Stop Loss that is able to be manually adjusted on the chart could be accomplished using the Managed Approach with Exit Methods. Please see the attached example script, ExitMethodsSample, which demonstrates how you could use Exit methods to place an adjustable Profit Target and Stop Loss. We use a bool in our script to ensure that orders are submitted once and not for each time OnBarUpdate is processed. This allows us to manually adjust the Profit Target and Stop Loss.
In the example script, we check if we are in a flat position by using Position.MarketPosition == MarketPosition.Flat. If we are in a flat position then the script calls EnterLong to place an entry order and we set a bool variable to true. Then, the script checks if we are in a long position and if the bool == true followed by using ExitLongStopMarket and ExitLongLimit to place a Profit Target and Stop Loss and we also flip our bool back to false.
Please see the help guide documentation below for more information.
ExitLongLimit - https://ninjatrader.com/support/help...tlonglimit.htm
ExitLongStopMarket - https://ninjatrader.com/support/help...stopmarket.htm
Position.MarketPosition - https://ninjatrader.com/support/help...etposition.htm
Let us know if we may assist further.Attached Files<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
-
That seems simple enough.
what is the purpose of State == State.Historical in this instance?
should I include this in my code and If so would the code below be the correct order?
protected override void OnBarUpdate()
if (State == State.Historical)
return;
if ((CurrentBars[0] < 20)
|| (CurrentBars[1] < 20)
|| (CurrentBars[2] < 20))
return;
if (BarsInProgress != 0)
return;
// rest of code
Thanks for the help
Comment
-
Hello sdauteuil,
Thank you for your note.
State == State.Historical checks to see if the strategy is processing historical data. If it is and we call return, the strategy will skip historical data processing.
Yes, that is the correct order for using if (State == State.Historical) return;.
Please let us know if we may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
43 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment