Infront Portfolio Manager

Define limit strategies

Module "Advanced Technical Analysis"

To define a limit scheme, the "Limit" parameter is used to pass a function (an anonymous macro) that is to make the decision on whether to exit a trading position. This function has the following parameters:

  • Security: the evaluated security.

  • Long(Boolean): Indicates whether the position is long ("True") or short ("False").

  • EntryPrice(NumberWithTime): Entry price and date (i.e. the security price on the day following the signal).

  • CurrentPrice(NumberWithTime): current exit price with date.

The function should return a Boolean as the result, "True" means "Limit exit". The limit function is evaluated from the entry point of a trading phase for each subsequent price (on a daily basis) until it returns "True" (or other signals end the trading phase).

Beispiel 1

#$[$Long;$EntryPrice;$CurrentPrice](
if($Long;
$CurrentPrice<$EntryPrice*(1-$Losslimit);
$CurrentPrice>$EntryPrice*(1+$Losslimit))
)

This function tests whether the price has fallen below the entry price minus a configurable percentage($LossLimit) (nontrailing loss). The evaluation must be mirrored for short positions.


Beispiel 2

$TrailEntry:= -1;
$LimitFunction:=
#[$Long;$EntryPrice;$CurrentPrice](
$TrailEntry:=if($TrailEntry<0;$EntryPrice;$TrailEntry);
$TrailEntry:=if($Long;
Max($TrailEntry;$CurrentPrice);
Min($TrailEntry;$CurrentPrice));
if($Long;
$CurrentPrice<$TrailEntry*(1-$Losslimit);
$CurrentPrice>$TrailEntry*(1+$Losslimit))
)

This is a simulation of the trailing loss using a limit function. In the variable $TrailEntry variable, the entry price is tracked and adjusted according to the current prices during the limit evaluation.