I am having some real problems with the Date object. I am trying to print a red circle where my I have placed a trade. In this case at the price of 1290.5 at 12:36:13 on 23rd February 2006. The debug values I get are completely different to my dates and the trade plotted on the chart is completely different to my debug and input dates. Please help!!
Here is my code.
The output I get is this
and the output to screen i get is this
Here is my code.
PHP Code:
/*
Place trades on chart
*/
function preMain()
{
setPriceStudy(true);
setStudyTitle("Trades");
setComputeOnClose();
debugClear();
}
function main()
{
//print trade on 23rd February 2006 at 12:36:13 at a price of 1290.5
tradeBar(2006,2,23,12,36,13,1290.5);
}
var a=0;
function tradeBar(y,m,d,h,m,s,price)
{
var tradeDate = new Date(y,m-1,d,h,m,s);
if (a==0)
{
debugPrintRawtime(tradeDate,"trade");
a=1;
}
var tradeTime = tradeDate.getTime()/1000;
var prevBarTime = getValue("rawtime",-1);
var thisBarTime = getValue("rawtime",0);
if (tradeTime >= prevBarTime && tradeTime < thisBarTime)
{
var prevBarDate = new Date(prevBarTime);
var thisBarDate = new Date(thisBarTime);
debugPrintRawtime(prevBarDate,"prev bar");
debugPrintRawtime(thisBarDate,"this bar");
drawShapeRelative(-1,price,Shape.CIRCLE,null,Color.red,Shape.BOTTOM | Shape.ONTOP,"trade");
}
}
function debugPrintRawtime(rt, text)
{
debugPrint(rt.getFullYear() + "/" + rt.getMonth() + "/" + rt.getDate() + " - " +
rt.getHours() + ":" + rt.getMinutes() + ":" + rt.getSeconds() + " - " + text +"\n");
}
and the output to screen i get is this
Comment