Jumat, 04 September 2009

Code Snippet - EOD Data

On the weekends many traders are looking over charts, some only do it on the weekends. They might place orders based on the charts they view. No matter what type of order you use, if you are using daily data, you may have noticed that sometimes you don't get all the current data for every symbol. Murphy's law says that the stock you interested in will be the one that is missing one days worth of quotes. A couple of times I have almost placed an order based on old data, but noticed something wasn't right when I logged into the trading software and noticed the last price was different. I wrote this piece of code to show up in the title when the last daily bar isn't the same as today's day. The code also considers Saturday and Sunday.


DownloadDate = LastValue(DateNum());
TodayDate = Now(3);
if(Now(9)== 7) DownloadDate = DownloadDate + 1;
if(Now(9)== 0) DownloadDate = DownloadDate + 2;
if(LastValue(DownloadDate) != TodayDate)
BarDateError = " *WARNING: Data NOT Current*";
else
BarDateError ="";


My title bar uses this code, which is where the value BarDateError is displayed.


Title = EncodeColor(colorLightBlue) + Name() + " " + FullName() +
EncodeColor(colorLightBlue) + " - " + Date() +
EncodeColor(colorBlue) + " O=" + O +
EncodeColor(colorLime) + " H=" + H +
EncodeColor(colorRed) +" L=" + L +
EncodeColor(colorBlue) + " C=" + C +
EncodeColor(colorYellow) + " ATR: " + Prec(ATR(6),4) + EncodeColor(colorWhite) +
" " + BarDateError;



Hope this helps you reduce errors, trading is hard enough without having to deal with oversights.
Related Posts Plugin for WordPress, Blogger...