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

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 junkone, Today, 11:37 AM
                    2 responses
                    12 views
                    0 likes
                    Last Post junkone
                    by junkone
                     
                    Started by frankthearm, Yesterday, 09:08 AM
                    12 responses
                    43 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by quantismo, 04-17-2024, 05:13 PM
                    5 responses
                    35 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by proptrade13, Today, 11:06 AM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by love2code2trade, 04-17-2024, 01:45 PM
                    4 responses
                    35 views
                    0 likes
                    Last Post love2code2trade  
                    Working...
                    X