PDA

View Full Version : Enhanced On Balance Volume Indicator


jimbo002
12-07-2008, 08:52 PM
Hi
Could someone create this enhanced OBV indicator? Here's the link that describes it: http://scientifictrader.com/volume.htm

It looks to be straightforward and simple, but since i dont know jack about programming, i'll leave it up to the experts. But I think this would be useful to us Ninjatraders.

I sure would appreciate it, thanks

jimbo :)

NinjaTrader_Bertrand
12-08-2008, 05:54 AM
Hi jimbo002,

Thanks for posting the link.

If you want this programmed, you can also contact our NinjaScript consultants listed here - http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm

T2020
12-08-2008, 01:54 PM
Hi
Could someone create this enhanced OBV indicator? Here's the link that describes it: http://scientifictrader.com/volume.htm

It looks to be straightforward and simple, but since i dont know jack about programming, i'll leave it up to the experts. But I think this would be useful to us Ninjatraders.

I sure would appreciate it, thanks

jimbo :)
Looks like it would be very useful and I'm in the same boat as far as programing . I'll just second it that I'd like to have it available in Ninja
as well ..... Thanks for posting it .

T2020
12-13-2008, 11:50 AM
Hi jimbo002,

Thanks for posting the link.

If you want this programmed, you can also contact our NinjaScript consultants listed here - http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm
Trouble is ,someone will probably come along and post it for free . Then the
one who paid for it would feel pretty silly . I'd like to see how it performs on
intraday time frames as opposed to the daily examples given in the link , but
not enough to pay hundreds of dollars to do so . I'd write it and post it myself
,but it's the same old problem - not a programmer .Some softwares have some
easy formula language to work with . Oh well .

NinjaTrader_Bertrand
12-13-2008, 12:22 PM
Hi T2020, I can see your point...should you want to travel down the NinjaScript route yourself at some point, here are some tutorials to get you started the right way - http://www.ninjatrader-support.com/HelpGuideV6/Overview18.html

T2020
12-13-2008, 12:48 PM
Thanks Bertrand .
Perhaps I can go over a section at a time ,when I have some time . I'll
bookmark the link .

RJay
12-13-2008, 01:03 PM
This formula looks simple enough. I do have one question..

Formula for improved On Balance Volume

Cumulative total of (volume * ((high-open) / (high-low))) - Cumulative total of (volume * ((open-low) / (high-low)))

What does the term "Cumulative total" mean in the description????

RJay

T2020
12-13-2008, 07:21 PM
This formula looks simple enough. I do have one question..

Formula for improved On Balance Volume

Cumulative total of (volume * ((high-open) / (high-low))) - Cumulative total of (volume * ((open-low) / (high-low)))

What does the term "Cumulative total" mean in the description????

RJay
Far as I know it's just a running sum of volume ,starting with the 1st bar
of however many days / bars you have loaded in the chart .

dwalls
12-13-2008, 07:51 PM
Agree, this looks interesting.
Hopefully someone will take this on.

Thanks in advance.

T2020
12-14-2008, 05:57 PM
Hi T2020, I can see your point...should you want to travel down the NinjaScript route yourself at some point, here are some tutorials to get you started the right way - http://www.ninjatrader-support.com/HelpGuideV6/Overview18.html
Well , I opened up the Ninja Wizard and got through the 1st tutorial on price
variables , so I guess that generated a starting place for the custom OBV,but can't say anything makes sense after that .

Elliott Wave
12-15-2008, 01:51 AM
I tried making this when it was first requested and after trying for a while with no success I gave up.

I'll post my non-working version as perhaps it may be easier to correct my error(s) than start from scratch.

Its certainly frustrating though, when the indicator is only two lines... :rolleyes:

RJay
12-15-2008, 12:43 PM
More Info:

Special notation to totals for prior days.

https://www.tradestation.com/Discussions/DATA/20051021090023SMAA_OBV_ENHANCED.doc

T2020
12-15-2008, 08:04 PM
I tried making this when it was first requested and after trying for a while with no success I gave up.

I'll post my non-working version as perhaps it may be easier to correct my error(s) than start from scratch.

Its certainly frustrating though, when the indicator is only two lines... :rolleyes:
Well , I imported it . Needless to say , I'm clueless . I'm sure Bertrand or Ben
could edit it to operation status in 5 minutes . chuckle .

Elliott Wave
12-15-2008, 10:04 PM
... I'm sure Bertrand or Ben
could edit it to operation status in 5 minutes . chuckle .

I'm sure too. But just to be clear, the version I uploaded doesn't work, and since I tried a few different things, it could be much father from the actual solution than from where I started...

roonius
12-15-2008, 10:32 PM
I'm sure too. But just to be clear, the version I uploaded doesn't work, and since I tried a few different things, it could be much father from the actual solution than from where I started...

Actually, your version is good, just missing one little (or may be big) thing - whenever you divide something , ALWAYS check your divisor !=0.
I corrected your mistake. :)

I attached the same chart (from the informational link) so you can see that calculations are performed correctly

Elliott Wave
12-16-2008, 04:46 AM
Actually, your version is good, just missing one little (or may be big) thing - whenever you divide something , ALWAYS check your divisor !=0.
I corrected your mistake. :)


Thanks a lot. I knew it was probably something small I was overlooking. I've never considered the divide by zero error, but I'll have to make sure I do from now on. :)

T2020
12-16-2008, 06:28 AM
Thank you both ! for taking the time to work on this .
Much appreciated . :)

T2020
12-16-2008, 06:54 AM
The indicator updates on bar completion . I changed one statement like this :
CalculateOnBarClose = false; : ,but there must be something else the needs to changed ,maybe this : if (CalculateOnBarClose) : ??? Nope , lost
again .

Elliott Wave
12-16-2008, 09:01 AM
The indicator updates on bar completion . I changed one statement like this :
CalculateOnBarClose = false; : ,but there must be something else the needs to changed ,maybe this : if (CalculateOnBarClose) : ??? Nope , lost
again .

What are you trying to do?
Just set calculate on bar close to false in the indicators windows if you want it to update every tick.

T2020
12-16-2008, 09:43 AM
What are you trying to do?
Just set calculate on bar close to false in the indicators windows if you want it to update every tick.
I did ,but it didn't change anything . That's why I thought maybe something
needed to be changed in the code .... ?Does it update every tick for you when you set it that way ?

roonius
12-16-2008, 10:06 AM
Here you go

T2020
12-16-2008, 12:52 PM
Here you go
Thanks again roonius . I notice that there is an extreme spike in the indicator
right at the beginning of a new bar occasionally ,but resumes normal working
almost immediately . Just something I'm leaving feed back on .
I wish i knew how to do this . I'd be adding moving averages to it , trying
certain period summations of the same formula . I could do all that on my
previous software , unfortunately it didn't have anything remotely as good as
the Ninja chart trader ,which I've come to rely on . Oh well . Thanks again .

RJay
12-16-2008, 01:33 PM
Roonius,

I clipped this code from your indicator.

if (CurrentBar == 0)
{
if((High[0]-Low[0])!=0)
{
volUp.Set(Volume[0]*((High[0]-Open[0])/(High[0]-Low[0])));
volDn.Set(Volume[0]*((Open[0]-Low[0])/(High[0]-Low[0])));
} else
{
volUp.Set(0);
volDn.Set(0);
}
} else

if((High[0]-Low[0])!=0)
{

volUp.Set(volUp[1] + Volume[0]*((High[0]-Open[0])/(High[0]-Low[0])));
volDn.Set(volDn[1] + Volume[0]*((Open[0]-Low[0]) /(High[0]-Low[0])));
}

OBVplot.Set(volUp[0] - volDn[0]);



You have this exception in there twice:

if((High[0]-Low[0])!=0)

i don't see any exceptions if ((Open[0]-Low[0])were to equal zero.

It looks like it could pop with an infinite number.


What are your thoughts,


RJay

roonius
12-16-2008, 01:37 PM
Roonius,

I clipped this code from your indicator.

if (CurrentBar == 0)
{
if((High[0]-Low[0])!=0)
{
volUp.Set(Volume[0]*((High[0]-Open[0])/(High[0]-Low[0])));
volDn.Set(Volume[0]*((Open[0]-Low[0])/(High[0]-Low[0])));
} else
{
volUp.Set(0);
volDn.Set(0);
}
} else

if((High[0]-Low[0])!=0)
{

volUp.Set(volUp[1] + Volume[0]*((High[0]-Open[0])/(High[0]-Low[0])));
volDn.Set(volDn[1] + Volume[0]*((Open[0]-Low[0]) /(High[0]-Low[0])));
}

OBVplot.Set(volUp[0] - volDn[0]);

You mave this in there twice:

if((High[0]-Low[0])!=0)

i don't see any exceptions if ((Open[0]-Low[0])==0)

It looks like it could pop with an infinite number.


What are your thoughts,


RJay

(Open[0]-Low[0]) is not a divisor

The only divisor we have is High[0] - Low[0]

RJay
12-16-2008, 01:47 PM
Variable * 0 / Variable.

Punch it in a calculator and see what happens. ;)

roonius
12-16-2008, 01:50 PM
Variable * 0 / Variable.

Punch it in a calculator and see what happens. ;)


As long as Variable !=0 it's ok

RJay
12-16-2008, 01:56 PM
You covered (High - Low) but not (Open - Low)

roonius
12-16-2008, 02:01 PM
I might be repeating myself, but Open - Low is not a divisor; So is not High - Open;
The only divisor is High - Low :)

RJay
12-16-2008, 02:10 PM
Maybe your right and I just don't get it.

variable * 0 = What?

0 / Variable = What?

I thought this would make any equation explode. :confused::confused::confused:

roonius
12-16-2008, 02:12 PM
Maybe your right and I just don't get it.

variable * 0 = What?
0 / Variable = What?
I thought this would make any equation explode. :confused::confused::confused:

variable * 0 = What? --- 0

0 / Variable = What? --- 0 as long as Variable != 0

You can do 0/Variable but can not Variable/0

T2020
12-16-2008, 02:25 PM
It'd be nice if what ever was doing it could be resolved , but doesn't appear to be very obvious .... ???

RJay
12-16-2008, 02:51 PM
variable * 0 = What? --- 0

0 / Variable = What? --- 0 as long as Variable != 0

You can do 0/Variable but can not Variable/0


Your Right, I apologise. Don't ever get old.

I should have checked before saying anything.

I guess I'm the "zero".

RJay :o:o:o

T2020
12-16-2008, 02:54 PM
if (CurrentBar == 0)
{
if((High[0]-Low[0])!=0)
{
volUp.Set(Volume[0]*((High[0]-Open[0])/(High[0]-Low[0])));
volDn.Set(Volume[0]*((Open[0]-Low[0])/(High[0]-Low[0])));
} else
{
volUp.Set(0);
volDn.Set(0);
}
} else

if((High[0]-Low[0])!=0)
{

volUp.Set(volUp[1] + Volume[0]*((High[0]-Open[0])/(High[0]-Low[0])));
volDn.Set(volDn[1] + Volume[0]*((Open[0]-Low[0]) /(High[0]-Low[0])));
}

OBVplot.Set(volUp[0] - volDn[0]);

Is the "if((High[0]-Low[0])!=0)" suppose to take
care of any divide by zero problems ? Maybe it's not doing what it's suppose to . What
if You just went
((High[0]-Open[0])/(High[0]-Low[0] +.00001)));
??

NinjaTrader_Josh
12-16-2008, 03:01 PM
Guys you may be running into double.Epsilon issues. Please review this article: http://www.ninjatrader-support2.com/vb/showthread.php?t=3929

To check for zero do this:
if (High[0] - Low[0] < double.Epsilon)
// It is zero;

roonius
12-16-2008, 03:12 PM
Thank you Ray for reminding me this isue

roonius
12-16-2008, 03:24 PM
Thanks again roonius . I notice that there is an extreme spike in the indicator
right at the beginning of a new bar occasionally ,but resumes normal working
almost immediately . Just something I'm leaving feed back on .
I wish i knew how to do this . I'd be adding moving averages to it , trying
certain period summations of the same formula . I could do all that on my
previous software , unfortunately it didn't have anything remotely as good as
the Ninja chart trader ,which I've come to rely on . Oh well . Thanks again .

Let me know if this will solve extreme spikes. I am not experiensing them my self, so I can not test

T2020
12-16-2008, 03:42 PM
Let me know if this will solve extreme spikes. I am not experiensing them my self, so I can not test
Will do , thanks again .

T2020
12-17-2008, 06:58 AM
This hasn't seemed to cure the problem here . I did notice the spike is less
extreme on a 30 second chart as opposed to a 1 minute chart . Changing
the 1 min to 60 second actually reduced the severity of the spike . I wonder
if it has something to do with me being on a wireless ISP . Not quite the quality of a land line . Packets get dropped . Using TT not Zen fire ??? It works well enough for me to stick with it . I do think it's better than the regular OBV .

T2020
12-17-2008, 08:54 AM
Guys you may be running into double.Epsilon issues. Please review this article: http://www.ninjatrader-support2.com/vb/showthread.php?t=3929

To check for zero do this:
if (High[0] - Low[0] < double.Epsilon)
// It is zero;
Were you suggesting to add this code to the indicator ? Tried it for the heck
of it . Makes the indicator flat line .

NinjaTrader_Bertrand
12-17-2008, 09:02 AM
No, I think this was just an example how the syntax is to be used.

T2020
12-17-2008, 09:22 AM
Still spiking away . If it's above zero ,it spikes down to zero and the reverse
if it's below zero . Gets annoying . Mainly watching a 30 second chart .

NinjaTrader_Josh
12-17-2008, 09:28 AM
The code snippet I provided is just for your comparisons. When subtracting doubles, a value greater than epsilon would mean it is not zero. Do a <= check for an equality check of 0.

T2020
12-17-2008, 10:36 AM
The code snippet I provided is just for your comparisons. When subtracting doubles, a value greater than epsilon would mean it is not zero. Do a <= check for an equality check of 0.
Any other thoughts why this continues to spike to the zero line ? I added this to the code as a " I'll try anything that might help " .00001 ..... code snip >'

if((High[0]-Low[0])!=0)
{
volUp.Set(volUp[1] + Volume[0]*((High[0]-Open[0])/(High[0]-Low[0]+.00001)));

volDn.Set(volDn[1] + Volume[0]*((Open[0]-Low[0])/(High[0]-Low[0]+.00001)));
}

NinjaTrader_Bertrand
12-17-2008, 10:49 AM
T2020, please post a screenshot what you mean by spiking through the zero line...we do not have the bandwidth to debug this, but I would make sure to Plot / Print any calculated value and isolate the one that is being miscalculated...step by step...

T2020
12-17-2008, 11:28 AM
This is as close as I can come because the spike only lasts about 1 second .
What I mean is the OBV line will spike down and touch the zero line . I have
drawn a blue line to mark it . Not sure what you mean by not having the bandwidth ?

NinjaTrader_Josh
12-17-2008, 11:49 AM
We mean we do not have the resources to offer much assistance in this custom indicator endeavor. Good luck guys.

T2020
12-17-2008, 12:35 PM
LOL , guess I wasn't paying attention when the momentum ran out of this
thread . Never fight the trend .:rolleyes: roonius , elliott wave , thanks again for
the help . Have to move on .This things starting to hurt my eye's .