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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          81 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          41 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          64 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          66 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          54 views
          0 likes
          Last Post CarlTrading  
          Working...
          X