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

Partially close a position : SL & TP update

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

    Partially close a position : SL & TP update

    Hi Guys;

    Using a custom window where user can choose an ATM, I send some market orders.
    When I partial close a position, let's say from 4 QTY to 2, the stop loss and take profit keeps 4 QTY.

    How please may I partial close a position in an Addon without using Strategy base code and update SL & TP with the new position size?

    (e.g partially close passing by chart trader works prefectly, here, I would need a custom button for the partial close)

    Thanks
    Last edited by TradeForge; 02-22-2024, 10:00 AM.
    TradeForge
    NinjaTrader Ecosystem Vendor - TradeForge

    #2
    Hello TradeForge,

    Thank you for your post.

    Can you please clarify how exactly you are submitting the orders in your AddOn script?

    In an AddOn script, you should use Account.CreateOrder() to create the order to partially close the position and Account.Submit() to submit that order.

    CreateOrder() - https://ninjatrader.com/support/help...reateorder.htm
    Submit() - https://ninjatrader.com/support/helpGuides/nt8/submit.htm

    I look forward to assisting further.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Hi Gaby;

      Thank your for your answer.

      In fact I already use the methods you mentionned.
      In case the user select a strategy using the visual component, then I start the ATM

      Here the part of the code when I submit an order:
      Click image for larger version

Name:	image.png
Views:	36
Size:	45.4 KB
ID:	1292622

      My issue here it's when an order is taken using the ATM, with a quantity/market size of 4 lots let's say, and if I manlualy close 2 lots, the SL and TP remain 4 Lots instead of 2.
      I would like the SL and TP to be updated with the new position size, by code
      TradeForge
      NinjaTrader Ecosystem Vendor - TradeForge

      Comment


        #4
        Hello,

        Thank you for your response.

        Can you clarify, are you trying to close these orders manually or by code? Apologies as I'm a little confused since you mentioned doing it manually but also asked how to accomplish this by code.

        Would you be able to provide a reduced test script that demonstrates the behavior?
        Gaby V.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jonafare, 12-06-2012, 03:48 PM
        5 responses
        3,986 views
        0 likes
        Last Post rene69851  
        Started by Fitspressorest, Today, 01:38 PM
        0 responses
        2 views
        0 likes
        Last Post Fitspressorest  
        Started by Jonker, Today, 01:19 PM
        0 responses
        2 views
        0 likes
        Last Post Jonker
        by Jonker
         
        Started by futtrader, Today, 01:16 PM
        0 responses
        8 views
        0 likes
        Last Post futtrader  
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,792 views
        0 likes
        Last Post aligator  
        Working...
        X