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

Profit Target !!

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

    Profit Target !!

    Hello,
    Do Not activate the profit Target!! Why?
    Code:
    # region OrderRouting
    private void ManagerOrder ()
    {
    if (Position.MarketPosition == MarketPosition.Long)

    {
    SetProfitTarget ("", CalculationMode.Price, Position.AvgPrice+ ATR (14) 0]));// does not work
    }
    }
    # endregion

    protected override void OnBarUpdate ()
    {
    ManagerOrder ();

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

    if (Low [0] <Low [1] & & Low [1] <Low [2])
    EnterLongStop (10, High [0], "EntryLong");
    SetStopLoss (CalculationMode.Price (Low [0]);
    SetProfitTarget ("Profit", CalculationMode.Price (Close [0] + ATR (14) [0 ])));
    }

    Ciao
    Roberto

    #2
    Roberto, your signal namings are unfortunately off - please try 'EnterLong' as well as 'FromEntrySignal' parameter in your first SetProfitTarget call - to debug any strategy order submission issue, TraceOrders are very helpgul - http://www.ninjatrader.com/support/f...ead.php?t=3627
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hello Bertrand,
      The horizontal lines to indicate the level of profit is correct. In the Output of window the calculation is correct for the Profit, but profit is not activated. Why?
      The code is more detailed:

      TraceOrders = true;

      # region OrderRouting
      private void ManagerOrder ()
      {
      if (Position.MarketPosition == MarketPosition.Long)

      {
      SetProfitTarget ("", CalculationMode.Price, Position.AvgPrice + ATR (14) 0 ]));// Does not work
      DrawText("tag3","ProfitLONG",0,Position.AvgPrice+A TR(14)[0]),Color.Green); OK
      DrawHorizontalLine("tag4",Position.AvgPrice+ATR(14 )[0]),Color.Blue); OK
      }
      }
      # endregion

      protected override void OnBarUpdate ()
      {
      ManagerOrder ();

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

      if (Low [0] <Low [1] & & Low [1] <Low [2])
      EnterLongStop (10, High [0], "EntryLong");// It 'requires a stop order
      SetStopLoss (CalculationMode.Price (Low [0]);
      SetProfitTarget ("Profit", CalculationMode.Price (Close [0] + ATR (14) [0 ])));
      Print(Time[0]+ " Valeu EntryLONG " + (High[0]));

      }

      Comment


        #4
        Italy, you named your entry "EnterLong", please ensure the profit target picks up this name in it's FromEntrySignal parameter.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I use the simulated data feed and create the condition for entry Long.
          In the chart the lines(Stop and Profit) are drawn correctly.
          In the OutPut of window the price of profit is correctly, but pratically there is not the closing Profit when the price is reached.....is a mystery!!

          Comment


            #6
            Roberto, did you follow through on testing out the changes I outlined with the signal naming in your code? Would that change the outcome you see?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              sorry but I do not know what to do, trying to explain in simple way or with an example.
              Thanks.
              Roberto

              Comment


                #8
                Roberto, please try this call instead then in your code -

                SetProfitTarget ("EnterLong", CalculationMode.Price, Position.AvgPrice + ATR (14) 0 ]));
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Thanks Bertrand
                  Everything Ok.
                  Roberto

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  167 responses
                  2,260 views
                  0 likes
                  Last Post jeronymite  
                  Started by warreng86, 11-10-2020, 02:04 PM
                  7 responses
                  1,362 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Perr0Grande, Today, 08:16 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post Perr0Grande  
                  Started by elderan, Today, 08:03 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post elderan
                  by elderan
                   
                  Started by algospoke, Today, 06:40 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post algospoke  
                  Working...
                  X