PureBytes Links
Trading Reference Links
|
I'm having trouble with getting ApplyStop to do what I want in the
following AFL.
I want to evaluate the signal line of MACD 3 bars after entry to
confirm either staying with the trade or stopping out. This is what
I tried but it fails to meet my expectations.
I also want to use applystop to buy or sell after a signal at the
same price as the EMA band if the price hits it during the following
few days.
Any suggestions?
//EMA Envelope Test with Stops
//pds=13;
//pds=Optimize("pds",14,5,25,4);
percent=1;
periods=13;
fast=5;
//percent=Optimize("percent",.015,.02,1);
emaverage=EMA(C,periods);
bandsadjust=emaverage*percent/100;
upperband=EMAverage+bandsadjust;
lowerband=EMAverage-bandsadjust;
Trigger=EMA(C,fast);
Buy=Ref(trigger,-1) < lowerband AND trigger >= lowerband;
Sell=Ref(trigger,-1) > upperband AND trigger <= upperband;
Cover=Ref(trigger,-1) < lowerband AND trigger >= lowerband;
Short=Ref(trigger,-1) > upperband AND trigger <= upperband;
IIf(Signal(0) < Signal(-2),ApplyStop(stopTypeNBar, stopModeBars,3,
True, True),stay=1);
//ApplyStop(stopTypeNBar, stopModeBars,3);
//ApplyStop( stopTypeTrailing, stopModePoint, 3, True );
Equity(1); // THIS EVALUATES STOPS
Plot( Close, "Price", colorBlack, styleBar );
PlotShapes( IIf( Buy, 1,
IIf( Sell == 4, 6,
IIf( Sell, 2, 0 ) ) ), IIf( Buy, colorGreen, colorRed ) );
Filter=Buy OR Sell OR Short OR Cover;
Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
AddColumn(Buy,"Buy");
AddColumn(Sell,"sell");
AddColumn(Short,"short");
AddColumn(Cover,"cover");
// Plot lines
Plot(EMA(C,fast), "Trigger", 7,1);
Plot(EMA(C,periods), "EMA", 5,1);
Plot(C,"EMA",15,64); //plots candles w/ close
Plot(upperband,"Upperband",3,1);//upperband
Plot(lowerband,"Lowerband",4,1);//lowerband
------------------------ Yahoo! Groups Sponsor ---------------------~-->
DVD Rentals with No Late Fees - Try Netflix for FREE!
http://us.click.yahoo.com/abvVKB/pEZFAA/46VHAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
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/
|