Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Flattening strategy when CumProfit is hit during open trades

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

    Flattening strategy when CumProfit is hit during open trades

    I have an automated strategy using three contracts with 3 different profit targets that I have working well to cease trading when a selected CumProfit target is hit, but this happens only after the trades for all 3 contracts are closed by the SetStopLoss settings which move up/down with the direction of the trade. However, quite often the cumprofit target is hit during the trade, only to pull back and take out the SetStopLoss at a lower profit, forcing the strategy to take another trade.

    Is there a way to force a strategy to flatten, or to move the SetStopLoss position for all contracts, as soon as price goes above/below what is the CumProfit level? That is to check tick-by-tick when the selected CumProfit is hit rather than onbarupdate.

    Nano

    #2
    Nano, you can set CalculateOnBarClose = false and then the strategy will update every tick. Then, it is possible to combine that with GetProfitLoss() to get a strategy that checks the open P/L every single tick:
    Code:
    double openPL = Position.GetProfitLoss(Close[0], PerformanceUnit.Currency);
    Lastly, a simple close all positions function could be something like this:
    Code:
    if (Position.MarketPosition != MarketPosition.Flat)
    {
        if (Position.MarketPosition == MarketPosition.Long)
           ExitLong();
        else
           ExitShort();
    }
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    574 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X