Print statements are commonly used as a debugging aid when code fails to work as expected.  Three functions have been created to add timestamps and additional useful information to each line printed:

FUNCTION

_DateTimeSym

_DateTimeSymBS

_DateTimeSymBSMP

USED IN

All Code

All Code

Strategies Only

ADDS TO PRINT LINE

Date, Time and Symbol Name

Date, Time, Symbol Name and BarStatus(1)

Date, Time, Symbol Name, BarStatus(1), Marketstatus and Barnumber

Usage

One of the above functions is used as a prefix in a debugging print statement as follows:

Print(_DateTimeSymBS, ”      Avg = “, avg, ”   Delta = “, delta);

producing the following output, using weekly bars:

09/17/2021 1500 CSLT BS=2      Avg = 110.95   Delta = 3.45
09/24/2021 1500 CSLT BS=2      Avg = 112.33   Delta = 2.54
10/01/2021 1500 CSLT BS=2      Avg = 114.05   Delta = 1.87

In a strategy, additional information regarding MarketPosition and BarNumber can be obtained using function _DateTimeSymBSMP:

Print(_DateTimeSymBSMP, ”      Avg = “, avg, ”   Delta = “, delta);

producing the following output:

09/17/2021 1500 CSLT BS=2 MP= 0 MP[1]= 0 Bar= 343      Avg = 110.95   Delta = 3.45
09/24/2021 1500 CSLT BS=2 MP= 0 MP[1]= 0 Bar= 344      Avg = 112.33   Delta = 2.54
10/01/2021 1500 CSLT BS=2 MP= 0 MP[1]= 0 Bar= 345      Avg = 114.05   Delta = 1.87

Downloads

Initially posted version:  10/8/21

Latest Update:  10/8/21

*.ELD files are compiled for TS 9.5 here:

_DateTimeSymBS Functions.zip

Users of earlier versions of TradeStation may compile the code
from the text files included in the above *.zip file.

The code may be visualized here:

_DateTimeSym.txt

 _DateTimeSymBS.txt

_DateTimeSymBSMP.txt