Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with Take Profit

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

    Problem with Take Profit

    Hi everyone! I need help... here's the code:


    SetProfitTarget("", CalculationMode.Ticks, TP);
    SetStopLoss("", CalculationMode.Ticks, value2, false);

    if (dist1 > dist2)
    {
    TP = entryPrice + dist1;
    }
    else if (dist1 <= dist2)
    {
    TP = value1;
    }
    TP, dist1, dist2, value1, value2 are ALL double variables. We’re OnBarUpdate.

    Why the take profit, when the strategy decides to place it, is always only 1 tick up the entry?

    Thanks!

    #2
    Hello mirkocero,

    Do you intend to use mode ticks? This would an integer value that specifies the number of ticks that the profit target order is placed in relation to the entry price.

    TP = entryPrice + dist1;
    This line here suggests that you may want to use CalculationMode.Price instead.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by mirkocero View Post
      Hi everyone! I need help... here's the code:


      SetProfitTarget("", CalculationMode.Ticks, TP);
      SetStopLoss("", CalculationMode.Ticks, value2, false);

      if (dist1 > dist2)
      {
      TP = entryPrice + dist1;
      }
      else if (dist1 <= dist2)
      {
      TP = value1;
      }
      TP, dist1, dist2, value1, value2 are ALL double variables. We’re OnBarUpdate.

      Why the take profit, when the strategy decides to place it, is always only 1 tick up the entry?

      Thanks!
      In addition to what Ryan wrote, you are setting your SetProfitTarget() based on TP. which is being calculated after the SetProfitTarget() statement, so your SetProfitTarget() target is not what you are calculating, but whatever its last value was.

      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