• 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 xmanjames, Today, 04:22 PM
    0 responses
    3 views
    0 likes
    Last Post xmanjames  
    Started by McQuac, Today, 03:48 PM
    0 responses
    3 views
    0 likes
    Last Post McQuac
    by McQuac
     
    Started by aviat72, Today, 01:00 PM
    2 responses
    11 views
    0 likes
    Last Post aviat72
    by aviat72
     
    Started by Andrey-Ufa, Today, 12:18 PM
    0 responses
    2 views
    0 likes
    Last Post Andrey-Ufa  
    Started by ben_ocean11, Today, 10:16 AM
    0 responses
    10 views
    0 likes
    Last Post ben_ocean11  
    Working...
    X