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

Problems testing for zero volume on range charts

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

    Problems testing for zero volume on range charts

    The following code does not appear to work in real-time when applied to a range chart. It's purpose is to flag any range bar with zero volume. (This can happen when a range chart gaps and NT 'fills' in the gap with phantom bars)

    It appears to think that volume is 0 for any new bar.
    Works fine on historical data, or if you refresh the chart in some manner.

    Code:
        protected override void OnBarUpdate()
            {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
            
    			if (Volume[0] < 1) BarColor = Color.Yellow;
    		
    		}
    The code above checks for vol < 1. Have also tried vol==0 with the same result.

    Only happens in real-time on RANGE Charts

    The bars should not be yellow in the attached picture.
    Attached Files
    Last edited by zoltran; 11-26-2007, 03:56 PM.

    #2
    Hmm I can't seem to reproduce on my end. What I did was setup simulator starting point to be much lower than the last true data price I had for the ER2. I then fired up the Simulated Data Feed and my indicator created this. It seems to be working as expected on my end. On the gap down, the phantom bars are all yellow, but the "real" bars are normal colored.

    Please try adding a Print function into your implementation to see what is happening on your end. I put a Print of Volume[0] in mine and it only prints when Volume=0.

    Code:
    protected override void OnBarUpdate()
    {
        if (Volume[0] < 1)
       {
           BarColor = Color.Yellow;
           Print(Time[0] + " " + Volume[0]);
       }
    }
    Attached Files
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I will do that tomorrow josh.

      Just to clarify .. I did not have a problem with valid '0' vol bars from a gap.

      The problem was with real-time data that had regular volume (>0)

      These bars were painting yellow today. First time I tried this indicator in real time... had always been historical before.

      We'll see what happens tomorrow.

      Comment


        #4
        Okay. I'm not having problems on my end for normal volumed bars either. If you notice in my screenshot the upturn at the bottom. Those were painted normally because they had volume. If your code is a bit more complex then what you posted you might want to try debugging it a bit.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          You saw the whole thing Josh.

          It was a huge one-line indicator. That's it, nothing else.

          if (Volume[0] < 1) BarColor = yellow ...


          I'll try again tomorrow on the same symbol

          Comment


            #6
            I have an idea. Are you using CalculateOnBarClose = false? I suspect at the very very beginning of the bar it might see 0 volume and then decide to paint the bar yellow and this painting is never retracted when volume goes into the bar?
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I thought of that .. pretty sure I changed to false

              Will check tomorrow .. time for bed

              Comment


                #8
                Hi Josh

                Just retested on Beta 4 ... still happens
                - CalcBarClose false
                - Range Chart

                It's easy to see it happen using a 1 range bar on 6E/Euro after hours. .. can watch it in slow-mo

                Attaching the little indicator and a screen shot.

                My 'hunch' is .. ...

                Watching it in slow motion on the after hours Euro, Volume IS 0 when the bar opens.. Don't know if that is valid or not, as what makes the bar actually print a new 'range' bar. ??

                I thought it was a tik/trade outside the current range setting. So there should be volume there.

                So.. the bar seems to start at 0 vol, the color changes because of this, .. but it never changes back to normal.
                Attached Files

                Comment


                  #9
                  Please try adding this to the code
                  Code:
                  else if (Volume[0] > 0)
                       BarColor = Color.Empty;
                  That should reset the bar color after the initial 0.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi and thanks Josh.
                    I was thinking that BarColor was reset for every new tick and that i wouldn't need to do BarColor=Color.Empty

                    In hindsight, it's obvious that would not be the case.

                    Thanks
                    Last edited by zoltran; 11-29-2007, 08:10 AM.

                    Comment


                      #11
                      Making range bars more realistic / Disabling phantom range bars

                      On a very related note: Range bars are nice, but having phantom bars makes the displayed data unrealistic when there are gap-ups/downs, and especially so when it involves one isolated trade.

                      Thus I really dislike the phantom bars. Would it be asking too much to have an option to disable the generating of phantom range bars?

                      Similarily, can there be an option to not fill-out range bars where the underlying price data does not actually span that range bar. For example: if trading is occuring say between $10 and $12 and all of a sudden there is one isolated trade at $15 and then trading resumes between $10 and $12, it would be nice if we displayed only a bar with a range of $15.00 to $15.00 instead of a bar with a range of say $14.90 to $15.00 (because the range was set to 10).

                      Am I the only one who wants to see range bars be more realistic?

                      Comment


                        #12
                        You can try this indicator to color the phantom bars if you like.
                        Attached Files

                        Comment


                          #13
                          Thanks. Yes, I've been testing the volume and trying to omit zero-volume bars from being considered in my indicator calculations (not always trivial to do), as well as coloring my bars correspondingly (actually using an alpha value to make them transparent, thus dimmer), but that's really a kludge and a real solution (change to NinjaTrader itself to have the option to not generate the bars in the first place) would be ideal.

                          Comment


                            #14
                            Great little indicator zoltran.

                            Regarding an option to disable plotting 'phantom' (zero volume) range bars, I think this would be very good for intra day charts at the open when there is a gap from prior day close. I am not so concerned about this during any one days session, but would accept that as well for simplicity.
                            Would it be possible to have a kind of context sensitve Chart Properties item that only showed up on range bar charts so this could be turned on or off for a gap at start of a day session?

                            Comment


                              #15
                              Will add your request to our list of possible future enhancements.
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cre8able, Today, 03:20 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post cre8able  
                              Started by Fran888, 02-16-2024, 10:48 AM
                              3 responses
                              45 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Started by martin70, 03-24-2023, 04:58 AM
                              15 responses
                              114 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by The_Sec, Today, 02:29 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              2 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X