Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

5 bar high or low, SetStopLoss and SetProfitTarget

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

    5 bar high or low, SetStopLoss and SetProfitTarget

    I want to set my stop loss at five-bar low or high from entry.
    For example, for a long entry and 5-bar low:
    SetStopLoss("long entry", CalculationMode.Price, five-bar low, false);

    How can I express the five-bar low to return the double value for the SetStopLoss. Should I use mutiple time frames, add barsarray ?
    Please help.
    And if I want to set my profit target at the number of ticks that the 5 bar high or low is away from my entry price, how can I express that in the SetProfitTarget?

    For example, for a long entry and 5-bar low:

    SetProfitTarget("long entry", CalculationMode.Price, Position.AvgPrice + (Position.AvgPrice - five-bar low))


    Does the above return the double value I need for my profit target or should I use CalculationMode.Ticks and in that case how can I express the price difference in ticks?
    Thanks in advance for any help.

    #2
    henryblack, welcome to the forums here - I just responded to the note you send to support, please let me know if this helps. Thanks

    Comment


      #3
      I want my profit target to be as many ticks away from my entry price as the 5-bar low.

      SetProfitTarget("long entry", CalculationMode.Price, Position.AvgPrice + (Position.AvgPrice - MIN(Low, 5)[0]))

      Would the above give me the correct value?

      Comment


        #4
        henryblack,

        That would be correct. Please be sure to do this in OnBarUpdate().
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I want to exit half of my position at risk and and the other half at two times risk.
          if (..)
          {
          EnterLong(DefaultQuantity, "long1");
          EnterLong(DefaultQuantity, "long2");
          SetProfitTarget("long1", CalculationMode.Price, Position.AvgPrice + (Position.AvgPrice - MIN(Low, 5)[0]));
          SetProfitTarget("long2", CalculationMode.Price, Position.AvgPrice + (2 * (Position.AvgPrice - MIN(Low, 5)[0])));
          SetStopLoss("long1", CalculationMode.Price, MIN(Low, 5)[0]);
          SetStopLoss("long2", CalculationMode.Price, MIN(Low, 5)[0]);
          }

          Now, if my first target is filled, I want to move the stop loss for the long2 entry signal to break even. What should I put as a condition for this and would the following work?

          if (....)
          {
          SetStopLoss(
          CalculationMode.Price, Position.AvgPrice);

          }

          Would the expression
          Position.MarketPosition == DefaultQuantity
          work for my example?

          Comment


            #6
            henryblack, for moving your stop losses on custom conditions please refer to this sample here - http://www.ninjatrader-support2.com/...ead.php?t=3222

            For a more granular approach a more advanced concept can be used -

            The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()

            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