Yesterday and Today

Top  Previous  Next

 

One of the most important issues to understand when working with Mechanica Basic is how to envision the concepts of yesterday and today.

It is CRITICAL to understand Mechanicas time-orientation. It can mean the difference between developing a faulty system that promises wonderfulbut falseresults, and developing a solid system that can actually be traded in the real-world.

Today centric orientation

Mechanica is today-centric in its time orientation. This means that you will always trade today, based on something that happened in the past.

Some backtesting software works from the viewpoint of taking action tomorrow. Mechanica does not; it looks at the world from the viewpoint of a trader sitting at his or her desk at 6:00 AM, waiting for the markets to open. Again, this is a today-centric orientation.

Since trades do not take place on a future date, there is really no concept of tomorrow in Mechanica. In fact, it is impossible to even accidentally refer to a future date in Mechanica, though we can refer to the trading session in the future on the same date.

 

Understanding yesterday and today

Whether processing historical or current market data, Mechanica does not consult your PC's system clock to verify dates. Rather, it takes the most recent day of data and simply calls it yesterday.

For example, lets say that todays date is 6/4/2002. Then yesterday, to Mechanica, might be:

2/9/1997 ...if youre testing historical data and Mechanicas Resources Page is currently processing data for the date 2/10/1997. Thus, to Mechanica, today is 2/10/1997. (This date will display in the grid as 19970210)

Using the same premise as above, if todays date is 6/4/2002, then yesterday to Mechanica could be:

6/4/2002  ...once your end-of-day data for 6/4/2002 is downloaded and processed.

Again, Mechanica simply takes your most recent day of data and calls it yesterday.

If, in real-world trading, you get your end-of-day data at 4:59 PM on 6/4/2002, then it immediately becomes yesterday's data, and remains yesterdays data until the completion of trading the next day, 6/5/2002.

So, Mechanica makes trades today based upon information that was available at or before the close of yesterday.

 

Offset (look back) notation

In Mechanica the notation “[1]” always means yesterday, when used in conjunction with a price keyword such as CLOSE, or in association with a column number.

Consider again the point of view of a trader sitting at his or her desk at 6:00 AM Tuesday morning, waiting for the markets to open:

CLOSE[1]         'returns the value of Mondays closing price 

CLOSE[2]         'returns the value of last Fridays closing price 

COL4[1]         'returns Mondays value of COL4 

 

Of course, the same holds true if the same trader is sitting at his or her desk Monday night, after Mondays end-of-day data has been loaded.

The screen shot below demonstrates the effect. The closing price for 19980106 (01/06/1998) is shown in COL1 with no offset (look back).

COL2 looks back one day. COL3 looks back 2 days (COL3 = CLOSE[2]); thus the data from COL1 for the date 19980106 appears in COL3 two trading days later, on 19980108.