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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        52 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
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X