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

Re: [amibroker] coding exit points in AFL; multiple exits



PureBytes Links

Trading Reference Links

Hello,

Thank you for your e-mail. 
As to your questions:
1. Make sure that you have checked "Exit at stop" box
in the settings dialog, or if you are using ApplyStop function,
make sure that the fourth argument (exitatstop) is set to 1:
ApplyStop( type, mode, amount, exitatstop ) 

2. You can set multiple exit points. As for the example you
supplied it is enough to set profit target and max. loss stops.

buy = cross( macd(), signal() );
sell = 0;
ApplyStop( 0, 1, 2, 1 ); 
ApplyStop( 1, 1, 2, 1 ); 

In addition to that your "sell" formula may combine multiple exit
strategies using OR operator.

Best regards,
Tomasz Janeczko
amibroker.com 


----- Original Message ----- 
From: "techwatcher" <ppark@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, September 27, 2001 10:12 PM
Subject: [amibroker] coding exit points in AFL; multiple exits


>[snip]
> 
> 1. If you pre-selected a small group of stocks from a universe using 
> the filter mechanism in the software and now want to backtest a 
> money management strategy, how do you make sure that the exit 
> actually happens at the exit stop. Somehow, it looks like the profit 
> number from a trade uses the "sell price" rather than the "profit 
> target percent" specified in the Settings tab. For example, for a 
> given stock produced by a filter, I may want to buy at the open on 
> the day after the stock met the filter criteria and then sell at 2 
> percent higher than that. Let's also suppose that the stock performs 
> in the following manner on the day that the purchase happens:
> 
> XYZ: open=100, high=105, low=100, close=101
> 
> In this scenario, I would expect an exit at 102 and register a 
> profit of 2 percent for this transaction.
> 
> Somehow, the way that I have been coding it produces a bigger number 
> than 2 percent profit even though I specify "profit target percent" 
> of 2 percent. I am sure that it is not difficult, but I don't know 
> what I am doing wrong. I have been using the settings tab to do this 
> rather using the applystop function in AFL. Could someone supply the 
> specific backtest code for doing this? 
> 
> 2. Can this software support multiple exit points? For example, a 
> limit of 2 percent above the purchase price and stop of 2 percent 
> below the purchase price? What would be the AFL code for this.
> 

Best regards,
Tomasz Janeczko
===============
AmiBroker - the comprehensive share manager.
http://www.amibroker.com