Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss method does not update quantity upon partial position close

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:
                
    if (State == State.Configure)
                {
                    SetStopLoss(CalculationMode.Ticks, 30);
    }
    ​

    #2
    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.

    Comment


      #3
      I'm closing partial position programmatically, not manually using chart trader. Thanks.

      Comment


        #4
        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:If you plan to scale out of a position, I suggest using separate entry orders for the desired quantity you plan to scale out later. The following example demonstrates how to achieve this:Please let us know if we may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        50 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X