Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalclateOnBarClose question

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

    CalclateOnBarClose question

    I have a strategy that I need to use CalculateOnBarClose = true for most of it, but need CalculateOnBarClose = false for adjusting my stop losses. I'm using the following code;



    if(Position.MarketPosition == MarketPosition.Long
    && Close[
    0] - Position.AvgPrice >= 5*TickSize
    && Close[
    0] - Position.AvgPrice < 10*TickSize)
    {
    SetStopLoss(
    "Long PB", CalculationMode.Ticks, 3, false);
    }

    and would like it to update at the moment it occurs, and not wait until the bar closes. I can do this of course by setting CalculateOnBarClose = false, but I need the rest of my strategy to run on CalculateOnBarClose = true.

    Is there a way to apply CalculateOnBarClose = false just to this portion of my code?

    Thanks,

    Safetrading

    #2
    Hello Safetrading, you can use the solution presented in the following reference sample to work with COBC true and false in the same script - http://www.ninjatrader.com/support/f...ad.php?t=19387

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    144 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X