Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetprofitTarget ???

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

    SetprofitTarget ???

    Hello,
    I have a problem with the SetprofitTarget,is not activate when it reaches the price . In the Output window , the calculation: Close [0] + RangeIL is correct. The profit does not fire when the price is reached.
    Code:

    # region Positions
    private void GoLong ()

    EnterLong (10, "");
    SetProfitTarget (LongBuy "CalculationMode.Price, Close [0] + rangeIL);
    Print (Time [0] + "Value rangeIL" rangeIL +);// it's OK
    # endregion

    protected override void OnBarUpdate ()

    if (variable1 Variable0 == 0)
    {

    GoLong ();
    }

    Ciao.
    Roberto

    #2
    Roberto, it looks like the FromEntrySignal name is not correct in your call so it's not picked up - you would need to name your entry then LongBuy, too.

    Comment


      #3
      Sorry, but I do not know what to do. Here's the code more detail:
      # region Variables
      private double rangeIL = 1;

      # endregion

      # region Positions
      private void GoLong ()
      EnterLong (10, "");
      SetProfitTarget (LongBuy "CalculationMode.Price, Close [0] + rangeIL);
      Print (Time [0] + "Value rangeIL" rangeIL +);// it's OK but the profit does not work
      # endregion

      # region OrderRouting
      private void ManagerOrder ()
      {
      if (Position.MarketPosition == MarketPosition.Long)
      SetStopLoss (CalculationMode.Percent, 0.04);
      Etc. .....
      }

      # endregion

      protected override void OnBarUpdate ()

      ManagerOrder ();
      if (Position.MarketPosition! = MarketPosition.Flat) return;

      if (variable1 Variable0 == 0)
      {

      GoLong ();
      }

      Hello.
      Roberto

      Comment


        #4
        Roberto, you tag the target to the incorrect entry signal name - please try the snippet below instead -

        EnterLong (10, "LongBuy");
        SetProfitTarget ("LongBuy", CalculationMode.Price, Close [0] + rangeIL);

        Comment


          #5
          Ok Bertrand,
          I removed the region Positions, now works.
          Thanks.
          Hello.
          Roberto

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          152 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          89 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          133 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          127 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          107 views
          0 likes
          Last Post CarlTrading  
          Working...
          X