Skip to content

Quick-tip 43 | Draw a line at the SetPercentTrailing level

Quick-tip43-1

Draw the SetPercentTrailing level

Quick-tip 43 demonstrates how to calculate and draw a line at the trailing stop loss level when using the TradeStation function: SetPercentTrailing.

This quick-tip program does not take the Commission and Slippage settings into account when calculating and drawing the trailing stop level. Quick tip 43 assumes that SetPercentTrailing is being used on a SetStopPosition basis.

Also see tutorial 80 which looks at using SetDollarTrailing.

SetPercentTrailing is a built-in stop reserved word is used to specify the amount of the maximum open position profit you are willing to lose (as a percent) as well as the profit level that must be reached in order for the stop to take effect. The position is closed out when the specified percentage of the maximum profit is lost.

The reserved word is called using: SetPercentTrailing( FloorAmnt, Amount ); where FloorAmnt is the profit level that must be reached in order for the stop to take effect and Amount is the amount of the maximum open position profit you are willing to lose (as a percent).

Quick-tip 43 applied to a 5 minute @ES chart

Notes on the calculation

OpenPositionProfit returns the current gain or loss of the current open position. CurrentContracts returns the number of contracts in the current position BigPointValue returns the market value of a whole number price move for the share or contract price of a particular symbol.

An exit will occur when
OpenPositionProfit = MaxProfit( 1 – PercAmount / 100 )
provided the FloorAmt of profit has been reached

Imagine an ‘imaginary entry price’, iEP (not taking commission or slippage into account)
OpenPositionProfit will be equal to iEP – price at the moment multiplied by CurrentContracts multiplied by BigPointValue.
i.e. OpenPositionProfit = ( iEP – Close ) * ( CurrentContracts * BigPointValue )
re-arranging the formula
iEP = Close + OpenPositionProfit / ( CurrentContracts * BigPointValue )

So at the stop level (STrl2) we can substitute OpenPositionProfit into
OpenPositionProfit = MaxProfit( 1 – PercAmount / 100 )
we get ( iEP – STrl2 ) * ( CurrentContracts * BigPointValue ) = MaxProfit( 1 – PercAmount / 100 )
where the stop (STrl2) is located. Re-arranging the formula
( iEP – STrl2 ) = MaxProfit( 1 – PercAmount / 100 ) / ( CurrentContracts * BigPointValue )
and STrl2 = iEP – MaxProfit( 1 – PercAmount / 100 ) / ( CurrentContracts * BigPointValue )

Video explanation

This content is for members only.

THE TRADING APPS, INDICATORS, SHOW ME STUDIES, STRATEGIES AND OTHER PROGRAMS HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

TO THE BEST OF MARKPLEX CORPORATION’S KNOWLEDGE, ALL OF THE INFORMATION ON THIS PAGE IS CORRECT, AND IT IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION AND/OR PROGRAM(S) DESCRIBED, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION AND/OR PROGRAMS DESCRIBED IS AT YOUR OWN RISK.

ANY EASYLANGUAGE OR POWERLANGUAGE TRADING STRATEGIES, TRADING APPS, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (AND PARTS THEREOF) AND ASSOCIATED TECHNIQUES REFERRED TO, INCLUDED IN OR ATTACHED TO THIS TUTORIAL OR PROGRAM DESCRIPTION ARE EXAMPLES ONLY, AND HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION. DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS AND TECHNIQUES DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.