Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit Targets

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

    Profit Targets

    Hi

    I wrote a system and I'd like to apply a profit target, not a static one based on fixed nr of pips, but proportional to the ATR.

    To do so, after my conditions to enter/exit trades, I wrote:

    // Condition set 3
    if (Close[0] > Position.AvgPrice * (1 + ATR(14)[0]))

    {
    ExitLong("TAKEPROFIT", " BUY");
    }

    It doesn't work though, like if those lines were not present, the system trades regardless.

    What did I forget please?

    Any help greatly appreciated

    #2
    I suggest debugging your code as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418

    Comment


      #3
      Hi Ray,

      Thank you for the link, but I didn't find anything close to what I need.

      Could you please just watch the line of code and tell me if it's right? I just want to take profit conditional to a certain value of an indicator.

      Otherwise, are there any strategy examples?

      Many thanks

      Comment


        #4
        You might find additional info on NinjaScript coding issues here: http://www.ninjatrader-support.com/v...splay.php?f=30

        Also: Please check your logs for funny messages.

        Comment


          #5
          I think your target will be way too big (or small if ATR is negative.)

          Maybe you want something more like this...

          Code:
          if (Close[0] > (Position.AvgPrice + (multiplier * ATR(14)[0])))
          {
            ExitLong...
          }
          Where "multiplier" is determined by your strategy.

          Comment

          Latest Posts

          Collapse

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