Thanks - Brandon
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
Manually modify strategy-generated orders
Collapse
X
-
Manually modify strategy-generated orders
I currently have a strategy that submits a stop loss and a profit target when a stop limit entry order is filled, but I'm unable to move these orders around. What I would like to do is have the ability to move these orders up and down with a DOM or ChartTrader but whenever I do that now, they snap right back to their original price. Is there any way to accomplish what I'm looking for?
Thanks - BrandonTags: None
-
Hello Brandon,
Thanks for your post.
The SetStopLoss(), SetProfitTarget() and SetTrailStop() methods will all use internal rules that will update the stop or target to the assigned level after each bar closure.
It is possible to use the Exit methods to serve as your profit target and stop loss with the isLiveUntilCancelled overload so the orders can then be adjusted manually.
I've attached some sample code demonstrating how this is possible:
Code:protected override void OnBarUpdate() { if(Historical) return; if(Position.MarketPosition == MarketPosition.Flat) EnterLong("MyEntry"); } protected override void OnExecution(IExecution execution) { if(execution.Name == "MyEntry") ExitLongStop(0, true, 1, Position.AvgPrice - 10 * TickSize, "MyExit", "MyEntry"); }
OnExecution() - https://ninjatrader.com/support/help...nexecution.htm
ExitLongStop() (Please see isLiveUntilCancelled overload) - https://ninjatrader.com/support/help...itlongstop.htm
Also, for a more robust approach to using Exit methods for your protective orders as well as the OnOrderUpdate() and OnExecution() methods, I recommend reviewing the SampleOnOrderUpdate example.
SampleOnOrderUpdate - https://ninjatrader.com/support/foru...ead.php?t=7499
Please let us know if you have any additional questions.Last edited by NinjaTrader_ChelseaB; 10-14-2022, 08:02 AM.JimNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,606 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
8 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
4 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
13 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment