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

Counting Number of Bars from an event

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

    Counting Number of Bars from an event

    Hi, I am working in my own ZigZag indicator and I need to count the number of bars that appear after an event. To uderstand what I mean, please take a look to the following PDF and video.

    The PDF is an explanation of what I need to measure.


    The video is to see how the indicator works.


    Thanks in advance!

    #2
    Hello Sangui,

    Thank you for the post.

    You will need to save the value of CurrentBar when the line is drawn on the bar.

    Any bar after the line is drawn will have a greater CurrentBar value, so keep a count of any bar after the flagged one (the one with a line touching it).

    More on CurrentBar here:


    If questions come up or if we may be of any further assistance, please let us know.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Dear Chris,

      Yes I am already using this, but the counters don't work well and I don't know why.

      You can see the rare behaviour in the following PDF:


      The part of the code that takes care of the counting of the bars down:

      with if(dir==1) sentence (a new PIVOTUP is being created):


      if(IsFalling(lineaUP) && cayendo) // the bars stars to fall from the previous PIVOTUP (not confirmed yet)
      {
      BarrasDOWN=BarraActual; //BarraActual are the bars in progress
      cayendo=false;

      }

      if(IsRising(lineaUP)) {cayendo=true; BarrasDOWN=BarraActual+1;} //BARRAS DOWN are the falling bars

      if(!cayendo && (BarraActual-BarrasDOWN+1)>=2 && 100*Bars.PercentComplete>50 ) // THIS IS THE CONDITION FOR CHANGING FROM dir=1 to dir=-1 (that is, a new PIVOTDOWN would be in progress... (1: falling, 2: 2 falling bars as minimu,, 3: the bar is 50% completed)
      {
      cayendo=true; BarrasDOWN=BarraActual+1;
      IndiceUP++;
      PIVOTDOWN=Low[0]; lineaDOWN[0]=PIVOTDOWN; bPIVOTDOWN2=BarraActual; PIVOTDOWN2 = lineaDOWN[0];
      dir=-1;
      }

      Any suggestion or example with similar idea that I can check?

      Comment


        #4
        Hello Sangui,

        Thanks for the reply.

        Please either post your code file here or email it to platformsupport[at]ninjatrader[dot com] and reference the link to this forum post in the body of the email.

        Indicator/Strategy files will be found in Documents/NinjaTrader 8/bin/Custom

        I look forward to your reply.
        Last edited by NinjaTrader_ChrisL; 08-18-2017, 12:12 PM.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hello Sangui,

          Thanks for the reply.

          Please either post your code file here or email it to platformsupport[at]ninjatrader[dot com] and reference the link to this forum post in the body of the email.

          Indicator/Strategy files will be found in Documents/NinjaTrader 8/bin/Custom

          I look forward to your reply.

          Hello, I wanted to ensure you saw my previous post.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Yes, I am sorry about the delay in my reply. I am still testing the solution of previous mail. I will comeback just un case I dont succeed 😉

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cls71, Today, 04:45 AM
            0 responses
            1 view
            0 likes
            Last Post cls71
            by cls71
             
            Started by mjairg, 07-20-2023, 11:57 PM
            3 responses
            213 views
            1 like
            Last Post PaulMohn  
            Started by TheWhiteDragon, 01-21-2019, 12:44 PM
            4 responses
            544 views
            0 likes
            Last Post PaulMohn  
            Started by GLFX005, Today, 03:23 AM
            0 responses
            3 views
            0 likes
            Last Post GLFX005
            by GLFX005
             
            Started by XXtrader, Yesterday, 11:30 PM
            2 responses
            12 views
            0 likes
            Last Post XXtrader  
            Working...
            X