Using LastCalcDateTime
When a TradeStation EasyLanguage program is applied to a chart (or its status changed from ‘off’ to ‘on’) it run on each bar of the chart after maxbarsback (and ticks, depending on type of chart, program applied and whether the bar is historic or real time) from first to last.
This quick-tip show how, when the program runs on the FIRST bar after MaxBarsBack, to find the date, time, and datetime of the last bar on the chart.
EasyLanguage code
Once Begin Clearprintlog; Print( "BarType ",BarType:0:0," Bar DateTime ", BarDateTime.Format( "%m/%d/%Y %H:%M:%S " ) ); Print( " Bar Number ",BarNumber, " MaxBarsBack ", MaxBarsBack ); Print( " ***** LastCalcDate ",LastCalcDate, " LastCalcTime ", LastCalcTime, " LastCalcDateTime " ); Print( LastCalcDateTime.Format( "%m/%d/%Y %I:%M:%S %p " ) ); End;