Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to generate a signal when price crosses high of the previous bar

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

    How to generate a signal when price crosses high of the previous bar

    Please advise how to generate a signal when price crosses high of the previous bar. I cannot find the last price in the wizard. Tried to backtest with (Bid >= High[1]) - it don`t work okay. Please advise.


    #2
    vitaleg, you can access the last price by using the Close variable. If you wanted to see if the last price (most recent close) is above the previous bar's high (and then go long, for example), you could compare those values as shown in the screenshot.
    Attached Files
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thank you. But I`m using 5min interval. I need to know if price crosses the high during this interval, not when bar will close.

      Comment


        #4
        vitaleg, in that case, you will have to do something like this:
        Code:
        if (Close[0] > High[1] && Open[0] < Close[1])
           // show alert or something
        The above code basically says: if the most recent close is above the previous bar's high, and the current bar's open is below the previous bar's high, then do something.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Austin, so as far as I understand I cannot get the last price? Just last price, not bar properties.

          Comment


            #6
            vitaleg, the Close property contains the instrument's last traded price. In other words, Close[0] = last price. If you set CalculateOnBarClose = false, then it is updated every tick. If CalculateOnBarClose = true, then it is updated once per bar.
            AustinNinjaTrader Customer Service

            Comment


              #7
              Oh, got it. Thanks a lot.

              Comment


                #8
                you can access the last price by using the Close variable
                One more question. I`ve tried to program strategy to trig when last price is higher than High[1] + 0.02$ But it doesn`t work correctly on backtesting - sometimes it enter correctly, sometimes no. I have the following code:

                Close[0] > (High[1] + 0.02)

                Comment


                  #9
                  Which instrument are you working on as this happens? I suggest to add some drawings to visually see when an entry should be triggered according to your programmed rules -



                  Also please keep in mind the order will be placed on the next bar, since this the earliest possible trade location in backtesting.

                  Comment


                    #10
                    Hi, I have a similar issue in NT6.5....
                    I am trying something very very simple as I am new to the programming here but clearly am missing something.
                    I basically just added to a new Wizard generated indicator, after the OnBarUpdate()...

                    if (Close[0]<Close[2])
                    DrawSquare("tag1"+CurrentBar, true, 0, Low[0] - TickSize, Color.Blue);

                    But nothing shows...?
                    thanks.
                    Last edited by Adina; 08-19-2010, 05:50 AM.

                    Comment


                      #11
                      Adina, you likely miss this check at your OnBarUpdate() start - http://www.ninjatrader.com/support/f...ead.php?t=3170

                      Comment


                        #12
                        thankyou - I knew it was something completely simple......

                        Comment

                        Latest Posts

                        Collapse

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