• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code for "Flatten Everything" and Total/Overall Unrealized PnL

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

    Code for "Flatten Everything" and Total/Overall Unrealized PnL

    Hi NT8,

    What is the Ninjascript code to "Flatten Everything"

    Also, is there a Ninjascript code for If(Total/entire account Unrealized PnL is > $100).

    In short, as I place multiple trades, I am looking for a strategy to flatten everything after my entire account Unrealized PnL reaches a profit threshold.

    Thank you
    Last edited by Austiner87; 02-17-2020, 06:03 PM.

    #2
    Hello Austiner87,

    You can find some previous discussion about flattening from a strategy in the following link:
    https://ninjatrader.com/support/foru...om-my-strategy

    Generally you would need to either track your orders and then submit the appropriate close positions or cancel the open orders. You can also use the addon Flatten method as noted.

    For Unrealized PnL you can use the Position object and its GetUnrealizedProfitLoss method.

    https://ninjatrader.com/support/help...8/position.htm
    https://ninjatrader.com/support/help...profitloss.htm


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Dragon989, 11-02-2018, 04:59 PM
    2 responses
    64 views
    0 likes
    Last Post krimkrim  
    Started by Bikotoru, Yesterday, 04:34 PM
    0 responses
    9 views
    0 likes
    Last Post Bikotoru  
    Started by dmking, Yesterday, 03:42 PM
    2 responses
    8 views
    0 likes
    Last Post nikhilkanna1234  
    Started by login_dejavu, Yesterday, 03:30 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by MajorIIssue, Yesterday, 09:17 AM
    4 responses
    15 views
    0 likes
    Last Post MajorIIssue  
    Working...
    X