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

Max Volume in N Bars Not Computing

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

    Max Volume in N Bars Not Computing

    I'm trying to calculate the highest volume in n bars but am not getting anything to compute.
    I'm using the VolumeUpDown indicator as a starting point.

    the following code does not draw a Dot nor does it print anything.


    if (Volume[0] > MAX(Volume, 5)[0])
    {
    DrawDot("HighVolume" + CurrentBar, true, 0, Volume[0] + 50, Color.Red);
    Print(" Time = " + DateTime.Now + " High Volume Dot = " + Volume[0]);
    }

    What am I missing?

    TIA,

    taddypole...

    #2
    Taddypole, try referencing one bar back for your MAX() indicator, otherwise the current bar is included in it, so the condition could never be true for it to plot.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      I've tried 1 bar back and 2 bars back but no luck.
      I've attached the picture and the code.
      I still get no dots nor prints of the MAX value.
      Attached Files

      Comment


        #4
        So you would see no prints at all triggering?

        Is this for the same on other chart types as well?

        I saw for some prints in your code trigger -

        Vol UpDn Four (a)- Time = 1/6/2012 11:32:00 AM BarPeriod = 1 Min Max Volume = 3545

        The other condition might simply be to hard to be fullfilled.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          No Prints, No Dots.

          The (a) print statement was for giving me the highest volume in the last 5.
          The (b) print statement is to identify if the just printed Volume bar is greater than the last 5.

          I've tried it in a min chart and a tick chart but not joy...

          Attached Files

          Comment


            #6
            Would you see dots with this changed code?

            Likely the condition was too hard in your prior version and thus never evaluated to trigger the dot printing.
            Attached Files
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thanks Bertrand that helped but I still have some problems. Not all the conditions are met, just some of them. I'm now trying to dig deeper.

              i've been here before but i'm trying to get down to the tick level to see what's going on but am having a problem with tickcount.

              In the attachment, i've recorded the Bars.TickCount and Bars.Period.Value parameters but they are always values 1 & 3. I've used these parameters on tick charts and they worked there but they are not working on LineBreak Charts.

              I'm trying to calculate the term: Count = Bars.Period.Value - Bars.TickCount;

              Can you help?

              Regards,

              taddypole...
              Attached Files

              Comment


                #8
                Originally posted by Taddypole View Post
                In the attachment, i've recorded the Bars.TickCount and Bars.Period.Value parameters but they are always values 1 & 3. I've used these parameters on tick charts and they worked there but they are not working on LineBreak Charts.

                I'm trying to calculate the term: Count = Bars.Period.Value - Bars.TickCount;
                Taddypole,

                I am responding on behalf of Bertrand.

                What code are you using here? What sort of chart are you using this on? Who is your data provider?

                I look forward to helping you resolve your issue.
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you AdamP,

                  In previous posts i included pictures and code but I think I'm having a problem with "FirstTickOfBar". I have run into this in the past and have tried to develop a "SecondTickOfBar".

                  Here's the code:

                  Count = Bars.Period.Value - Bars.TickCount;

                  Print(" High Volume Dot (b)- Time = " + DateTime.Now + " Bars Tick Count (a) = " + Bars.TickCount + " Bars Period Value = " + Bars.Period.Value);


                  if (Count == 0)
                  {
                  lastTick = true;
                  }

                  if (Count == Bars.Period.Value -1) // "FirstTickofBar" is sometimes a Bad tick - do not use calculations from this tick
                  {
                  beginBar = true;
                  }
                  if (Count == Bars.Period.Value - 2) // the secondtickofbar is the first good calculation tick of new bar (found by trial and error)
                  {
                  firstTick = true;
                  }

                  But when I used this as mentioned in the previous post, it doesn't work.

                  I'm using a LineBreak Chart and my data provider is CQG.

                  Thanks for helping...

                  taddypole...

                  Comment


                    #10
                    In the original code, if I use Volume[0], it plots correct for historical bars but not for real time bars.

                    if (FirstTickOfBar)
                    {
                    if (Volume[0] > MAX(Volume, 4)[1])
                    }

                    If I use Volume[1], (which for me seems correct when running tick for tick and using FirstTickOfBar):
                    it works neither for historical nor real time.

                    if (FirstTickOfBar)
                    {
                    if (Volume[1] > MAX(Volume, 4)[1])
                    }

                    In the attached picture, you can see the Volume[0] case. It works for historical bars, but when I go to real time market, the Dots don't plot and the Volume MAX's are always "1".

                    I don't understand...

                    Refer to Post #6 for the code.
                    Attached Files

                    Comment


                      #11
                      Dumb Question: What's a 55 tick 3LB Wicked?

                      This indicator you have works for me in market replay going forward with a normal 55 tick chart on CL 02-12.

                      It's Sunday, so I can't exactly test in live.

                      ( I did play with the colors and added some extra prints to see what was going on).




                      Originally posted by Taddypole View Post
                      In the original code, if I use Volume[0], it plots correct for historical bars but not for real time bars.



                      Refer to Post #6 for the code.
                      Attached Files

                      Comment


                        #12
                        Originally posted by sledge View Post
                        Dumb Question: What's a 55 tick 3LB Wicked?
                        .
                        ok found it, line break chart, 55 tick, i have linebreaks = 3

                        I can't find the "Wicked" option.

                        appears to work going forward in market replay.
                        Attached Files

                        Comment


                          #13
                          Does it even work?? I'm reading this thread, and there appears to be talk about what you are seeing with these Wicked LB bars.



                          Can you post a picture worth a thousand words? Thx. Also, add Ninja's LineBreak bartype to the chart as well, for comparison. You cant see my "issue" with a pic., need a video. Ninjas linebreak chart does the same. Could someon explain when does the 3lbw calculate the open? And why does it change many times in the same candlestick? I also had an issue today when I had a green candle and entry in 150tick 3lbw CL, but trade went to SL. Then I restarted the ninja trader, and then there where only …



                          Problem Caused by Transition Bar from Historical to Real-Time Data The problem has to do with the transition from historical bars to real-time bars. This is what I think that NinjaTrader does:

                          ---

                          Is anyone having problems with this LB on Replay?
                          All my bar types are replaying correctly except this one.
                          Real time is fine.
                          I am on NT7 version 6
                          ----

                          Comment


                            #14
                            I finally found the problem.


                            In the condition statement:
                            if (Volume[0] > MAX(Volume, 5)[0])

                            I need the current Volume[0] to be indexed to [1] since I'm using COBC = false and firing on FIrstTickOfBar. That gives me the previous bar's volume which is the one I'm interested in.

                            Next for the highest in a range of Volume bars I'm interested in, I need the index to start back 2 bars:

                            MAX(Volume,5)[2]

                            Making these changes now has the indicator working correctly.

                            This works in live market as well as replay for me.

                            regards,


                            taddypole...

                            Comment


                              #15
                              taddypole,

                              I am happy you have resolved your issue.

                              Please let us know if you require additional assistance.
                              Adam P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              44 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              10 responses
                              180 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X