VForce formula error?

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

VForce formula error?

Postby Laurent » 10 Feb 2011

To compute the Klinger Volume Oscillator, you need first to compute the Volume Force.

On the net (on a lot of Web sites) there is the following code to compute it:

Code: Select all

Type: Function, Name: VForce

Vars: TSum(0), Trend(0), DM(0), CM(0);

TSum = High + Low + Close;
IF TSum > TSum[1] Then

Trend = 1
Else
Trend = -1;
IF Trend = Trend[1] Then
CM = CM + Range
Else
CM = Range + Range[1];
IF CM <> 0 Then
VForce = Volume * AbsValue(2 * (DM/CM) -1) * Trend * 100;
...
It looks like there is a problem...
DM = 0... so AbsValue(2 * (DM/CM) -1) will always be equal to -1...
Is it normal? Did I miss something?

BTW what is DM? Would be cool to have the right formula! ;)

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: VForce formula error?

Postby TJ » 10 Feb 2011

this is from my archive:

Code: Select all

// Type: Function, Name: VForce

Vars:
TSum(0),
Trend(0),
DM(0),
CM(0);

TSum = High + Low + Close;
DM = High - low;

IF TSum > TSum[1] Then
Trend = 1
Else
Trend = -1;

IF Trend = Trend[1] Then
CM = CM + Range
Else
CM = Range + Range[1];

IF CM <> 0 Then
VForce = Volume * AbsValue(2 * (DM/CM) -1) * Trend * 0.01;

{0.01 works great too; original version had * 100.
Made smaller to decrease the plotted size of volume}

Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Re: VForce formula error?

Postby Laurent » 10 Feb 2011

Cool, thanks for your version!

There is the error on the multicharts website:
https://www.multicharts.com/support/bas ... le&id=1387

I don't know if this can be fixed!


Return to “User Contributed Studies and Indicator Library”