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

Finding the lows of new bars

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

    Finding the lows of new bars

    Is there a way for NT to find the lows of each 1 min bar, then placing a limit order below those bars after a crossover?

    #2
    I guess Im looking for a live until cancelled help, taking a look at it now...

    Comment


      #3
      chatchgo,

      Sure. What is your question for using liveUntilCancelled?

      You can check for lower lows through the use of MIN(Low, 10)[0] for instance. That would give you the lowest low for a 10 bar period.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Hey Josh,

        Im trying to get NT to enter a limit order 2 ticks below the low of every bar after a crossover? Im not too sure how to program this, as Im new to writing programs

        Thanks in advance

        Comment


          #5
          Hi chatchgo, thank you for your inquiry.

          What you're trying to do is entirely possible within NinjaScript. You can access the low of each bar by referencing Low[x], where 'x' is the number of bars back. So if you want the low of the current bar, just take a look at Low[0].

          The next step would be to check for crossovers, which you can do with either CrossAbove or CrossBelow.

          Lastly, to place a limit order below the low of a bar, you could so something like this:
          EnterLongLimit(Low[0] - 2*TickSize, "buy below the low"). That would place a buy limit order at two ticks below the low of the current bar.

          Hopefully this gets you going in the right direction, but let us know if you're still having problems.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Thx Austin, Ive gotten that far, now I need the order to stay live until filled...b/c everytime that order isnt filled it cancels itself and price runs away. I need the order to stay live, and keep trailing 2 ticks below the low of the future bar. I tried Low (-1), but that doesn't seem to work.

            Thanks in advance
            Last edited by chatchgo; 07-02-2009, 08:04 AM.

            Comment


              #7
              Chatchgo, have you taken a look at the liveUntilCancelled property of EnterLongLimit?
              AustinNinjaTrader Customer Service

              Comment


                #8
                Im not sure what to write in for the bool entry, can u show me an example possibly of a liveuntilcancelled entry?

                Comment


                  #9
                  Sure thing, EnterLongLimit(0, true, DefaultQuantity, LimitPrice, "buy signal"), where LimitPrice is your limit price, and "buy signal" is the signal name.
                  The "true" is all you need to set liveUntilCancelled.
                  AustinNinjaTrader Customer Service

                  Comment


                    #10
                    OK thx austin...that got the ball rolling. Now that the order stays live, how do I look for the next bar's low -2 ticks

                    Comment


                      #11
                      Chatchgo, I can outline for you what you can do to accomplish this, but I can't write all the code.

                      Ok, so when the order is first placed, all is fine and good.
                      The next bar (now the current bar) comes and the order is still active, yet the low of the current bar has changed.

                      This is where you have a few options. You can add some new logic to the OnBarUpdate section checking to see whether or not the order has been filled. If it hasn't, you can cancel it, and then resubmit a new order. Another option is to just modify the previous order.

                      I suggest taking a look at IOrders. It allows much greater control over orders, but is a complex subject to get a grasp of.
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        EnterShortStop(0, true, 1, Low[0] + -2 * TickSize, "Short");
                        DrawVerticalLine(
                        "My vertical line" + CurrentBar, 0, Color.Red);


                        if (CurrentBar > 0 + 5)
                        CancelOrder (
                        "Short");

                        Im here in the process now Austin. But I can't figure out what name to call when I cancel order?? I tried to set a name to the the original entry order

                        (myEntryOrder = EnterLongLimit(0, true, 1, Low[0], "Long Entry");

                        But i get error on generating strategy...

                        Comment


                          #13
                          Chatchgo, I'll investigate this further and let you know.
                          AustinNinjaTrader Customer Service

                          Comment


                            #14
                            When calling CancelOrder, you need to specify the IOrder object, not a string value.

                            In your case, you could change your EnterShortStop to an IOrder object, and then cancel that.

                            Ex:
                            Code:
                            myShortOrder = [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]EnterShortStop([/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=#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][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], Low[[/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]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] * TickSize, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Short"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
                            CancelOrder(myShortOrder)
                            [/SIZE][/FONT][/SIZE][/FONT]

                            AustinNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Barry Milan, Today, 10:35 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by WeyldFalcon, 12-10-2020, 06:48 PM
                            14 responses
                            1,428 views
                            0 likes
                            Last Post Handclap0241  
                            Started by DJ888, Yesterday, 06:09 PM
                            2 responses
                            9 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by jeronymite, 04-12-2024, 04:26 PM
                            3 responses
                            40 views
                            0 likes
                            Last Post jeronymite  
                            Started by bill2023, Today, 08:51 AM
                            2 responses
                            16 views
                            0 likes
                            Last Post bill2023  
                            Working...
                            X