Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Take action on incoming tick

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

    Take action on incoming tick

    What command can I use to move my stop loss to breakeven once price profits 4 ticks? I have the logic included below, but I do not want to wait for bar to close before my stop loss gets modified. I want stop loss to move to break even as soon as price touches 4 tick profit (rather than wait for bar to close). Is there a way to do this?

    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss(CalculationMode.Ticks,
    8);
    }

    // If a long position is open, allow for stop loss modification to breakeven
    elseif (Position.MarketPosition == MarketPosition.Long)
    {
    // Once the price is greater than entry price +4 ticks, set stop loss to breakeven
    if (High[0] > Position.AvgPrice + 4 * TickSize)
    {
    SetStopLoss(CalculationMode.Price, Position.AvgPrice);
    }
    }


    }

    #2
    Hello,

    Do you have CalculateOnBarClose set to false in your initialization?
    DenNinjaTrader Customer Service

    Comment


      #3
      I can try that. There are some parts of the code that I want calculated only upon bar closing, except for this part. Is there way to do that. An example is initiating a trade only once bar closes, but moving my stop loss to breakeven once 4 tick profit is touched.

      Comment


        #4
        Hello,

        Then I would use FirstTickOfBar to trigger these 'on bar close' actions:
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        51 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        142 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        160 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        96 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        275 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X