Thank you very much for the conversion. I will compare results to my excel 
program. The first thing I noticed is that it works in a trending market, but 
not in a range bound market. A little tweaking will be in order.

--- In [email protected], "sanjiv" <sumanga...@...> wrote:
>
> Hello,
> 
> You could please see if following is what you are looking for. Please do 
> cross verify individual component by plotting to make sure that the formula 
> is doing what you are looking for :
> 
> //============
> 
> xMACD = MACD(12,26) ;
> Signal_9 = Signal(12, 26, 9);
> xHistogram = xMACD - Signal_9;
> //==================================== Hist Trend 
> ========================================
> Hist_Trend = IIf( xHistogram > 0, 1, -1);
> Hist_Trend = IIf(xHistogram >0 ,IIf(Ref(Hist_Trend,-1) == 5 , 5, 
> Ref(Hist_Trend,-1)+1) ,IIf(xHistogram > Ref(xHistogram,-1) , 
> Ref(Hist_Trend,-1) ,IIf(Ref(Hist_Trend,-1) ==-5 ,-5, Ref(Hist_Trend,-1) -1)));
> //==================================== MACD Trend 
> ======================================
> MACD_Trend = IIf( xMACD > 0, 1, -1);
> 
> MACD_Trend = IIf(xMACD > 0 , IIf(Ref(xMACD,-1) == 5 , 5,Ref(xMACD,-1) +1) 
> ,IIf(xMACD > Ref(xMACD,-1) ,Ref(xMACD,-1) , IIf(Ref(xMACD,-1)== -5 , -5 , 
> Ref(xMACD,-1) -1)));
> //===================================== MA Trend 
> =======================================
> MA_Trend = IIf (C > MA(C,20) , 1 , -1);
> MA_Trend = IIf(C > MA(C,20) , IIf(Ref(MA_Trend,-1) == 5 , 5, 
> Ref(MA_Trend,-1)+1) , IIf(MA_Trend > Ref(MA_Trend,-1), Ref(MA_Trend,-1) , 
> IIf(Ref(MA_Trend,-1) == -5 , -5 , Ref(MA_Trend,-1) -1)));
> //======================================TREND===========================================
> Trend = (Hist_Trend + (MACD_Trend * 3) + (MA_Trend * 2)) / 6; //Weighted 
> Average of Three Trend Indicators
> Trend_Average = MA(Trend,10);
> mTRADE = IIf (Trend_Average >= 0 , IIf (Ref(Trend_Average,-1) < 0 , 1 ,0) , 
> IIf (Ref(Trend_Average,-1) > 0 ,-1 , 0));
> 
> Buy = Cover = mTRADE == 1;
> Sell = Short = mTRADE == -1;
> 
> BuyPrice = SellPrice = ShortPrice = CoverPrice = C;
> SetTradeDelays(0,0,0,0);
> 
> Plot( C, "C",colorYellow, 128 );
> 
> PlotShapes( shapeUpArrow * Buy, colorGreen, 0 , L, -10 );
> PlotShapes( shapeDownArrow * Sell, colorRed, 0 , H, -10 );
> 
> 
> With Regards
> 
> Sanjiv Bansal
> 
> --- In [email protected], "JEFF F" <jefff@> wrote:
> >
> > I have created this simple system in excel and would like to try to convert 
> > it to AFL. If anyone can help, I would appreciate it. 
> > 
> > ===================================DEFINITIONS=======================================
> > MACD = EMA12 – EMA26
> > 9 Day Signal = 9 Day Average MACD
> > Histogram = MACD - 9 Day Signal
> > ==================================== Hist Trend 
> > ========================================
> > Hist Trend = If Histogram > 0, 1, -1
> > =IF(Histogram Today >0 , IF(Hist Trend Yesterday = 5 , 5, Hist Trend 
> > Yesterday +1) , IF(Histogram Today > Histogram Yesterday , Hist Trend 
> > Yesterday , IF(Hist Trend Yesterday =-5 , -5, Hist Trend Yesterday -1)))
> > ==================================== MACD Trend 
> > ======================================
> > MACD Trend = If MACD > 0, 1, -1
> > =IF(MACD Today > 0 , IF(MACD Trend Yesterday = 5 , 5, MACD Trend Yesterday 
> > +1) , IF(MACD Today > MACD Yesterday , MACD Trend Yesterday , IF(MACD Trend 
> > Yesterday = -5 , -5 , MACD Trend Yesterday -1)))
> > ===================================== MA Trend 
> > =======================================
> > MA Trend = IF (Close > MA20 , 1 , -1)
> > =IF(Close Today > MA20 Today , IF(MA Trend Yesterday = 5 , 5, MA Trend 
> > Yesterday +1) , IF(Close Today > Close Yesterday, MA Trend Yesterday , 
> > IF(MA Trend Yesterday = -5 , -5 , MA Trend Yesterday -1)))
> > ======================================TREND=========================================
> > Trend = (Hist Trend + (MACD Trend * 3) + (MA Trend * 2)) / 6    //Weighted 
> > Average of Three Trend Indicators
> > Trend Average = AVERAGE (10 Day Trend)
> > =IF (Trend Average Today >= 0 , IF (Trend Average Yesterday < 0 , "BUY" , 
> > "Hold") , IF (Trend Average Yesterday > 0 , "SELL" , "Hold"))
> > =========================================END========================================
> >
>


Reply via email to