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!
See more
See less

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.
    Emily C.NinjaTrader Customer Service

    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.
        Emily C.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        15 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        14 views
        0 likes
        Last Post strategist007  
        Working...
        X