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

Indicator Logic

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

    Indicator Logic

    Hello,

    This question is about an indicator Logic. I am new to programming. My question is, when you create an indicator and the OnBarUpdate() is executed bar after bar, does the code goes back again to the first candle to recalculate everything from the beginning on every new bar??

    Thanks

    #2
    Originally posted by MillenniumTrader View Post
    Hello,

    This question is about an indicator Logic. I am new to programming. My question is, when you create an indicator and the OnBarUpdate() is executed bar after bar, does the code goes back again to the first candle to recalculate everything from the beginning on every new bar??

    Thanks
    Not unless you ask it to. It will simply run through the code block sequentially once for each barUpdate.

    Comment


      #3
      Thanks for your response, Is there any special setting for this behavior or it has to be custom coded

      Comment


        #4
        Originally posted by MillenniumTrader View Post
        Thanks for your response, Is there any special setting for this behavior or it has to be custom coded
        What special behavior?

        Comment


          #5
          Millennium,

          Can you tell us why you need this, perhaps by giving an example? The program does keep track of the data on prior bars in order to make calculations on the current bar.

          futurestrack

          Comment


            #6
            Hello MillenniumTrader,

            Thank you for your post.

            Koganam is correct, OnBarUpdate() would process bar by bar from oldest to newest. If you want to look back over a period of time you would generally use a period to do so. A period such as the one used for the SMA sets the number of bars used for the calculation.

            And like futurestrack mentioned, if you can provide an example of what you wish to do we can provide more details.

            Comment


              #7
              Thanks for the great support, see the attached file for more explanation. The indicator is already painting the rectangles in my chart but they dont stop when price trespass thru them in the future. I don't know if I should use "DrawLine()" , "DrawRegion()" or "DrawExtendLine()" for this specific application. The problem is that the indicator will have to go back and check if previous rectangles have been COMPLETELY cut by price. See attached picture.

              Regards
              Attached Files

              Comment


                #8
                I would think you could on each bar:

                For each of the existing rectangles
                See if the price has been both below and above the rectangle since its left edge bar.
                If so then set the rectangle right edge coordinates as the current bar position.

                I think you can define some global variable arrays to keep track of all this.

                Clearly it's not an easy problem, but it can be done. (Ask yourself if it's really worth it)

                Hope this helps.

                futurestrack

                Comment


                  #9
                  Originally posted by MillenniumTrader View Post
                  Thanks for the great support, see the attached file for more explanation. The indicator is already painting the rectangles in my chart but they dont stop when price trespass thru them in the future. I don't know if I should use "DrawLine()" , "DrawRegion()" or "DrawExtendLine()" for this specific application. The problem is that the indicator will have to go back and check if previous rectangles have been COMPLETELY cut by price. See attached picture.

                  Regards
                  That is fairly obviously the "Hidden Gaps" setup. Well, there is good news and there is not so good news. It can obviously be coded because we have already coded it. That is the good news. The not so good news is that we are a commercial outfit who are selling that indicator, so I cannot give you the source code.

                  Is this not what you are talking about?
                  Attached Files

                  Comment


                    #10
                    Hello Koganam, yes it is exactly what I am trying to accomplish here. I didn't know that you have it coded already. By the way, I checked your website but I didn't see it there. Can you provide the link? I cant tell you that I will buy it because I have coded the main indicator logic with the help of many here (and without coding experience) so I will try to completed if I can. As you can see in the picture, the only missing part is stopping the rectangles. Anyways, I am really grateful for your help and others people too. the advice is not only good for this indicator but for others too.I will try to work with arrays and with the IdrawObject to see what I get.

                    Regards,
                    Attached Files

                    Comment


                      #11
                      Originally posted by MillenniumTrader View Post
                      Hello Koganam, yes it is exactly what I am trying to accomplish here. I didn't know that you have it coded already. By the way, I checked your website but I didn't see it there. Can you provide the link? I cant tell you that I will buy it because I have coded the main indicator logic with the help of many here (and without coding experience) so I will try to completed if I can. As you can see in the picture, the only missing part is stopping the rectangles. Anyways, I am really grateful for your help and others people too. the advice is not only good for this indicator but for others too.I will try to work with arrays and with the IdrawObject to see what I get.

                      Regards,
                      Send me a note from the website, or a PM. I will email you a Trial.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by gentlebenthebear, Today, 01:30 AM
                      2 responses
                      13 views
                      0 likes
                      Last Post gentlebenthebear  
                      Started by Kaledus, Today, 01:29 PM
                      2 responses
                      8 views
                      0 likes
                      Last Post Kaledus
                      by Kaledus
                       
                      Started by frankthearm, Yesterday, 09:08 AM
                      13 responses
                      45 views
                      0 likes
                      Last Post frankthearm  
                      Started by PaulMohn, Today, 12:36 PM
                      2 responses
                      16 views
                      0 likes
                      Last Post PaulMohn  
                      Started by Conceptzx, 10-11-2022, 06:38 AM
                      2 responses
                      56 views
                      0 likes
                      Last Post PhillT
                      by PhillT
                       
                      Working...
                      X