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

[amibroker] Re: translate esignal script to AB afl?



PureBytes Links

Trading Reference Links

Start with this script from somebody on this forum. 

SECTION_BEGIN("MACD");
/*Long entry = blue line crosses above green line 
Long exit = after above green line, blue line crosses below green 
line 

Short entry = blue line crosses below red line 
Short exit = after below red line, blue line crosses above green line 
*/



A1=EMA(C,12)-EMA(C,26); 
BBtop=BBandTop(A1,10,1); 
BBbot=BBandBot(A1,10,1);
Plot(a1,"MACD",colorDarkBlue,styleThick);
Plot(BBtop,"BBtop",colorDarkGreen,styleThick|styleDashed);
Plot(BBbot,"BBbot",colorRed,styleThick|styleDashed);
Plot(0,"",colorBlack);
Buy= Cross(a1,BBtop) ;
Sell=Cross(BBtop,a1) ;
_SECTION_END();

--- In amibroker@xxxxxxxxxxxxxxx, "n7wyw" <dennisljohnston@xxx> wrote:
>
> Here is an eSignal script of MACD similar to the one contained in 
> nexgen software that costs over $10,000 which is a bollinger band 
> study on macd.  What changes should I make to have this run in AB?
> Thanks for any suggestions.
> 
> Dennis
> 
> 
> eSignal Formula Script --- Printed on: 12/1/2007, 11:14:53 PM --- 
> Page 1
> 1 /*
> 2 MACD BB
> 3 Developed by David Laffineuse, December 2007
> 4 http://tradersguild.wordpress.com
> 5 trader2be@xxx
> 6 */
> 7
> 8 var gUpperBoll = null;
> 9 var gLowerBoll = null;
> 10 var gMACD = null;
> 11 var gTagID = null;
> 12
> 13 function preMain() {
> 14
> 15 setPriceStudy(false);
> 16 setStudyTitle("DL_MACD_BB");
> 17 setCursorLabelName("DL_MACD_UB",0);
> 18 setCursorLabelName("DL_MACD_LB",1);
> 19 setDefaultBarFgColor(Color.yellow,0);
> 20 setDefaultBarFgColor(Color.yellow,1);
> 21 setPlotType(PLOTTYPE_LINE,0);
> 22 setPlotType(PLOTTYPE_LINE,1);
> 23 setDefaultBarThickness(1,0);
> 24 setDefaultBarThickness(1,1);
> 25
> 26 fp1 = new FunctionParameter( "MACD_FL", 
FunctionParameter.NUMBER);
> 27 with(fp1) {
> 28 setName("MACD Fast Length");
> 29 setDefault(12);
> 30 }
> 31 fp2 = new FunctionParameter( "MACD_SL", 
FunctionParameter.NUMBER);
> 32 with(fp2) {
> 33 setName("MACD Slow Length");
> 34 setDefault(26);
> 35 }
> 36 fp3 = new FunctionParameter( "MACD_SM", 
FunctionParameter.NUMBER);
> 37 with(fp3) {
> 38 setName("MACD Smoothing");
> 39 setDefault(9);
> 40 }
> 41 fp4 = new FunctionParameter( "Boll_Length", 
> FunctionParameter.NUMBER);
> 42 with(fp4) {
> 43 setName("Bollinger Length");
> 44 setDefault(20);
> 45 }
> 46 fp5 = new FunctionParameter( "Boll_STD", 
FunctionParameter.NUMBER);
> 47 with(fp5) {
> 48 setName("Bollinger Standard Deviation");
> 49 setDefault(2);
> 50 }
> 51
> 52 }
> 53
> 54 function main(MACD_FL,MACD_SL,MACD_SM,Boll_Length,Boll_STD){
> 55
> 56 var dblMACD = null; // MACD value @ current bar
> 57 var dblMACD_1 = null; // MACD value @ previous bar
> 58 var dblUpperBoll = null; // Upper BB value
> 59 var dblLowerBoll = null; // Lower BB value
> 60 var strBasisColor = null; // Basis color
> 61 var strCircleColor = null; // Circle Color
> 62
> 63 // Instantiations of studies (done once)
> 64
> 65 if (gMACD == null) {
> 66 gMACD = macd(MACD_FL,MACD_SL,MACD_SM);
> 67 gUpperBoll = upperBB(Boll_Length,Boll_STD,gMACD);
> 68 gLowerBoll = lowerBB(Boll_Length,Boll_STD,gMACD);
> 69 }
> 70
> 71 // Rounding required to enable proper white circle assessment
> 72 dblMACD = Math.round((gMACD.getValue(0))*10000)/10000;
> 73 dblMACD_1 = Math.round((gMACD.getValue(-1))*10000)/10000;
> 74 dblUpperBoll = Math.round((gUpperBoll.getValue(0))*10000)/10000;
> 75 dblLowerBoll = Math.round((gLowerBoll.getValue(0))*10000)/10000;
> C:\Program Files\eSignal\Formulas\DL_Formulas\DL_MACD_BB.efs --- 
File 
> time: 10:55:42 PM
> eSignal Formula Script --- Printed on: 12/1/2007, 11:14:53 PM --- 
> Page 2
> 76
> 77 // MACD plot
> 78 if (dblMACD > dblMACD_1) strCircleColor = "Color.green";
> 79 else if (dblMACD == dblMACD_1) strCircleColor = "Color.white";
> 80 else if (dblMACD < dblMACD_1) strCircleColor = "Color.red";
> 81
> 82 drawShapeRelative(0, dblMACD, Shape.CIRCLE, null, eval
> (strCircleColor), Shape.ONTOP );
> 83
> 84 // changes the color of the band based on the value of the MACD
> 85 if (dblMACD >= 0) strBasisColor = "Color.green"; else 
> strBasisColor = "Color.red";
> 86
> 87 drawLineRelative(-1,0,0,0, PS_SOLID, 2, eval
> (strBasisColor),fnGetTagID());
> 88 addBand(0,PS_SOLID,2,eval(strBasisColor),"0line");
> 89
> 90 return new Array (dblUpperBoll,dblLowerBoll);
> 91
> 92 }
> 93 function fnGetTagID() {
> 94 gTagID += 1;
> 95 return gTagID;
> 96 }
> C:\Program Files\eSignal\Formulas\DL_Formulas\DL_MACD_BB.efs --- 
File 
> time: 10:55:42 PM
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html
 
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:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto: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/