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

Re: [amibroker] Exit base on time and profit



PureBytes Links

Trading Reference Links

Greetings --

See if this helps.  Note I've changed the 5% to 2% -- there are not many 5% gains in 5 days.

Thanks,
Howard
www.quantitativetradingsystems.com

//---------------------------------------------------------------------
//    ExitAfterFiveDays.afl
//

//    Put trade entry logic here.
MA1 = MA(C,3);
MA2 = MA(C,20);

Buy = Cross(MA1,MA2);

//    Put trade exit logic here, but call the exit SellSystem
SellSystem = Cross(MA2,MA1);

//    Set a profit target stop at 2%, exit intraday
ApplyStop(stopTypeProfit,stopModePercent,2,1);

//  Combine the SellSystem with a timed exit after 5 days.
//  If the profit target was reached, it would have taken the trade out first.
Sell = SellSystem OR (BarsSince(Buy)>=5);

//  Remove the extra arrow.
Buy = ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);

//  Plot everything
Plot(C,"C",colorBlack,styleCandle);
Plot(MA1,"MA1",colorGreen,styleLine);
Plot(MA2,"MA2",colorBlue,styleLine);
PlotShapes(Buy*shapeUpArrow+Sell*shapeDownArrow,
    IIf(Buy,colorGreen,colorRed));



On 4/2/07, chwinc2000 <chwinc2000@xxxxxxxxx> wrote:

Hello,

Can someone please point me in the direction of how I would go about
coding this?

Exit Rules --> I would like to exit 5 bars after entry if open profit
is <5% gain.

Thank you for your help.


__._,_.___

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





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___