Close
Skip to content

Program 13 | ‘Pivot – limit’ Strategy

Program 13 is a TradeStation EasyLanguage strategy developed in version 8.7 and is compatible with newer versions (including version 10). It uses a setup which looks for a pivot, a price retracement beyond the pivot value and then generates a limit order.In the ‘short’ setup we look for a high pivot, for the price to dip down, then rise above the pivot level for a limit order to be placed next bar (you can also define filters to further restrict when a trade is placed.) The long setup requires a low pivot, followed by a lower low for a long limit order to be placed next bar (again, you can define filters to further restrict when trades are placed).

In program 13 IntrabarOrderGeneration is set to False.

The following chart shows an example. Please note that the the screen shots included on this site are examples and are not meant to imply that this program will generate profitable trades. THE STRATEGY HAS BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

Pivot-limit strategy applied to S&P E-mini
Program 13 applied to a 5 minute @ES chart.

Pivot-limit strategy applied to S&P E-mini
An annotated close up of program 13 applied to a 5 minute @ES chart. Text annotations were added using Photoshop.

The trades in this strategy described in more detail

Short trades

Based on the ‘pivot-limit’ pattern, to initiate a short entry order the program looks for a high pivot, if found, a counter is started and incremented by one every bar. It then searches for a higher high than the pivot high and if found within a user defined number of bars following the discovery of the high pivot, a sell short limit order is placed at the level of the first pivot high on the next bar (subject to any user defined filters also being true).

Long trades

To initiate a long trade program 13 searches for a low pivot, once found a counter is started (which is incremented by one every bar.) The program then searches for a low below the pivot level and then looks for price to retrace and cross the level of the initial low pivot. If this occurs a condition is set to true and a buy limit order at the level of the initial low pivot is placed on the next bar, provided the counter is under a user input value and any user defined filters also being true.

I explain the strategy in more detail in the video below.

THE STRATEGY HAS BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

The unprotected (i.e. you can view and modify the EasyLanguage) program may be downloaded by clicking the following button.

YOU MAY PAY BY CREDIT CARD OR PAYPAL. YOU DO NOT NEED TO HAVE OR OPEN A PAYPAL ACCOUNT TO MAKE A PAYMENT.

The following is an example of the setup needed to generate long trades:

Example of long trade applied to S&P E-mini
Long trades generated when program 13 applied to a 5 minute e-mini chart.

The above screen shot shows that the conditions were fulfilled to enter a long trade. Notice that in this case we initially do not enter the trade because we are short, however when the short trade is covered the program checks to see that the long counter is still under a user input amount and enters a long trade.

User Defined Filters

One of the keys to using this program is to define filters within the program.

The default filters are set up as follows:

LongFilter1 = TRUE;
LongFilter2 = TRUE;
LongFilter3 = TRUE;

// Short filters
ShortFilter1 = TRUE;
ShortFilter2 = TRUE;
ShortFilter3 = TRUE;

With these settings, they don’t have any effect.

If you wanted to create a stochastic filter you would need to modify the code as follows:

// Long filters
// Stochastic variables
Vars: oFastK( 0 ), // Variable for Multiple Output Function for Stochastic function
oFastD( 0 ), // Variable for Multiple Output Function for Stochastic function
oSlowK( 0 ), // Variable for Multiple Output Function for Stochastic function
oSlowD( 0 ); // Variable for Multiple Output Function for Stochastic function

Value1 = Stochastic( H, L, C, 10, 3, 3, 1, oFastK, oFastD, oSlowK, oSlowD ) ;
LongFilter1 = oSlowk < 25; LongFilter2 = TRUE; LongFilter3 = TRUE; // Short filters ShortFilter1 = oSlowk > 75;
ShortFilter2 = TRUE;
ShortFilter3 = TRUE;

In other words, LongFilter1 is TRUE if oSlowk is less than 25 and ShortFilter1 is TRUE if oSlowk is greater than 75.

Say you wanted to add an additional CCI filter, for example to filter trades such that we would only go long if the candlestick pattern must have occurred within MaxAfterCandle bars, any other conditions set evaluate to TRUE, and the CCI is less than -150 then you would need to add the following code:

Value2 = CCI( 14 );
LongFilter2 = Value2 < -150;

To learn more about creating filters visit: Tutorial 53 | Creating strategy filters

User Inputs

LeftStrength( 3 ), // Used to define left pivot strength
RightStrength( 3 ), // Used to define right pivot strength
NumBars( 12 ), // Counter must be less than this number to generate trade
Cts( 10 ), // Number of contracts to be traded
TrailVal( 54 ), // Trail value – expressed as multiple of minimum price move
Tgt1( 10 ), // First target – expressed as multiple of minimum price move (i.e. Target1 = Tgt1 * MinMove / PriceScale)
Tgt2( 5 ), // Second target – incremental to the first target (i.e. Target2 = Tgt2 * MinMove / PriceScale + Target1)
FirstTgtCts( 8 ), // The number of contracts to be taken off at first target
ShowLines( true); // If set to TRUE trailing stop lines are drawn

See a video demonstration below.

The unprotected (i.e. you can view and modify the EasyLanguage) program may be downloaded by clicking the following button.

YOU MAY PAY BY CREDIT CARD OR PAYPAL. YOU DO NOT NEED TO HAVE OR OPEN A PAYPAL ACCOUNT TO MAKE A PAYMENT.

The program was developed for TradeStation 8.7 and later versions and works on intraday, daily, weekly, and monthly charts. The strategy may be applied to tick charts, but the trailing stop line and pivot lines may not display correctly due to an EasyLanguage limitation.

Video demonstration of Program 13

The unprotected (i.e. you can view and modify the EasyLanguage) program may be downloaded by clicking the following button.

YOU MAY PAY BY CREDIT CARD OR PAYPAL. YOU DO NOT NEED TO HAVE OR OPEN A PAYPAL ACCOUNT TO MAKE A PAYMENT.

Please email any bugs that you may discover to support@markplex.com.

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, 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.