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

Exit long vs setstoploss

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

    Exit long vs setstoploss

    If trade is currently in a long position what is the difference below between using ExitLong or using SetStopLoss of just 1 tick. Wouldn't they both essentially exit the trade immediately when conditions are met? Apparently not, because there is a huge difference in net profit when backtesting.

    if (BarsInProgress == 1) && Position.MarketPosition == MarketPosition.Long
    &&//conditions here
    {
    SetStopLoss(CalculationMode.Ticks, 1);
    //or use
    ExitLong(200);
    }

    #2
    Zachj, the Sets would always reference the primary series of the instrument you're dealing with, so you could not tie them / send orders to a specific BarsInProgress like the Exit methods would allow you via their BarsInProgress parameter.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      So basically any of the conditions below specifically "Closes[1][0]" will just ignore the request to use bip=1 and use primary instead?

      if ((BarsInProgress == 1) && Position.MarketPosition == MarketPosition.Long
      && (SMA(BarsArray[0],Fast)[1] < SMA(BarsArray[0],Slow)[1] && SMA(BarsArray[0],Fast)[2] > SMA(BarsArray[0],Slow)[2] && Closes[1][0] < Lows[0][1] - exitdistance)
      {
      SetStopLoss(CalculationMode.Ticks, 1);
      }

      Also if market position is currently long is the stoploss 1 tick below the last price after conditions are met or 1 tick below entry price?

      Comment


        #4
        No, the condition is evaluated on BIP == 1 - however the SetStopLoss command will generate an order for the primary series, it would not allow to specify a bars series to use for it (you need to more advanced exit methods for that).

        The stop references the entry price (Position.AvgPrice) for the price level.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Yes well that's what I want it to do, evaluate the conditions based on BIP==1, once the conditions are met then based on primary set a stoploss 1 tick down from last price. But setstoploss is always based off the entry price so I can't do that. But either way the net profit is a lot higher when I use this setup so I'm just trying to figure out what exactly it's doing.

          The conditions are the opposite of the entry, a crossof the faster MA below the slower MA. But at that point its already below 1 tick under the entry price. So price must have to move back up above the entry price and then move down again. 1 tick below entry is basically stopping it out as soon as the stock goes negative.

          Comment


            #6
            Bertrand, say my primary is a 15min and I am using SetStopLoss(), then 5min into the bar it goes below the stop but then the price rallies and goes up above my target exit by the end of the 15min bar. The stop will not be triggered but instead the target will correct because it doesn't read the SetStopLoss() order until the end of the 15min bar? Essentially giving false profits.

            In order for it to acknowledge the stop price 5min in I would have to use a 5min bar or smaller as primary?

            Comment


              #7
              Correct, if you wanted to simulate the stop fills on the 5 min series, then this would need to be the primary series for the Set() methods.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                With primary as 15min still, if I moved SetStopLoss() from Initialize() down to the OBU section and did say if BIP == 1, Index 1 being 5min. The setstop would still not trigger till the end of the 15min?

                Comment


                  #9
                  It would not matter - the Set()'s are evaluated in relation to your primary series only. You cannot submit in BIP context with them.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Just one more quick thing, does it state this anywhere in the helpguide regarding the Sets only functioning on primary? I don't see it anywhere under the description for SetStopLoss.

                    Comment


                      #11
                      Perhaps not as direct as it should be, as you would see from the managed mode options, that the Set's don't provide any advanced IOrder return nor would take any BarsInProgress to submit against like the Exit methods for example.



                      I will make a suggestion to attempt further clarifying in the next help guide revisions.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Under Multi-Time Frame and Instruments it looks like it addresses it unless I'm misinterpreting...

                        Notes:
                        1. Should you have multiple Bars objects of the same instrument and are using Set() methods in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly.

                        Comment


                          #13
                          Right, there's a small note on it, but my comment was regarding your expectation to see it under the SetStopLoss page in the managed mode section.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Bertrand I have an older post with Lance that I forgot about at this link...


                            I'm getting confused now because in that post he says.... "SetStopLoss in OnBarUpdate will have the stops applied intrabar. "

                            Comment


                              #15
                              zachj, lances post just means that the set method doesn't need to wait until the end of the bar to be placed. His comments are not related to any sort of multi-time frame strategy.
                              MatthewNinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by gravdigaz6, Today, 11:40 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by MarianApalaghiei, Today, 10:49 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by XXtrader, Today, 11:30 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post XXtrader  
                              Started by love2code2trade, Yesterday, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Started by funk10101, Today, 09:43 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post funk10101  
                              Working...
                              X