Skip to content

Quick-tip 13 | How to detect the first tick of a bar

This quick tip demonstrates how to recognize the first tick of a TradeStation bar using the EasyLanguage BarStatus keyword.

EasyLanguage first tick strategy video

Quick-tips 13 strategy

{ THIS STRATEGY 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 NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION IS AT YOUR OWN RISK.
THIS STRATEGY AND ASSOCIATED TECHNIQUES IS AN EXAMPLE ONLY, AND HAS BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION DOES NOT RECOMMEND
THAT YOU USE ANY SUCH TRADING STRATEGIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS
(OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF THIS STRATEGY DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.}

{ This reserved word will return one of four possible values:

2 = the closing tick of a bar
1 = a tick within a bar
0 = the opening tick of a bar (relevant only for strategies using Open Next Bar order actions)
-1 = an error occurred while executing the reserved word }

[Intrabarordergeneration = TRUE]

Var: Intrabarpersist Int BarStatusLT( -2 );

Once ClearPrintLog;

{If BarStatus( 1 ) = 0 then }Print( "Bar Number ",BarNumber," Bar DateTime ",BarDateTime.Format( "%m/%d/%Y %H:%M:%S " ),
" BarStatus ", BarStatus( 1 )," BarStatusLT ", BarStatusLT, " Close ", C:5:5 );

BarStatusLT = BarStatus( 1 );

// buy ("LongEntry") 4 contracts next bar at open next bar Limit;

{ ** Copyright (c) 2017 Markplex Corporation. All rights reserved. **
** Markplex Corporation reserves the right to modify or overwrite this analysis technique
on its http://markplex.com Web site. ** }