Saturday, January 11, 2014

Amibroker AFL for Parabolic SAR Crossover Signal

Amibroker AFL for recognizing Parabolic SAR crossover.

Credit goes to the creator of the AFL Code. No changes have been made by the Blog owner to the AFL code. The code has been obtained through online resource and is presented on as it is basis.

Please copy the code from the Code Box below. You may refer to the image posted below to look how the chart looks after applying the AFL.



_SECTION_BEGIN("Parabolic SAR Crossover");
Plot(C,"Close",colorBlack,64);
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();


Plot( 2, /* defines the height of the Market Trend in percent of pane width */"TREND",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 6 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

SetChartBkColor( ParamColor( "Outer panel",colorBlack) );

SetChartOptions(0,chartShowArrows|chartShowDates);
 
NewDay = Day()!= Ref(Day(), -1);
DH = HHV( H, NewDay);
DL =  LLV(L, NewDay);
Plot(DH,"DAY HIGH",colorPaleGreen,ParamStyle("Style"),0,0,0);
Plot(DL,"DAY LOW",colorPink,ParamStyle("Style"),0,0,0);
R1=((DH-DL)*0.33)+DL;
R2=((DH-DL)*0.66)+DL;
Plot(R1,"BEARISH BELOW",colorYellow,styleDashed,0,0,0);
Plot(R2,"BULLISH ABOVE",colorBrightGreen,styleDashed,0,0,0);

accel = Param("Acceleration", 0.02, 0, 1, 0.001); 
mx = Param("Max. acceleration", 0.2, 0, 1, 0.001); 

F_SAR = SAR(accel,mx); 

colordots = IIf(F_SAR < L,colorGreen,IIf(F_SAR> H,colorRed,colorWhite)); 

Buy = Cross(C,F_SAR); Buy = Ref(Buy,-1); BuyPrice = O; 
Sell = Cross(F_SAR,C); Sell = Ref(Sell,-1); SellPrice = O; 

SetBarsRequired(-2,-2); 
SetChartOptions(0, chartShowDates); 
 Plot(F_SAR,"\nF_SAR",colordots,styleDots|styleNoLine); 

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBrightGreen,0,L,-15); 
PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorBrightGreen,0,L,-15); 
PlotShapes(IIf(Buy,shapeHollowCircle,shapeNone),colorBlue,0,BuyPrice,0); 

PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15); 
PlotShapes(IIf(Sell,shapeHollowDownArrow,shapeNone),colorRed,0,H,-15); 
PlotShapes(IIf(Sell,shapeHollowCircle,shapeNone),colorOrange,0,SellPrice,0);

There is a substantial risk of loss associated with trading in Stock Markets. Losses can and
will occur. No responsibility for loss occurred to any person acting or refraining to act as a result
of using the AFL written by their respective creators and published in this Blog for sharing of knowledge can be accepted by the Blog owner.



No comments:

Post a Comment

Required US Government Disclaimer & CTFC Rule 4.41

Futures trading contains substantial risk and is not suitable for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only consider risk capital that should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. CTFC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS SUCH AS LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN. All trades, patterns, charts, systems, etc., discussed in this website or advertisement are for illustrative purposes only and not construed as specific advisory recommendations. All ideas and materials presented herein are for information and educational purposes only. No system or trading methodology has ever been developed that can guarantee profits or prevent losses. The testimonials and examples used herein are exceptional results which do not apply to average people and are not intended to represent or guarantee that anyone will achieve the same or similar results. Trades placed on the reliance of Trend Methods systems are taken at your own risk for your own account. This is not an offer to buy or sell futures interests.