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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    61 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    39 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    21 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    23 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    51 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X