if (State == State.Configure) { SetStopLoss(CalculationMode.Ticks, 30); }
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
SetStopLoss method does not update quantity upon partial position close
Collapse
X
-
SetStopLoss method does not update quantity upon partial position close
SetStopLoss method does not update quantity upon partial position close. Suppose I've filled a position of 4 contracts and SL is on 4 contracts alright. At at point, I decided to close 2 contracts but this does not update SL quantity automatically. Any help to fix this would be nice. Thanks.
Code:Tags: None
-
Hello singjay,
Thank you for your post.
Are you closing the 2 contracts manually or programmatically? I see you are calling SetStopLoss() without using a fromEntrySignal name. This means the exit order will be attached to all entries and the quantity should match the quantity for the Position object in NinjaScript:
If you are manually closing 2 contracts, this would not necessarily update the position object in the strategy and could be the reason you are not seeing the stop loss quantity change. If you would like to manually modify stops and targets, I suggest using ATM strategies in your NinjaScript strategy logic. This allows you to set programmatic entries, then manually manipulate the entry/stop/target orders as desired. For more information:Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
-
Hello singjay,
Thank you for your reply.
Do you see any errors on the log tab of the Control Center? If so, what do the errors report?
I suggest adding Print() statements as well as enabling Trace Orders to receive valuable information in the NinjaScript Output window to help you better understand your strategy's behavior. For more information on using prints and trace orders, please see the following links:- https://ninjatrader.com/support/foru...ing#post791121
- https://ninjatrader.com/support/help...aceorders2.htm
Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by AaronKoRn, Today, 09:49 PM
|
0 responses
11 views
0 likes
|
Last Post
by AaronKoRn
Today, 09:49 PM
|
||
Started by carnitron, Today, 08:42 PM
|
0 responses
10 views
0 likes
|
Last Post
by carnitron
Today, 08:42 PM
|
||
Started by strategist007, Today, 07:51 PM
|
0 responses
11 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,980 views
3 likes
|
Last Post
by jhudas88
Today, 06:59 PM
|
||
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
9 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
Comment