Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

KeyReversal and MACD value

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

    KeyReversal and MACD value

    The keyreversal will evaluate the hi/lo of nbarsago. It will == 1 if a reversal is present.
    Is there a way to capyure how many bars ago that the prior hi/lo occurred?
    When ==1 I want to determine the stoch or macd value at the time of nbarsago to compare to the current value.
    Thank you,
    Duke

    #2
    Hello dukeb,

    You can use the MAX() and MIN() functions to be able to calculate the highest and lowest value over a specified period and return the number of bars ago.

    MAX: http://www.ninjatrader.com/support/h...aximum_max.htm

    MIN: http://www.ninjatrader.com/support/h...inimum_min.htm

    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thank you... really appreciated..
      Duke

      Comment


        #4
        Code Syntax

        I have attached some code. Please see the screen shot for the eror codes.
        Thank you,
        Duke
        Attached Files

        Comment


          #5
          Hello dukeb,

          NinjaScript is case sensitive so MAX() function needs to be all capitalized as well as the MIN() function.


          Here is a link to our support forums that goes over how to debug your code which comes in handy if you run into a compiling errors when writing custom code as well.
          http://www.ninjatrader.com/support/f...ead.php?t=3418

          Let us know if we can be of further assistance.
          JCNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_JC View Post
            Hello dukeb,

            NinjaScript is case sensitive so MAX() function needs to be all capitalized as well as the MIN() function.


            Here is a link to our support forums that goes over how to debug your code which comes in handy if you run into a compiling errors when writing custom code as well.


            Let us know if we can be of further assistance.
            Thank you for your response. The attachment shows I have now capped MAX(). When I click on the first error it hightlights 'BarsArray' on the second line.
            When I click on the second error, it highlights '20' in the first line.
            It appears there is some kind of syntax issue that I am not seeing.
            Duke
            Attached Files

            Comment


              #7
              Hello dukeb,

              Could you remove the brackets after the 20, as the brackets will only be used for an array and 20 is only an integer. See the forum post below for more information using brackets [].

              http://www.ninjatrader.com/support/f...ad.php?t=19346

              Let us know if we can be of further assistance.
              JCNinjaTrader Customer Service

              Comment


                #8
                Originally posted by dukeb View Post
                Thank you for your response. The attachment shows I have now capped MAX(). When I click on the first error it hightlights 'BarsArray' on the second line.
                When I click on the second error, it highlights '20' in the first line.
                It appears there is some kind of syntax issue that I am not seeing.
                Duke
                "20" is an integer. 20[0] does not make sense to the compiler, (nor to a human ) You cannot index an integer.

                Comment


                  #9
                  Thank you .... in retrospect this seems rather obvious.

                  Comment


                    #10
                    I understand...
                    Thank you..

                    Comment

                    Latest Posts

                    Collapse

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