Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    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);
        BertrandNinjaTrader Customer Service

        Comment


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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by owensd, 04-21-2024, 11:34 PM
          9 responses
          34 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by trilliantrader, 04-10-2024, 09:33 PM
          7 responses
          25 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by traderqz, Today, 12:06 AM
          5 responses
          11 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by Mongo, Today, 11:05 AM
          2 responses
          10 views
          0 likes
          Last Post Mongo
          by Mongo
           
          Started by guillembm, Today, 11:25 AM
          0 responses
          5 views
          0 likes
          Last Post guillembm  
          Working...
          X