NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 11-26-2007, 12:44 PM   #1
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default 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 Images
File Type: jpg zerovol.JPG (53.9 KB, 31 views)
Last edited by zoltran; 11-26-2007 at 02:56 PM.
zoltran is offline  
Reply With Quote
Old 11-26-2007, 11:58 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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 Images
File Type: jpg ER2 12-07 11_26_2007 (5 Range).jpg (33.4 KB, 15 views)
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-27-2007, 12:04 AM   #3
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
zoltran is offline  
Reply With Quote
Old 11-27-2007, 12:20 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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.
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-27-2007, 12:23 AM   #5
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

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
zoltran is offline  
Reply With Quote
Old 11-27-2007, 12:39 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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?
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-27-2007, 12:43 AM   #7
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

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

Will check tomorrow .. time for bed
zoltran is offline  
Reply With Quote
Old 11-28-2007, 05:22 PM   #8
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

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 Images
File Type: jpg zerovol.JPG (72.8 KB, 17 views)
Attached Files
File Type: cs ZeroVolBar.cs (4.7 KB, 1 views)
zoltran is offline  
Reply With Quote
Old 11-29-2007, 01:03 AM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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.
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-29-2007, 07:07 AM   #10
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

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 at 07:10 AM.
zoltran is offline  
Reply With Quote
Old 12-04-2007, 11:02 AM   #11
Wizard
Junior Member
 
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
Default 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?
Wizard is offline  
Reply With Quote
Old 12-04-2007, 11:16 AM   #12
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

You can try this indicator to color the phantom bars if you like.
Attached Files
File Type: cs ZeroVolBar.cs (4.7 KB, 6 views)
zoltran is offline  
Reply With Quote
Old 12-04-2007, 12:30 PM   #13
Wizard
Junior Member
 
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
Wizard is offline  
Reply With Quote
Old 12-04-2007, 12:47 PM   #14
MJT
Senior Member
 
Join Date: Jun 2006
Posts: 111
Thanks: 0
Thanked 1 time in 1 post
Default

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?
MJT is offline  
Reply With Quote
Old 12-04-2007, 12:59 PM   #15
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Will add your request to our list of possible future enhancements.
NinjaTrader_Ray is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
range bar charts ceesvh Historical NinjaTrader 6.5 Beta Threads 2 11-21-2007 05:54 AM
Preserving Range Settings for Charts JangoFolly Charting 4 11-15-2007 08:19 AM
back testing volume data... bigdaddo Charting 7 11-13-2007 11:14 PM
Some Range Bars have zero volume scjohn Historical NinjaTrader 6.5 Beta Threads 5 11-09-2007 09:31 AM
Problems with testing for DonchianChannel breakouts plipa Strategy Development 5 04-20-2007 07:39 AM


All times are GMT -6. The time now is 12:01 PM.