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

[amibroker] AFL code help request



PureBytes Links

Trading Reference Links

I started with the EMA band afl in the library.  I want to modify the 
buy/sell signals to buy when the fast ema moves below the lower band 
and crosses up from below.  Then sell when it hooks over the upper 
ban goes above and crosses down. 
Also, I want to stop and reverse on the signals both long and short.  
Can someone suggest changes as described?  Thanks.


 /* EMA offset bands ver 1_2
I'd guess this is NOT much different to bbands except you can contol 
the per %
offset and the periods ema to off set*/
per=.015;//Percent placement
periods=13;//time periods
fast=5;
/*********************************/

emaverage= EMA(C,periods);
bandsAdjust=emaverage*per;

upperband=emaverage+bandsAdjust;
Lowerband=emaverage-bandsAdjust;

Plot(EMA(C,fast),"trigger",7,1);

Plot(EMA(C,periods),"ema",5,1);
Plot(C,"EMA",15,64);// plots the close with candles
Plot(upperband,"upperband",3,1);// upperband
Plot(Lowerband,"lowerband",4,1);//lowerband

bCond1=Ref(Cross(C,Lowerband),-1) AND C > lowerband ;
bCond2= C > EMAverage ;// the "or" gets me into up trends 
bCond3= C > EMA(C,65);// trend

Buy = bcond1 AND bCond3 OR bCond2; 

scond1= Ref( Cross(emaverage,C),-1)AND C < emaverage;// close days 
under ema 
scond2=C < Lowerband;//failed trade drops below lowerband
Sell = scond1 OR scond2;

Buy = ExRem( Buy, Sell );// removes buy/sell arrows
Sell = ExRem( Sell, Buy );


Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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