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

[amibroker] Re: Need help with programming


  • Date: Sat, 20 Mar 2010 11:29:08 -0000
  • From: "sanjiv" <sumangalam@xxxxxxxx>
  • Subject: [amibroker] Re: Need help with programming

PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "JEFF F" <jefff@xxx> 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========================================
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/