May 23, 2012 08:02
A-Z Index | Category Index |
ApplyStop
- apply built-in stopTrading system toolbox
(AFL 1.7)
SYNTAX ApplyStop( type, mode, amount, exitatstop, volatile = False, ReEntryDelay = 0 )
RETURNSnothing
FUNCTION controls built-in stops from the formula level (allows optimization of stops)
Parameters:
type =
0 = stopTypeLoss - maximum loss stop,
1 = stopTypeProfit - profit target stop,
2 = stopTypeTrailing - trailing stop,
3 = stopTypeNBar - N-bar stop
mode =
0 - disable stop (stopModeDisable),
1 - amount in percent (stopModePercent), or number of bars for N-bar stop (stopModeBars),
2 - amount in points (stopModePoint);
3 - amount in percent of profit (risk)
amount =
percent/point loss/profit trigger/risk amount.
This could be a number (static stop level) or an array (dynamic stop level)
ExitAtStop
ExitAtStop = 0 - means check stops using only trade price and exit at regular trade price(1)
(if you are trading on close it means that only close price will be checked for exits and exit will be done at close price)
ExitAtStop = 1 - check High-Low prices and exit intraday on price equal to stop level on the same bar when stop was triggered
ExitAtStop = 2 - check High-Low prices but exit NEXT BAR on regular trade price.
volatile -
decides if amount (or distance) (3rd parameter) is sampled at the trade entry and remains fixed during the trade (Volatile = FALSE - old behaviour) or if can vary during the trade (Volatile = TRUE) (allows single line Chandelier exit implementation)(2)
ReEntryDelay -
how many bars to wait till entering the same stock is allowed.
Note on using stops:
Scenario 1:
you trade on next bar OPEN and want to exit intraday on stop price
Correct settings:
ActivateStopsImmediately turned O
applystop