Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Separate stops for trades in same direction

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

    Separate stops for trades in same direction

    When I enter a trade with 3 targets, the stop of target2 and target 3 moves to break even after target one is fill.
    My problem is when I enter more than 1 trades in same direction, the stop for the unfilled targets moves to an average of all the trades and the targets of the previous trades don’t get fill until the targets of last trade are fill.
    How can I separate targets and stops from all trades in same direction.

    Thanks
    Here is my script
    privatevoid ManageOrders()
    {
    if (Position.MarketPosition == MarketPosition.Long)
    {
    if (be2)
    {
    if ( High[0] >= Position.AvgPrice + (Target1*TickSize)) //this is the break even target 2
    SetStopLoss("target2",CalculationMode.Price,Position.AvgPrice,false);
    }
    if(be3)
    {
    if ( High[0] >= Position.AvgPrice + (Target1*TickSize)) //this is the break even target 3
    SetStopLoss("target3",CalculationMode.Price,Position.AvgPrice,false);

    }
    }

    if (Position.MarketPosition == MarketPosition.Short)
    {
    if (be2)
    {
    if ( Low[0] <= Position.AvgPrice - (Target1*TickSize)) //this is the break even target 2
    SetStopLoss("target2",CalculationMode.Price,Position.AvgPrice,false);
    }
    if(be3)
    {
    if ( Low[0] <= Position.AvgPrice - (Target1*TickSize)) //this is the break even target 3
    SetStopLoss("target3",CalculationMode.Price,Position.AvgPrice,false);

    }

    }

    }



    #2
    robe2010, I don't see where be2 and be3 are set so I'm not sure if this would be expected behavior then. Can you please post the entire script here?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Hi Austin,
      I Have Attached the strategy and a Chart.
      thanks for you replay and your help.
      Attached Files

      Comment


        #4
        robe2010, please rename all of your stops to something like "stop1", and "stop2", instead of the target names. You are trying to set both stops and targets to the same signal name, which would definitely result in some unexpected behavior.
        AustinNinjaTrader Customer Service

        Comment


          #5
          I rename the stops as you advise, I got the same results.
          I have attached a chart for you to see my results.
          Im wondering if my problem is that stops are merging because im using the
          Position.AvgPrice to set my stop loss??

          Thanks for your patience
          Attached Files

          Comment


            #6
            Hi robe2010,

            How can I separate targets and stops from all trades in same direction.
            You do this with unique signal names, and matching the fromEntrySignal parameter in your stops and targets with the signal name specified in the Enter method. It looks like your strategy does this already. You may want to change EntryHandling for your strategy to UniqueEntries, so that you're allowing x EntriesPerDirection for each uniquely named rule. This allows more control on scaling in and out with multiple stops / targets. A basic scale out strategy is available here:



            I would first create a basic scale out strategy that works as you expect, and then work on integrating the dynamic stop loss movement into this.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi RyanM,
              I finally was able to separate the targets from trades in same direction by creating a method for every Entry, but I’m still can’t separate the stops when want move to a break even.
              I named the trades tradeA, tradeB, tradeC, tradeD……… every time I enter a trade I calculate the AvgPrice and assign the value to variable, but when I am a single trade (tradeA) the average is OK, once trade B is enter I again calculate AvgPrice and assign to another variable in this case I got the average of both trades A & B., the same when I add a trade C , I got The average of tradeA,B & C.
              Any suggestions on how to separate the average of all the trades or is there way to save my entry price of every trade in a variable to be used later to move my stop to break even for very trade without using "Position.Avgprice".???
              Thanks for all your help
              privatevoid ManageOrders()

              if (Position.MarketPosition == MarketPosition.Long)
              {
              BarColor = Color.DarkGreen;
              DrawTextFixed(
              "tag1", "CURRENT POSITION LONG", TextPosition.TopLeft, Color.White,textFontMed , Color.DarkGreen, Color.Green,8);
              if (be2)
              {
              if(beA )
              {
              EntryA = Position.AvgPrice;
              if ( High[0] >= EntryA + (Target1A*TickSize))
              {
              SetStopLoss(
              "target2A",CalculationMode.Price,EntryA,false);
              SetStopLoss(
              "target3A",CalculationMode.Price,EntryA,false);
              beA =
              false;
              }}
              if(beB )
              {

              EntryB = Position.AvgPrice; ;
              if ( High[0] >= EntryB + (Target1B*TickSize))
              {
              SetStopLoss(
              "target2B",CalculationMode.Price,EntryB,false);
              SetStopLoss(
              "target3B",CalculationMode.Price,EntryB,false);
              beB =
              false;
              }}
              Attached Files

              Comment


                #8
                robe2010, for more precise control and order feedback info I would suggest working with the more advanced IOrder objects - http://www.ninjatrader.com/support/h...nt7/iorder.htm

                Comment


                  #9
                  IOrders was the perfect solution, I have now separated the targets and stops for all my entries.


                  thanks soo much for all your help.

                  Comment


                    #10
                    Glad to hear this it's working out for you!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    673 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    379 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    111 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    577 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    582 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X