Volume Weighted MACD

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
sdewar
Posts: 19
Joined: 04 Nov 2010
Been thanked: 2 times

Volume Weighted MACD

Postby sdewar » 29 Jan 2011

Hi - Can someone tell me how to change the MACD settings to make them Volume Weighted moving averages instead of exponential? I am using MC 6.1.

Thanks for the help.

Cheers

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

Re: Volume Weighted MACD

Postby TJ » 29 Jan 2011

Hi - Can someone tell me how to change the MACD settings to make them Volume Weighted moving averages instead of exponential? I am using MC 6.1.

Thanks for the help.

Cheers
Do you have the formula for Volume Weighted moving average?

sdewar
Posts: 19
Joined: 04 Nov 2010
Been thanked: 2 times

Re: Volume Weighted MACD

Postby sdewar » 30 Jan 2011

Hi - I found this code on the web but can't get it to compile without errors;

Code: Select all

//Indicator: VW_MACD

inputs:
FastLength( 12 ),
SlowLength( 26 ),
VW_MACDLength( 9 ),
DisplayVW_MACD( False ) ;

variables:
MyVolume( 0 ),
VW_MACD( 0 ),
VW_MACDAvg( 0 ),
VW_MACDDiff( 0 ) ;

if BarType >= 2 and BarType < 5 then
{ not tick/minute data nor an advanced chart type (Kagi, Renko, Kase etc.) }
MyVolume = Volume
else
{ if tick/minute data or an advanced chart type; in the case of minute data,
also set the "For volume, use:" field in the Format Symbol dialog to Trade Vol or
Tick Count, as desired; when using advanced chart types, Ticks returns volume if
the chart is built from 1-tick interval data }
MyVolume = Ticks ;

VW_MACD = ( XAverage( MyVolume * Close , FastLength )
/ XAverage( MyVolume, FastLength ) )
- (XAverage( MyVolume * Close , SlowLength )
/ XAverage( MyVolume, SlowLength)) ;
VW_MACDAvg = Average( VW_MACD, VW_MACDLength ) ;
VW_MACDDiff = VW_MACD - VW_MACDAvg ;

if DisplayVW_MACD then
begin
Plot1( VW_MACD, "MACD" ) ;
Plot2( VW_MACDAvg, "MACDAvg" ) ;
end ;
Plot3( VW_MACDDiff, "MACDDiff" ) ;
Plot4( 0, "ZeroLine" ) ;

Code: Select all

//Strategy: MACD_Diff

inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;

variables: MyMACD( 0 ), MACDAvg( 0 ), MACDDiff( 0 ) ;

MyMACD = MACD( Close, FastLength, SlowLength ) ;
MACDAvg = XAverage( MyMACD, MACDLength ) ;
MACDDiff = MyMACD - MACDAvg ;

Plot1( MACDDiff, "MACDDiff" ) ;
Plot2( 0, "ZeroLine" ) ;

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Volume Weighted MACD

Postby sptrader » 30 Jan 2011

It won't compile as is, because a strategy is in there too- I commented it out and it compiles..

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

Re: Volume Weighted MACD

Postby TJ » 30 Jan 2011

Hi - I found this code on the web but can't get it to compile without errors;
...
1. In the future, please use the code tag to wrap around the code. It makes reading the code easier. (I have done it for you this time.)

2. In the future, please copy and paste the error message, so that people know where to help you. Sometimes the error has nothing with the code, but your computer, or other issues.


ps. there are 2 codes in your post.

sdewar
Posts: 19
Joined: 04 Nov 2010
Been thanked: 2 times

Re: Volume Weighted MACD

Postby sdewar » 30 Jan 2011

Thanks a lot guys. Will do no problem. Appreciate you pointing me in the right direction I am a coding dummy.

Cheers

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

Re: Volume Weighted MACD

Postby TJ » 31 Jan 2011

Thanks a lot guys. Will do no problem. Appreciate you pointing me in the right direction I am a coding dummy.

Cheers
You are welcome.


Return to “User Contributed Studies and Indicator Library”