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
Change a SetStopLoss() Order
Collapse
X
-
Hello sjmuk1,
There is a sample in the following link that shows how you can do a breakeven. The sample is not using SetStopLoss but is instead using ExitLongStopMarket, if you wanted to use SetStopLoss instead you could replace the ExitLongStopMarket order syntax with SetStopLoss. This sample otherwise lines up with what you described, it uses Order objects to know the state of the orders and also uses the order events to drive its logic.
https://ninjatrader.com/support/help...and_onexec.htm
The important parts of this sample would be its use of OnExecutionUpdate and OnOrderUpdate to manage its Order variables. Also OnBarUpdate where the entry is submitted and the break even for the target is managed. The Position and Order information are used from OnBarUpdate to delegate the breakeven and entry.
This sample only uses 1 order for simplicity, I would suggest that you initially do the same to make sure you have a single order being tracked correctly. That also lets you change to using SetStopLoss if you wanted. Once you do that you can expand it to support multiple entries or scaling if you wanted to.
Leave a comment:
-
OK Thanks, How could you suggest i approach checking my open positions for moving them to breakeven at some point if I am using SetStopLoss(). I'll have filled entry order objects to check and some will be closed positions with cancelled or filled stops and some will be open positions with active working stops. I want to only check breakeven on the ones that are currently open positions. What do you suggest?
Leave a comment:
-
Hello sjmuk1,
Yes its the same exact concept you would just have two separate entry orders and two separate SetStopLoss syntax.
The Signal name from the entry order is used to tie a stop to that entry so you would have two entries with unique signal names and then each of your targets can reference a specific entry to close out part of a position.
Leave a comment:
-
Thanks, what if i have two speperate entry orders and I want to manage two separate stoploss orders for them, can I do that with SetStopLoss()?
Leave a comment:
-
Hello sjmuk1,
The Set methods are submitted based on the entry fill but you can change it later by calling SetStopLoss again with new values.
The two ways to use SetStopLoss orders would be statically by calling SetStopLoss in State.SetDefaults, that gives an always used stop. The other way would be to initialize the stop then submit the entry so that the stop is attached to the entry, that looks like this:
SetStopLoss(yourvalues);
EnterLong();
later you can call SetStopLoss again from other conditions in OnBarUpdate to update it.
Leave a comment:
-
Change a SetStopLoss() Order
Hi, Can a StopLoss submitted after an order execution, which was set using SetStopLoss() be subsequently changed?Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ny10013, Today, 06:45 AM
|
2 responses
16 views
0 likes
|
Last Post
![]()
by ny10013
Today, 11:05 AM
|
||
Started by thowar9, 03-03-2021, 11:48 PM
|
18 responses
1,292 views
1 like
|
Last Post
![]()
by tanagoswami
Today, 09:41 AM
|
||
Started by Sadarar, Today, 09:13 AM
|
0 responses
17 views
0 likes
|
Last Post
![]()
by Sadarar
Today, 09:13 AM
|
||
Started by RMin101, 05-24-2023, 01:50 PM
|
34 responses
154 views
0 likes
|
Last Post
![]()
by Atomic
Today, 08:16 AM
|
||
Started by Atomic, Today, 06:40 AM
|
0 responses
17 views
0 likes
|
Last Post
![]()
by Atomic
Today, 06:40 AM
|
Leave a comment: