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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      388 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      260 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      218 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      302 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      269 views
      0 likes
      Last Post CarlTrading  
      Working...
      X