Some things as simple as identifying new day might be complex for a new AFL programmer. Following is the Amibroker Formula Language snippet for identifying new day. If your backtesting or trading system requires identifying new day and then use this information further for other analysis , then you can use this block of code after testing it for accuracy.
//The following piece of code used to check for new day dnArr = DateNum(); newDay = dnArr != Ref( dnArr, -1);
DateNum() function returns an array with a value representing a number for each day. The number is calculated based on formulae :
10000 * (year - 1900) + 100 * month + day
Today’s date is : Dec 04, 2015
Calculation -> 10000 * (2014 - 1900) + 100 * 12 + 4 = 1,141,204.000
And value for yesterday ( Dec 03, 2015 ) would be 1,141,203.000.
If you are using 1 minute bar interval, then the value of “dnArr” for the first bar of the day would be 1 and all other would be 0.
Please note that above piece of code is for only informational purpose and you need to personally validate and test it before using it