[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Composite MACD Help requierd



PureBytes Links

Trading Reference Links

Dear All,
   
  Help required for AFL of MACDComposite.
   
  Metastock formula is as under:-
  ====================
MACD - composite EMA
====================
---8<---------------------------

{ MACD or Histogram based on multiple EMA's }
{ Incorporating automatic overbought/oversold
  levels }
{ ©Copyright 2005 Jose Silva }
{ http://www.metastocktools.com }

{ User inputs }
plot1:=Input("[1]MACD,  [2]Histogram",1,2,1);
plot2:=Input("[1]MACD/Hist,  [2]Normalized",
 1,2,1);
pds:=Input("Signal/Histogram EMA periods",
 2,260,21);

{ Composite-EMA MACD/Histogram }
ema1:=
  Mov(C,3,E)
 +Mov(C,5,E)
 +Mov(C,8,E)
 +Mov(C,11,E)
 +Mov(C,14,E)
 +Mov(C,17,E);
ema2:=
  Mov(C,30,E)
 +Mov(C,35,E)
 +Mov(C,40,E)
 +Mov(C,45,E)
 +Mov(C,50,E)
 +Mov(C,56,E);
emaComp:=ema1-ema2;
signal:=Mov(emaComp,pds,E);
hist:=emaComp-signal;

{ Choose MACD or Histogram }
MacdH:=If(plot1=1,emaComp,hist);

{ Normalized MACD/Histogram }
normMod:=Highest(MacdH)-Lowest(MacdH);
normMod:=If(normMod=0,.000001,normMod);
MacdHnorm:=
 ((MacdH-Lowest(MacdH))/normMod-.5)*200;

{ Choose standard/normalized }
MacdComp:=If(plot2=1,MacdH,MacdHnorm);
signal:=Mov(MacdComp,pds,E);

{ MACD/Hist average }
avg:=Cum(MacdComp)/Cum(IsDefined(MacdComp));

{ MACD/Hist auto boundaries }
pk:=Ref(MacdComp,-1)>MacdComp
 AND Ref(MacdComp,-1)>Ref(MacdComp,-2)
 AND Ref(MacdComp,-1)>avg;
pkVal:=ValueWhen(1,pk,Ref(MacdComp,-1));
tr:=Ref(MacdComp,-1)<MacdComp
 AND Ref(MacdComp,-1)<Ref(MacdComp,-2)
 AND Ref(MacdComp,-1)<avg;
trVal:=ValueWhen(1,tr,Ref(MacdComp,-1));
Obought:=Cum(pkVal)/Cum(IsDefined(pkVal));
Osold:=Cum(trVal)/Cum(IsDefined(trVal));

{ Plot in own window }
Obought;                { Red  }
avg;                    { Grey }
Osold;                  { Blue }
If(plot1=1,signal,avg); { Green }
MacdComp                { Black }

  Formula of Metastock available at 
  http://www.metastocktools.com/MetaStock/MACDHcomp.txt also.

  I have written part code in AFL as under:-
  // Composite MACD
  ema1=
  EMA(C,3)
  +EMA(C,5)
  +EMA(C,8)
  +EMA(C,11)
  +EMA(C,14)
  +EMA(C,17);
  ema2=
  EMA(C,30)
  +EMA(C,35)
  +EMA(C,40)
  +EMA(C,45)
  +EMA(C,50)
  +EMA(C,56);
  emaComp=ema1-ema2;
  s=EMA(emaComp,21);
   
  Plot(S , "SIGNAL", colorRed);
  Plot(emaComp , "emaComp", colorBlue);
  Plot(0,"",colorBlack,styleLine);
      
Help requested to complete the code. I have taken permission of Mr.Jose Silva regarding above.
   
  Thanks in advance.
  Hitash Pandya

 				
---------------------------------
 Here?s a new way to find what you're looking for - Yahoo! Answers 
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.18/662 - Release Date: 1/31/2007 3:16 PM