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

Disable Strategy on Realized Net PnL Target

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

    Disable Strategy on Realized Net PnL Target

    I have two separate strategies that work simultaneously. I would like to disable both strategies at the same time when the realized Net Profit from both strategies combined ( I would assume total account PnL) has reached specified currency values, say $3000 or -$1500.

    This is currently implemented in my two scripts:

    // if net PnL is greater than $3000 or a loss of less than -$1500, then we need to close the strategy.
    if (SystemPerformance.AllTrades.TradesPerformance.Cur rency.CumProfit > 3000
    || SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit < -1500)
    {
    CloseStrategy("My Custom Close");
    }


    The strategy disables on its own when either of these conditions are met which is great; however, I would like to change "CumProfit" with the total Net PnL of the two combined active strategies. What should be the correct syntax for the bots to gather the combined net PnL of all active strategies?

    Thanks for the help in advance.
    Last edited by Don22Trader1; 10-26-2021, 04:28 PM.

    #2
    Hello Don22Trader1,

    Thanks for your post.

    You could consider having the strategies read/write to static variables in an AddOn to share a combined Net PnL.

    See the MySharedMethodsAddOnExample script in post #2 of this forum thread linked below for an example of creating static methods.

    MySharedMethodsAddOnExample: https://ninjatrader.com/support/foru...est#post733956

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    942 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    9 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    4 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    28 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    33 views
    0 likes
    Last Post wzgy0920  
    Working...
    X