View Full Version : Time[x] wrong
Lost Trader
08-10-2010, 06:23 PM
OK, this test case is built off the Test1-3 from the earlier thread Closes[1].
It still takes as input a variable BIP which tells it to calculate signals on BIP=1 or BIP=0. You can see from the chart that the indicator is set to BIP = 1 to use the internal bar series (5*25V).
In this one, I am saving points of change, and then looking for Div/Conv to draw.
If you look in the code, you see that the XPoint values are saved by
oetsiLL.Set(eTSI[i], b0-i, Time[b0-i]); // WRONG
histLL.Set(HIST[xh],b0-xh,Time[b0-xh]); // CORRECT
minorHH.Set(Highs[x][xm],bx-xm,Time[bx-xm]); // CORRECT
i, xh, xm are all barsago. b0 = CurrentBars[0] and bx=CurrentBars[x=1].
The attached snapshot shows the printout as well as the Data Box. minor & hist are both correct, even though they are on different bar series. etsi is wrong. Oddly, the bar = b0-i is CORRECT, but the Time[b0-i] is that of the very first bar on the chart CurrentBars[0]==0.
Since, in a multi-bar series, one must use Time to draw the DC line correctly, I need Time[] to assign the values correctly.
Is there a flavor of Time that specifies Bar series? If not, there needs to be one.
NinjaTrader_Bertrand
08-11-2010, 06:42 AM
LostTrader, in a MultiSeries context you can use Times[x][x] to access the timestamps of the added bars objects -
http://www.ninjatrader.com/support/helpGuides/nt7/times.htm
Would that help fix the erroneous timestamp return you ran into?
Lost Trader
08-11-2010, 08:56 AM
Nope, it does not....
oetsiHH.Set(eTSI[i], b0-i, Times[0][b0-i]);
same failure. The recorded bar is correct but the Time is that of the very first bar on the chart. The other two recorded Times are correct, as they were before.
Perhaps I should have said, in addition to existing, it also needs to work? :D
I find it odd that it is (one of) the BIP=0 ones that is failing, Not all, just some.
NinjaTrader_Bertrand
08-11-2010, 10:29 AM
I would agree lostTrader, that seems odd - best would be to strip down the indicator and print out all related parts of this one call giving you issues to be able to iron out where this stems from.
Lost Trader
08-11-2010, 11:15 AM
It "stems" from a problem in Ninjatrader's Time function.
Don't you guys even care?
NinjaTrader_Austin
08-11-2010, 03:11 PM
Lost Trader, it is very difficult to find exactly where an issue stems from in a 400+ line indicator. If you can provide us with a stripped down indicator that exhibits this behavior, we'll gladly take a look.
Lost Trader
08-11-2010, 04:36 PM
Austin, it certainly is not the beta tester's responsibility to debug the code for development. Particularly since beta testing for you is a volunteer job.
I gave you the test case. I told you exactly which line in the test case.
The fact that y'all are unwilling to do the job does explain why NT7 is so buggy.
NinjaTrader_Bertrand
08-12-2010, 06:17 AM
LostTrader, I agree with you that betatesters should not debug NT's code, but here we're dealing with your custom indicator code which is not stripped down to it's maximum - to provide a simple test as working basis, please test my script attached on your 25 Vol chart, it will add the 125 Vol one and print BIP, CurrentBars and Time of the respective bars object to your output window. Doing so, please let me know where you see the Time() method returning you an unexpected value, testing on my ES ZenFire chart I seem to get all prints as expected.
Thanks
Lost Trader
08-12-2010, 10:17 AM
Bertrand, I looked at your test case and even ran it. Of course, it better work correctly. If you look at Test4, you will notice that NONE of the Print("Time[0]"); stmts ever failed.
The problem only occurred when saving the previous Time[# > 0] in a DateTime variable and then only sometimes. I improved your test case below. It fails. When you know why, please let me know.
Thank you.
P.S. I think you meant "down to its minimum" :D
NinjaTrader_Bertrand
08-12-2010, 10:55 AM
Ok, thanks for the snippet - I printed the DateTime's you save to your DateTime variable t, they all print correct, next I printed the CurrentBars you access from the primary series for both series, they also seem correct.
After looking at your code I rather believe the issue is in your XPoint custom class from where the false time prints originate from, the first (t from your OnBarUpdate() ) is correct, the Time one from the helper class not, so I suggest to focus on this to debug your indicator.
Lost Trader
08-12-2010, 02:37 PM
No, it isn't in the XPoint class. Been using it for years in v6.5 which prompted me to go back and check.
Sigh. I printed out the Times[x][bx-i] and it was wrong before the .Set -- then I realized that Time uses barsago and it should be written Times[x][i]. When Test4 was corrected, it works now. That also explains why it was inconsistent - new high/low updates always used current time - no mistakes there.
I hate it when I make stupid mistakes and that does seem to be one of my more common ones. :o