Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MultipleEntries StopLoss Issue

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

    MultipleEntries StopLoss Issue

    TradeA is getting stopped out by TradeB's stoploss. Here is an example:

    Trade A: Long Entered @ 1.1100
    StopLoss @ 1.1000 (100 pips)

    Trade B: Long Entered @ 1.1200
    StopLoss @ 1.1100 (100 pips)

    Trade A is getting stopped out at 1.1100 from TradeB's stoploss.

    Any help is appreciated.
    KeelRisk

    #2
    Hi KeelRisk, can you post the code you're using for your stop loss? There could be a number of reasons the SL is being triggered, but without a code sample we can't be certain.
    AustinNinjaTrader Customer Service

    Comment


      #3
      TradeA is stopped out by TradeB's stoploss...code

      This is not all the code but the main sections. I put a StopLoss and ProfitTarget on in the Initialize() method

      Code:
      [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{ [/FONT][/SIZE]
      [SIZE=2][FONT=Courier New] SetProfitTarget([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], CalculationMode.Ticks, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1000[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New] SetStopLoss([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], CalculationMode.Ticks, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]30[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT][/SIZE][/FONT]
       
      [SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New] CalculateOnBarClose = [/FONT][/SIZE][/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
       
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000] Called on each bar update event (incoming tick)[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{ [/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff] if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (ToTime(Time[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]) == ToTime([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]16[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]))[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New] { [/FONT][/SIZE]
       
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]   //Random Yes or No to trade[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]   if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (GetRandomTrueOrFalse())[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]   {[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]       //If Yes to trade then Random buy or sell[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]       if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (GetRandomTrueOrFalse())[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]       {[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]           if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CanGoLong())[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]               EnterLong(DefaultQuantity, [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]); [/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]       }[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]       else[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]       {[/SIZE][/FONT]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]           if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CanGoShort())[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]               EnterShort(DefaultQuantity, [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]); [/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]       }[/FONT][/SIZE]
      [SIZE=2][FONT=Courier New]    }[/FONT][/SIZE]
      [SIZE=2][FONT=Courier New] }[/FONT][/SIZE]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
      [/SIZE][/FONT]

      Comment


        #4
        Confused

        I have moved the stoploss and profit limit orders from initialize to onbarupdate(). I have also tried adding an entrySignal to tie everything together but still no luck.

        I continually get stops, hit out of order when EntriesPerDirection > 1

        In need of help
        KeelRisk

        Comment


          #5
          Another piece of the puzzle for what it is worth

          I created a strategy just through the wizard. It enters a buy(long) everyday at 4:00pm with a 1000 pip profit and 30 pip stop. I allow upto 2 postions open.

          When I run this quickie strategy, the stops get crossed just like my custom strategy. So, this way I know I'm not doing anything out of the ordinary on my custom strategy.


          KeelRisk

          Comment


            #6
            TraceOrder logs

            Here is a TraceOrders of the issue. 2 trades...the first trade is getting stopped out(stoploss) from the second trades' stop loss. I can't figure this out!

            HTML Code:
             
            7/1/2004 4:00:00 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Test0' Mode=Ticks Value=1000 Currency=0 Simulated=False
            7/1/2004 4:00:00 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Test0' Mode=Ticks Value=30 Currency=0 Simulated=False
            7/1/2004 4:00:00 PM Entered internal PlaceOrder() method at 7/1/2004 4:00:00 PM: Action=Buy OrderType=Market Quantity=0.01M LimitPrice=0 StopPrice=0 SignalName='Test0' FromEntrySignal=''
            7/2/2004 4:00:00 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Test1' Mode=Ticks Value=1000 Currency=0 Simulated=False
            7/2/2004 4:00:00 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Test1' Mode=Ticks Value=30 Currency=0 Simulated=False
            7/2/2004 4:00:00 PM Entered internal PlaceOrder() method at 7/2/2004 4:00:00 PM: Action=Buy OrderType=Market Quantity=0.01M LimitPrice=0 StopPrice=0 SignalName='Test1' FromEntrySignal=''
            7/5/2004 11:59:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00005/Back101' Name='Profit target' State=Working Instrument='$EURUSD' Action=Sell Limit price=1.331 Stop price=0 Quantity=0.01M Strategy='test1' Type=Limit Tif=Gtc Oco='NT-00001' Filled=0 Fill price=0 Token='59358cb9d3f947d589a0d6a707f9b2c2' Gtd='12/1/2099 12:00:00 AM'
            7/5/2004 11:59:00 AM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00005/Back101' Name='Profit target' State=Cancelled Instrument='$EURUSD' Action=Sell Limit price=1.331 Stop price=0 Quantity=0.01M Strategy='test1' Type=Limit Tif=Gtc Oco='NT-00001' Filled=0 Fill price=0 Token='59358cb9d3f947d589a0d6a707f9b2c2' Gtd='12/1/2099 12:00:00 AM'
            7/5/2004 2:58:00 PM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Back101' Name='Profit target' State=Working Instrument='$EURUSD' Action=Sell Limit price=1.316 Stop price=0 Quantity=0.01M Strategy='test1' Type=Limit Tif=Gtc Oco='NT-00000' Filled=0 Fill price=0 Token='1b3254d213644dbc88d3381b77168b15' Gtd='12/1/2099 12:00:00 AM'
            7/5/2004 2:58:00 PM Cancelled pending exit order, since associated position is closed: Order='NT-00001/Back101' Name='Stop loss' State=Working Instrument='$EURUSD' Action=Sell Limit price=0 Stop price=1.213 Quantity=0.01M Strategy='test1' Type=Stop Tif=Gtc Oco='NT-00000' Filled=0 Fill price=0 Token='c4e2e55de3664bcbbd9c80a16a411222' Gtd='12/1/2099 12:00:00 AM'
             
             

            Comment


              #7
              Do you reset the StopLoss value once in a flat position?

              Comment


                #8
                There is no need to reset once I'm in a flat position because I'm never in a flat postion. As the TraceOrders indicates, I enter position 1, then set a stop and limit order. Then Position 2 gets initiated, then another stop and limit order.

                After all the above occurs, Position 1 hits Position 2's stoploss.

                Let me know if you want to reproduce on your side. It would be very easy. I could export 2 days worth of data and email. Then all you would have to do is create quick stategy that enters the trades at 4:00pm, with a stop of 30pips and profit of 1000pips...that is all

                thanks

                Comment


                  #9
                  KeelRisk, ok thanks - which order handling settings are you using? PerStrategyPosition or PerEntryExecution? - http://www.ninjatrader-support.com/H...tegiesTab.html

                  Comment


                    #10
                    I have it set at PerEntryExecution.

                    KeelRisk

                    Comment


                      #11
                      Ok, please contact me at support at ninjatrader dot com Attn Bertrand with the needed instructions to test this on my end - thank you!

                      Comment


                        #12
                        Sent email...thanks

                        Comment


                          #13
                          Thanks, we're looking into this currently.

                          Comment


                            #14
                            KeelRisk,

                            Development has informed me this is a limitation with using the Strategy Wizard. To scale out you will have to tie unique signal names to your entries and exits. To do so may require custom programming to achieve the scale out effect you want.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Josh,

                              I actually already tried this and still got the same result. I created a custom strategy that tied the trades(entry), stoplosses and profit targets to unique signal names and the stops still got crossed.

                              Should I send a sample so dev can take a look at that scenario?

                              The way I look at it right now is that you cannot trade multiple entries and expect corresponding StopLoss and ProfitTarget calls to remain straight. Which I'm fine with because I can code up and keep track of that myself to hit my own stoploss and profitTarget. However, I would be surprised to see that NinjaTrader does not support multiple entries and associated stops and profit limits. I'm sure I'm just missing something.


                              Thanks
                              KeelRisk

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              672 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