Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
It does work correctly - it works EXACTLY as you have coded it, and uses the data exactly as you provide it. You have just programmed it wrong....
Put some sample data into your code and see the effects for yourself...
BARS 1 to 100 - Data values in the order of 100... using x1....
{** _MACD Input switched **}
x1:=Security("C:\\METASTOCK DATA\\.DJI",C);
x2:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C);
x1:=ExtFml("Forum.Sum",x1,1); {in the order of 100}
x2:=ExtFml("Forum.Sum",x2,1);
x3:=ExtFml("Forum.Sum",x2,300);{30-->300 to normalize, but no change}
x:=If(x3=0,x1,x2);
{these MAs are in the order of 100}
MAFast:=Mov(x,12,E);
MASlow:=Mov(x,26,E);
{***Normalize -- from Jose's code}
ratio:=Min(MAFast,MASlow)/Max(MAFast,MASlow);
Mac:=(If(MAFast>MASlow,2-ratio,ratio)-1)*100;
MacdNorm:=(Mac-LLV(Mac,250))/(HHV(Mac,250)-LLV(Mac,250)+.000001)*100;
{***}
MASignalNorm:=Mov(MACDNorm,9,E);
MACDHNorm:=MACDNorm-MASignalNorm;
{These values turn out to be whatever?}
MASignalnorm-50;
MACDnorm-50;
MACDHnorm;
0;
{***}
What happens on BAR 101 when the data swings over to x2.... of the order 10000?
{** _MACD Input switched **}
x1:=Security("C:\\METASTOCK DATA\\.DJI",C);
x2:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C);
x1:=ExtFml("Forum.Sum",x1,1);
x2:=ExtFml("Forum.Sum",x2,1); {in the order of 10000}
x3:=ExtFml("Forum.Sum",x2,300);{30-->300 to normalize, but no change}
x:=If(x3=0,x1,x2);
{for the first 100 bars the MAs are in the order of 100, but now adds a bar with 100000. Obviously the effect is going to be greatest on the fast MA than the slow MA}
MAFast:=Mov(x,12,E);
MASlow:=Mov(x,26,E);
{Now what happens to the normalising process with massive jump from the previous values of the MAs and the disconnect of the data in the current MAs?}
{***Normalize -- from Jose's code}
ratio:=Min(MAFast,MASlow)/Max(MAFast,MASlow);
Mac:=(If(MAFast>MASlow,2-ratio,ratio)-1)*100;
MacdNorm:=(Mac-LLV(Mac,250))/(HHV(Mac,250)-LLV(Mac,250)+.000001)*100;
{***}
MASignalNorm:=Mov(MACDNorm,9,E);
MACDHNorm:=MACDNorm-MASignalNorm;
{These values turn out to be magnitude greater than before, distorting the plot}
MASignalnorm-50;
MACDnorm-50;
MACDHnorm;
0;
{***}
and the process is reversed when the data swings back the other way. As you have a disparity between the large and small data values, you are better off scaling one to better match the magnitude of the other.
If you want to swing MACDs, why not compute an MACD for each data set, then use your rules to change from one normalised MACD to the other? As my old boss said to me once, "Start thinking outside the box, instead of beating your head against it!"
{** _MACD Input switched **}
x1:=Security("C:\\METASTOCK DATA\\.DJI",C);
x2:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C);
x1:=ExtFml("Forum.Sum",x1,1);
x2:=ExtFml("Forum.Sum",x2,1);
x3:=ExtFml("Forum.Sum",x2,300);{30-->300 to normalize, but no change}
x1MAFast:=Mov(x1,12,E);
x1MASlow:=Mov(x1,26,E);
x2MAFast:=Mov(x2,12,E);
x2MASlow:=Mov(x2,26,E);
x1ratio:=Min(x1MAFast,x1MASlow)/Max(x1MAFast,x1MASlow);
x1Mac:=(If(x1MAFast>x1MASlow,2-x1ratio,x1ratio)-1)*100;
x1MacdNorm:=(x1Mac-LLV(x1Mac,250))/(HHV(x1Mac,250)-LLV(x1Mac,250)+.000001)*100;
x2ratio:=Min(x2MAFast,x2MASlow)/Max(x2MAFast,x2MASlow);
x2Mac:=(If(x2MAFast>x2MASlow,2-x2ratio,x2ratio)-1)*100;
x2MacdNorm:=(x2Mac-LLV(x2Mac,250))/(HHV(x2Mac,250)-LLV(x2Mac,250)+.000001)*100;
x1MASignalNorm:=Mov(x1MACDNorm,9,E);
x1MACDHNorm:=x1MACDNorm-x1MASignalNorm;
x2MASignalNorm:=Mov(x2MACDNorm,9,E);
x2MACDHNorm:=x2MACDNorm-x2MASignalNorm;
{plot}
x:=If(x3=0,x1MASignalnorm-50,x2MASignalnorm-50);
x:=If(x3=0,x1MACDnorm-50,x2MACDnorm-50);
x:=If(x3=0,x1MACDHnorm,x2MACDHnorm);
0;
You might have to look at the changeover period to make sure the MACD for the second data set exists before the expiration of the first data set... but that shoulddn't be too much of an issue??
wabbit :D
|