| ApplyStop |  Trading system toolbox | 
| SYNTAX | ApplyStop( type, mode, amount, exitatstop, volatile = False, ReEntryDelay = 0, ValidFrom = 0, ValidTo = -1 ) | 
| RETURNS | Nothing | 
| FUNCTION | controls built-in stops from the formula level (allows optimization of stops) Parameters: 
type = 
mode =  
amount =  
   ReEntryDelay -  ValidFrom -  ValidTo -  ValidFrom/ValidTo can be used to create stops that get actived/deactivated in different times. This setting is independent for each stop type. It also works in conjunction with SetOption("HoldMinBars", x ). HoldMinBars affects BOTH regular exits and stops, preventing ALL kind of exits during defined period. ValidFrom/ValidTo works on each stop separately and does not affect regular exits. 
Note on using stops: 
    ExitAtStop = 2	(NEW) 
 Scenario 4: you trade on today's close and want to exit only when today's close price hits the stop level Correct settings: ActivateStopsImmediately turned OFF ExitAtStop = 0 Trade delays set to zero Trade price set to close LIMITATIONS: 
 | 
| EXAMPLE | /* max loss stop optimization
*/
 
 | 
| SEE ALSO | 
| Herman van den Bergen psytek [at] magma.ca 2003-02-23 09:53:51 | If you are trading at the Close with zero delays be sure to unmark "Activate Stops Immediately" in Settings. | 
| Corey Saxe csaxe [at] nwi.net 2003-03-01 23:33:13 | For visual conformation of ApplyStop function, add the following lines below your ApplyStop formula in Indicator Builder: Equity(1); // THIS EVALUATES STOPS Plot(Sell==4,"ApplyStop Sell",colorRed,1|styleOwnScale); Plot(Cover==4,"ApplyStop Cover",colorGreen,1|styleOwnScale); | 
| Tomasz Janeczko tj --at-- amibroker.com 2004-08-28 03:14:12 | If two or more different stops are triggered on the VERY SAME bar then they are evaluated in this fixed order: Fixed Ruin stop (loosing 99.96% of the starting capital) Max. loss stop Profit target stop Trailing stop N-bar stop | 
| Graham Kavanagh gkavanagh [at] e-wire.net.au 2004-09-30 21:55:42 | from equity comments Depending on kind of the stop various values are written back to sell/cover array to enable you to distinguish if given signal was generated by regular rule or by stop. 1 - regular exit 2 - max. loss 3 - profit target 4 - trailing 5 - n-bar stop 6 - ruin stop | 
| Tomasz Janeczko tj --at-- amibroker.com 2005-03-01 17:10:39 | ExitAtStop has a new meaning for N-BAR stop type. If ExitAtStop = 0 then N-bar stop has the lowest priority (so if for example profit target stop is hit on the same bar then profit target is evaluated first) If ExitAtStop = 1 then N-bar stop has highest priority and it is evaluated before all other stops. The same effect is obtained by checking "Has priority" box in AA Settings window. | 
| Tomasz Janeczko tj-/nospam/ [at] amibroker.com 2006-01-13 11:41:32 | ApplyStop function is designed to be used to simulate stop orders placed at the exchange or simulated by the brokerage Please read this how such stops operate: http://www.interactivebrokers.com/en/trading/orders/stop.php?ib_entity=uk http://www.interactivebrokers.com/en/trading/orders/trailingStops.php?ib_entity=uk | 
The ApplyStop function is used in the following formulas in AFL on-line library:
See updated/extended version on-line.