Page 1 of 1

Volume Weighted MACD

Posted: 29 Jan 2011
by sdewar
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

Re: Volume Weighted MACD

Posted: 29 Jan 2011
by TJ
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?

Re: Volume Weighted MACD

Posted: 30 Jan 2011
by sdewar
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" ) ;

Re: Volume Weighted MACD

Posted: 30 Jan 2011
by sptrader
It won't compile as is, because a strategy is in there too- I commented it out and it compiles..

Re: Volume Weighted MACD

Posted: 30 Jan 2011
by TJ
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.

Re: Volume Weighted MACD

Posted: 30 Jan 2011
by sdewar
Thanks a lot guys. Will do no problem. Appreciate you pointing me in the right direction I am a coding dummy.

Cheers

Re: Volume Weighted MACD

Posted: 31 Jan 2011
by TJ
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.