# STOP & TSTOP Function

You are here:

The STOP or TSTOP function allows the user to easily set a cut loss or take profit signal that are based on your bought or trailing price. The syntax for both functions are the same but is computed differently:

STOP(Source, Gain/Loss, Buy Signal, Sell Signal)

Source: Where the loss or gain computation is based on, example Close
Gain/Loss: Should be in decimal form, example -5% should be written as -0.05
Sell Signal: Should be based on the strategy’s sell signal variable

The STOP function is based on your purchase price. Meaning if you set a -5% stop loss from the closing price of the purchase day and it will stay there until it resets. You can also use STOP to target a percentage return by using a positive number; 0.15 would mean a sell will trigger once you gain 15% from purchase.

Computation of STOP as a cut loss function:
Closing Price : 100
STOP Loss Percent: -.05
STOP Loss Price: 95

Syntax:
TSTOP(Source, Loss, Buy Signal, Sell Signal)
The TSTOP function is trailing and will be based on the latest and highest price. The TSTOP should always be a negative number.
TSTOP Loss Percent: -0.5

Example Script:
//Buy when RSI crosses 30 and sell if RSI crosses below 70. Cut loss of 5% from the close of the buy signal.
Set RSI = RSI(close,14)