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

[amibroker] Re: 4 macd charts



PureBytes Links

Trading Reference Links


Ravi,
Someone in our users group developed the exploration for 4-MACD taht 
follows.  I haven't had much luck with it so possibly you can make it 
perfom better.  Regards,
Dick H.

/******************** Preliminaries *******************************/
PositionSize = 10000;
scale = Param("scale", 100, 100, 1000, 100);

/******************** Generate Histogram data *********************/
//= Red Bars ===================
Gr1 = MACD(38,14); 
Gr2 = Signal(38,14,8);
Diffr = Gr1-Gr2;

//= Green Bars ===================
Gr1 = MACD(12, 25); 
Gr2 = Signal(12, 25, 6); 
Diffg = Gr1-Gr2;

//= Blue Bars ===================
Gr1 = MACD(33,17);
Gr2 = Signal(33,17,10);
Diffb = Gr1-Gr2;

//= Yellow Bars ===================
Gr1 = MACD(12,37); 
Gr2 = Signal(12,37,8); 
Diffy = Gr1-Gr2;

CR = (LastValue(Highest(diffr))/LastValue(Highest(diffr))) * Diffr;
CG = (LastValue(Highest(diffr))/LastValue(Highest(diffg))) * Diffg;
CB = (LastValue(Highest(diffr))/LastValue(Highest(diffb))) * Diffb;
CY = (LastValue(Highest(diffr))/LastValue(Highest(diffy))) * Diffy;

/***************** Generate Stochastics ***************************/

Stoch_K = StochK(17, 3);
Stoch_D = StochD(17, 3, 3);

/**************** Generate Bollinger Band "stuff" *****************/

BBT = BBandTop(C, 21, 2);
BBB = BBandBot(C, 21, 2);
BBML = (BBT + BBB) / 2;
QBB = (BBT-BBB) / 4;
BBUQ = BBML + QBB;
BBLQ = BBML - QBB;
CinTopQuarter = (C >= BBUQ); // 1 if C in upper quarter, 0 otherwise
CinBottomQuarter = (C <= BBLQ); // 1 if C in lower quarter, 0 
otherwise

/**************** Generate Buy / Sell Signals *********************/

Buy = Sell = False;

// 3 Options for initial Buy condition
// 1a) Buy when Green bar crosses from below to above zero line
// 1b) Buy as the Green (below zero) bar starts to turn up and the 
Red (above zero) starts to turn down 
// 1c) Buy as the Green starts to turn up with Yellow showing below 
the Green and the Red starts to turn down 

Buy1 = Cross(CG , 0); // option 1a
//Buy1 = ((CG < 0) AND (CR > 0) AND (Ref(CG,-1) < CG) AND (Ref(CR,-1) 
> CR)); // option 1b
//Buy1 = (((CG < 0) AND (CR > 0) AND (Ref(CG,-1) < CG) AND (Ref(CR,-
1) > CR) AND (CY < CG))); // option 1c

// Additional Buy Conditions
// 2) Stochastic has remained flat ....below the 20 line for several 
days and then crosses the line
// Note: I don't know how to encode "flat",
// I use the STOCH D, 
// "several days" means 3
// 3) The price is at the ... bottom of the Bollinger Band 

Buy2 = (Ref(Stoch_D, -3) < 20) AND 
  (Ref(Stoch_D, -2) < 20) AND 
  (Ref(Stoch_D, -1) < 20) AND
  Cross(Stoch_D, 20);

Buy3 = CinBottomQuarter;

Buy = Buy1 AND Buy2 AND Buy3;

// 3 Options for intial Sell condition
// 1a) Sell when Green bar crosses from above to below zero line
// 1b) Sell as the Green starts to turn down and the Red starts to 
turn up
// 1c) Sell as the Green starts to turn down and the Red starts to 
turn up with Blue showing below the Red

Sell1 = Cross(0, CG); // option 1a
//Sell1 = ((CG > 0) AND (CR < 0) AND (Ref(CG, -1) > CG) AND (Ref(CR,-
1) < CR)); // option 1b
//Sell1 = (((CG > 0) AND (CR < 0) AND (Ref(CG, -1) > CG) AND (Ref(CR,-
1) < CR) AND (CB < CR))); // option 1c

// Additional Sell Conditions
// 2) Stochastic has remained flat above the 80.... line for several 
days and then crosses the line
// Note: I don't know how to encode "flat",
// I use the STOCH D, 
// "several days" means 3
// 3) The price is at the top ... of the Bollinger Band

Sell2 = (Ref(Stoch_D, -3) > 80) AND 
  (Ref(Stoch_D, -2) > 80) AND 
  (Ref(Stoch_D, -1) < 80) AND
  Cross(80, Stoch_D);

Sell3 = CinTopQuarter;

Sell = Sell1 AND Sell3; // Sell2 is not used as it's too restrictive

// Remove extraneous Buy / Sell signals

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

/***************************** Indicator Plotting ***************/
_N(Title = Name() + "(" + FullName() + ");  "  + Date() +
"  \\c32Red=" + CR + ";" + "  \\c43Green=" + CG + ";  \\c37Blue=" + 
CB + ";  \\c33Yellow=" + CY +
"\n\\c16  4-MACD Exploration");

Plot (CR*scale, "", colorRed, 2+4);
Plot (CG*scale, "", colorBrightGreen, 2+4);
Plot (CB*scale, "", colorLightBlue, 2+4);
Plot (CY*scale, "", colorLightOrange, 2+4);
Plot (0, "", 16);
Plot (CR*scale, "", colorRed, 1);
Plot (CG*scale, "", colorBrightGreen, 1);

// Stoch_D is moved down by 50 points so that it's equilibrium line 
is is 0 rather than 50.
// The 20 and 80 Stochastic lines are now 30 and -30, respectively.
// This allows the stochastic to be plotted directly over the 4 MACD 
bars, which are centered 
// around 0 as well.
Plot (Stoch_D-50, "", 29, 1+4+8); 
Plot (30, "", 16);
Plot (-30,"", 16);

// Signals
BuySignals = Buy * shapeUpArrow;
SellSignals = Sell * shapeDownArrow;
PlotShapes (BuySignals, colorGreen, 0, Stoch_D-50, -20);
PlotShapes (Sellsignals, colorRed, 0, Stoch_D-50, -20);

/*************************** Exploration ***********************/
MinVolume = 1000000;
CloseTimesVolume = C * V;
MinCloseVolume = MA(CloseTimesVolume, 50) > MinVolume;
MinPrice = 5;
MaxPrice = 50;

Filter = (Buy OR Sell);
AddColumn (Buy, "Buy",1.0);
AddColumn (Sell, "Sell",1.0);
AddColumn (C, "Close");
AddColumn (V, "Volume", 13.0);
AddColumn (CloseTimesVolume, "C * V", 9.0);


--- In amibroker@xxxxxxxxxxxxxxx, "ravinikl" <ravinikil@xxxx> wrote:
> 
> 
> dear friends
>           i was working with 4 macd system indicators down loaded 
> from the file section. it is working good in amibroker. i would 
like 
> to ask help from you how to get exploration codes in afl for the 
same 
> or scan my data base to find out buy and sell signals on every day 
> basis for 4 macd system to obtain accurate results based on 
automatic 
> analysis.
>     with regards
> 
> ravi
> qatar





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

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

<*> 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/