Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Take Profit condition not executed

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

    Take Profit condition not executed

    Hello everyone

    I developed a strategy with signals "LONG" and "SHORT".

    I want to take profit if the system is long and it's making money but the last two bars closed lower.

    I wrote the following code, which is not working:

    // Condition set Long Take Profit
    if (Close[0] > (Position.AvgPrice)
    && Position.MarketPosition == MarketPosition.Long
    && Close[0] < Close[1]
    && Close[1] < Close[2])


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

    Why it doesn't work?

    Thank you

    #2
    Likely the conditions are not being met?

    In any case, you will have to debug this to determine what is happening. You have likely seen this before but I am posting this link in case you have not.

    RayNinjaTrader Customer Service

    Comment


      #3
      The conditions are met many times (I could see it on the charts), so I was wondering if the code was wrong.

      Originally posted by NinjaTrader_Ray View Post
      Likely the conditions are not being met?

      In any case, you will have to debug this to determine what is happening. You have likely seen this before but I am posting this link in case you have not.

      http://www.ninjatrader-support.com/v...ead.php?t=3418

      Comment


        #4
        Enable TraceOrders and see what the output window tells you about this order.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        601 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        559 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X