I would like to be able to move the stop manually in a strategy created in strategy builder, is there any line of code that could help to be able to move the SL and target once the order is placed?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Stop loss and Target can´t be moved manually in a strategy
Collapse
X
-
Stop loss and Target can´t be moved manually in a strategy
Hi
I would like to be able to move the stop manually in a strategy created in strategy builder, is there any line of code that could help to be able to move the SL and target once the order is placed?
Tags: None
-
Hello henryd333,
Thank you for your post.
To be able to manually move the stop and target created by a strategy you would have to unlock your code from the Strategy Builder using the 'Unlock code' button. After unlocking your code, you would need to use Exit method variations instead of Set methods. For example, if you were to create a Stop and Target using Exit methods, you could use the following Exit method variation. These are seen in the help guide documentation.
ExitLongStopLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName, string fromEntrySignal)
ExitLongLimit(int barsInProgressIndex, bool isLive UntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)
See the attached example script that demonstrates using Exit methods to place a Stop and Target that could be manually adjusted.
Also, see the help guide documentation below for more information.
ExitLongStopLimit() - https://ninjatrader.com/support/help...gstoplimit.htm
ExitLongLimit() - https://ninjatrader.com/support/help...tlonglimit.htm
Let us know if we may assist further.Attached FilesBrandon H.NinjaTrader Customer Service
- Likes 1
-
Hello, would it be possible to provide a short only version of the above ExitMethodsSample.zip that otherwise functions the exact same way with the manually movable limit and stop limits? I'm not grasping how to change the code and am getting "Limit price can't be smaller than stop price" errors.
Comment
-
Hello a99x77,
Thanks for your note.
This error message means that you are passing in a Limit Price value that is lower than your Stop Price value when calling your ExitShortStopLimit() method.
Yo would need to ensure that you are passing in a Limit Price value that is higher than your Stop Price value to resolve this error.
See the attached example script which is a modified version of the previously attached example that places short orders only.
Also, see this help guide page for more information about ExitShortStopLimit(): https://ninjatrader.com/support/help...tstoplimit.htm
Let me know if I may assist further.Attached FilesBrandon H.NinjaTrader Customer Service
Comment
-
Hello hellboy78,
Thanks for your note.
You would need to use Exit() methods instead of Set() methods in your script as seen in the example scripts posted in this thread.
For example, you could use ExitLongLimit() instead of SetProfitTarget(). You could use ExitLongStopLimit() instead if SetStopLoss().
See this help guide page for more information about Managed Approach Order Methods: https://ninjatrader.com/support/help...d_approach.htm
Let me know if I may assist further.Brandon H.NinjaTrader Customer Service
Comment
-
Hello hellboy78,
Thanks for your note.
If you currently use user-defined properties for your Set() method value argument, you would need to use those user-defined properties to offset your Exit() methods price field.
You would select 'Exit long position by limit order', click 'set' in the Limit price field, change the offset to 'Ticks', and set the value to use your user-defined variable.
See the attached screenshots showing how this would be set up for an ExitLongLimit() order for your profit target.
Something similar would be done to set up your Exit() method for your stop loss using ExitLongStopLimit().
Let me know if I may assist further.Brandon H.NinjaTrader Customer Service
Comment
-
so for exit profit target
ExitLongLimit (Position.AveragePrice + (ProfitTicks * TickSize))
ExitShortLimit (Position.AveragePrice + (ProfitTicks * TickSize))
or
ExitLongLimit (Position.Quantity , Position.AveragePrice + (ProfitTicks * TickSize))
ExitShortLimit (Position.Quantity , Position.AveragePrice + (ProfitTicks * TickSize))
and for exit stop loss?
ExitLongStopMarket (Position.AveragePrice + (ProfitTicks * TickSize))
ExitShortStopMarket (Position.AveragePrice + (ProfitTicks * TickSize))
I should use something different from "ProfitTicks" ?
Comment
-
Hello hellboy78,
Thanks for your note.
Yes, that would be the correct way to use the ExitLongLimit() and ExitLongStopMarket() methods.
ProfitTicks is simply a user-defined variable used to determine the number of ticks away that the profit target/stop loss will be placed from the entry order.
This variable could be replaced with any int variable that you want to use for your Exit order methods.
See the help guide documentation below for more information and sample code.
ExitLongLimit(): https://ninjatrader.com/support/help...tlonglimit.htm
ExitLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm
Let me know if you have any other questions.Brandon H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by andrewtrades, Today, 04:57 PM
|
1 response
5 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
3 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
6 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
19 views
0 likes
|
Last Post Today, 03:33 PM |
Comment