Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting two EnterStop orders?

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

    Setting two EnterStop orders?

    I wanted to know if it is possible to set a EnterLongStop order as well as a EnterShortStop order at the same time? Also, once one of the orders executes, the original ShortStop or LongStop becomes the stop loss order...

    Just interested in setting this order up to run backtest on different instruments.

    Thanks in advance

    #2
    Hi chatchgo, unfortunately not possible as you would run into our 'Internal Order Handling Rules' with this approach -

    http://www.ninjatrader-support.com/H...verview36.html (bottom section here)

    What you can do is monitor price to determine which order is needed and then only send one leg of the entry bracket.

    NinjaTrader7 will offer a new unmanaged approach to order submission -

    Comment


      #3
      Thank you for the quick reply Bertrand. Maybe I could just run a strategy for the long side, then one for the short side. Is it possible then, to set a stop to the low/high of the previous bar...For example,

      EnterLongStop(high(0) + 1 * Ticksize, "Long")

      SetStopLoss(Low(0) - 1 * Ticksize, true, ????????)

      My question is regarding the setstoploss part...

      Thanks in advance

      Comment


        #4
        You're welcome - you can split this up into two independent strategies.

        You can access the Low of the prior bar like this -

        Code:
        SetStopLoss("Long", CalculationMode.Price, Low[1] - 1 * TickSize, false)
        Last edited by NinjaTrader_Bertrand; 02-23-2010, 08:16 AM.

        Comment


          #5
          Where in the script should I put this code Bertrand, should I set it as the next condition set, or in the initialize() area...I ask because I am now getting an error on generating strategy that wasn't there before.

          Thanks

          1)Strategy\IBstratTrial.cs Expected class, delegate, enum, interface, or struct CS1518 - click for info 73 16

          2)Strategy\IBstratTrial.cs Type or namespace definition, or end-of-file expected CS1022 - click for info 81 1
          Last edited by chatchgo; 02-23-2010, 08:16 AM.

          Comment


            #6
            chatchgo, please put this in the OnBarUpdate() after your entry condition(s). For the errors you get, please keep in mind all NinjaScript files have to be error free to compile, you can double click on each error and the editor will show you exactly where the offending line was found.

            Comment


              #7
              Thanks Bertrand, the strategy is now compiling. But it appears that the stop loss is setting off at the close of the prior bar instead of the low of the prior bar using your program language that you gave me...

              It looks like I've found out what the problem was, thx!
              Last edited by chatchgo; 02-24-2010, 10:49 AM.

              Comment


                #8
                Great you got it resolved, you could also define the stopprice as variable and then just Print this out to debug the value being set then...

                Comment


                  #9
                  Actually, I just thought of this with your help...can I get the program to print the price of WHERE the stoploss SHOULD be (Low(0) - 1 * Ticksize...), then set the stoploss to that price??

                  Because the way I have it set, the stoploss moves up to every occurence of the called condition

                  Comment


                    #10
                    Sorry don't follow - correct as Low[1] changes with each bar in the trade the stoploss is adjusted as you call it on each on bar update...you could save the value to a variable as your entry condition triggers and then set it to this value while in the trade...this way it would not change as the trade progresses.

                    Comment


                      #11
                      OK, so how would I set it to a variable? If the first condition has my condition filled (Now I am long the market), how would I keep my stoploss = to the very first condition, and not have it continually update with every new occurence

                      Comment


                        #12
                        Use an additional bool variable. Once value is stored once, bool = false, as long as bool = false, do not keep resetting the variable storing the desired value.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          If you could, can you direct me to some bool material, im not too familiar with coding, as you can probably tell

                          thanks in advance

                          Comment


                            #14
                            In Variables region of your code:
                            Code:
                            private bool someVariable = true;
                            In OnBarUpdate():
                            Code:
                            if (someVariable == true && some other conditions you are using)
                            {
                                someVariable = false;
                                setValue = 100.5;
                            }
                            Then you decide whenever you want to be able to set your value again and when you decide it should be allowed, set someVariable = true.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Wow thanks Josh. I have no programming skills whatsoever, but using what you just wrote here I was able to use multiple bools to mimick the superDOM multiple profit target system in a way. Thanks!

                              Catchgo, if you still need help with this maybe I can help.


                              Originally posted by NinjaTrader_Josh View Post
                              In Variables region of your code:
                              Code:
                              private bool someVariable = true;
                              In OnBarUpdate():
                              Code:
                              if (someVariable == true && some other conditions you are using)
                              {
                                  someVariable = false;
                                  setValue = 100.5;
                              }
                              Then you decide whenever you want to be able to set your value again and when you decide it should be allowed, set someVariable = true.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              574 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X