![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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;
}
Only happens in real-time on RANGE Charts The bars should not be yellow in the attached picture.
Last edited by zoltran; 11-26-2007 at 02:56 PM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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]);
}
}
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
I thought of that .. pretty sure I changed to false
Will check tomorrow .. time for bed |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Please try adding this to the code
Code:
else if (Volume[0] > 0)
BarColor = Color.Empty;
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
You can try this indicator to color the phantom bars if you like.
|
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Jun 2006
Posts: 111
Thanks: 0
Thanked 1 time in 1 post
|
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? |
|
|
|
|
|
#15 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Will add your request to our list of possible future enhancements.
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |