NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support

Miscellaneous Support Miscellaneous support issues.

Reply
 
Thread Tools Display Modes
Old 05-17-2011, 06:41 AM   #31
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
Default

Hi Josh,

just to make sure that I understood everything, I have modified the default pivot indicator of NinjaTrader. Modifications are lines 120, 140, 331 and 337 (comments added).

Could you confirm that the code works correctly?
Attached Files
File Type: zip PivotsTest.zip (5.7 KB, 6 views)
Harry is offline  
Reply With Quote
Old 05-17-2011, 08:17 AM   #32
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Harry,

Quick glance over looks like you used it correctly. I cannot guarantee you the code changes definitively work because I have not extensively tested it, but I do not suspect issues.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-17-2011, 10:55 AM   #33
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
Default

Thanks for your answer, tested here, seems to work.

Quote:
Originally Posted by NinjaTrader_Josh View Post
Harry,

Quick glance over looks like you used it correctly. I cannot guarantee you the code changes definitively work because I have not extensively tested it, but I do not suspect issues.
Harry is offline  
Reply With Quote
Old 05-23-2011, 06:23 PM   #34
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
Default Problem with CurrentBar in PlotOverride

Hi Josh,

used the code snippets as you suggested, and at first glance it seemed to work, but then I ran into problems, see logs attached. Problem is that the integer diff came out negative, and the indicator plotted nothing,

Code:
int index = CurrentBar - Math.Min(Bars.Count - 1, this.LastBarIndexPainted);
Bars.Session.GetNextBeginEnd(Bars, index, out lastBarSessionBegin, out lastBarSessionEnd);            
Print(""+ index +", " + CurrentBar + ", " + this.LastBarIndexPainted );
Print(""+ index +", " + CurrentBar + ", " + (Bars.Count-1) );
which showed:

CurrentBar = 1
LastBarIndexPainted = 9460
Index = CurrentBar - LastBarIndexPainted = -9459;

Bars.Session.GetNextBeginEnd() did not accept a negative value for barsAgo. which created the error message. So the real problem here is that CurrentBar should have returned a value of 9461, but returned a value of 1 within PlotOverride.

Excerpt from output file (repeated adding of indicator via F5

Quote:
1, 9461, 9460 correct for (index, CurrentBar, this.LastBarIndexPainted)
1, 9461, 12534 correct for (index, CurrentBar, Bars.Count-1) // this is required for non-equidistant spacing
-9459, 1, 9460 false for (index, CurrentBar, this.LastBarIndexPainted)
-9459, 1, 12534 false for (index, CurrentBar, Bars.Count-1)
1, 9461, 9460
1, 9461, 12534
Attached Images
File Type: png Error Log.PNG (22.2 KB, 4 views)
Last edited by Harry; 05-23-2011 at 06:31 PM.
Harry is offline  
Reply With Quote
Old 05-24-2011, 08:11 AM   #35
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Harry,

Where is your chart scrolled to? I am not following your comment about Bars.Count required for non-equidistant charts. I will need information on how exactly you have your chart setup and when exactly you get which prints. Multi-series charts? Thank you.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-24-2011, 08:29 AM   #36
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
Harry,

Where is your chart scrolled to? I am not following your comment about Bars.Count required for non-equidistant charts. I will need information on how exactly you have your chart setup and when exactly you get which prints. Multi-series charts? Thank you.
Hi Josh,

I have observed the exceptions with both multi-series charts and single series charts. The exceptions are not related to Non-Equidistant Spacing, but simply to CurrentBar returning negative values in PlotOverride().

To observe the problem, you only need to put the two attached indicators (anaPivotsDailyV32 and anaPivotsDailyV32b) on a chart, best use a multi-series chart and add them to the upper and lower panel. Then toggle between instruments until an exception is thrown.

The exception is caused

-> by lines 1341+1342 (anaPivotsDailyV32)
-> by lines 1342-1345 (anaPivotsDailyV32b)

anaPivotsDailyV33 does not throw any exceptions, as I used the old signature of GetNextBeginEnd() in Plot() Override. So the immediate problem is solved for me now, when I use the new signature in OnBarUpdate() and the old signature in Plot().

I could only demonstrate with inserting Print() instructions that the problem is caused by CurrentBar taking negative values, so it could be another serious NinjaTrader bug.
Attached Files
File Type: zip anaPivotsDailyV32.zip (19.7 KB, 2 views)
File Type: zip SessionPivotsV33.zip (49.4 KB, 2 views)
Harry is offline  
Reply With Quote
Old 05-24-2011, 11:30 AM   #37
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Harry,

Let's try this. Can you run this script and see if you ever run into CurrentBar = 1 besides when you are on the very beginning of the chart? I have not been able to achieve that with this 100% basic setup. If we are able to establish this base scenario than I would suspect there to be something up with something in the Plot() logic you used on top of this basic setup causing the issue. That would be where we would need to look next.
Attached Files
File Type: zip PlotOverrideTest.zip (1.8 KB, 6 views)
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-06-2013, 01:43 PM   #38
devdas
Junior Member
 
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
Default

i ran into similar problem. Let me cut long problem in short , i am seeking correct use of

Code:
this.LastBarIndexPainted
when i have more than one data series.


say , in my indicator i Add a data series like

Code:
protected override void Initialize()
        {
            Overlay				= true;
	    Add(PeriodType.Minute,15);
        }
This indi is applied on 5 minute single series chart. Now following code works fine for primary data series ( that is 5 minute )

Code:
if(BarsInProgress == 0)
			{
			rmb_index0 = CurrentBars[0] - this.LastBarIndexPainted;
			Print(rmb_index0);
			}
now how can i get correct values for added series ( 15 minute ) ? following code returns wrong and negative values as this.LastBarIndexPainted references primary data series.

Code:
if(BarsInProgress == 1)
			{
			rmb_index1 = CurrentBars[1] - this.LastBarIndexPainted;
			Print(rmb_index1);
			}
devdas is offline  
Reply With Quote
Old 01-07-2013, 04:50 AM   #39
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello devdas,
Yes, LastBarIndexPainted will refer to the primary instrument only.

You may refer to the unsupported ChartControl.LastBarTimePainted (which returns a DateTime) and then further custom code it to get the correct bar number using the GetBar method.
http://www.ninjatrader.com/support/h...tml?getbar.htm
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 01-07-2013, 11:25 AM   #40
devdas
Junior Member
 
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
Default

Hi Joydeep,

i think this is deprecated now.

code

Code:
Print(this.ChartControl.LastBarTimePainted.ToString());

is returning "1/1/1800 12:00:00 AM" for every bar.

Hope im not doing anything wrong.
Can you check at your end or suggest correct snippets for this.
devdas is offline  
Reply With Quote
Old 01-07-2013, 11:45 AM   #41
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello devdas,
If you try using the below code to get the datetime of the last bar painted and then calculate the bar number of the secondary data series using the GetBar method.

Code:
DateTime time = Time[Math.Min(CurrentBar, this.LastVisibleBar)];
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 01-07-2013, 12:06 PM   #42
devdas
Junior Member
 
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
Default

It worked only on single series....but with secondary added series its just printing CurrentBars[1] value of last bar on ecah bar.

Code:
 if(BarsInProgress == 1)
			{
			DateTime time = Time[Math.Min(CurrentBar, this.LastVisibleBar)];
			Print(BarsArray[1].GetBar(time));
			}
Please confirm its not possible for more than 1 series , so i should tweak my indicator for single series.
devdas is offline  
Reply With Quote
Old 01-07-2013, 12:55 PM   #43
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello devdas,
If you try the below code and then scroll back on history then what prints are you getting.

Code:
if (this.BarsInProgress != 0) return;
DateTime time = Time[Math.Min(CurrentBar, this.LastBarIndexPainted + 1)];
int i = BarsArray[1].GetBar(time);
Print("CurrentBars 1 = " + CurrentBars[1].ToString() + " Corrosponding secondary bar " + (CurrentBars[1] - i).ToString());
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Old 01-08-2013, 10:41 AM   #44
devdas
Junior Member
 
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
Default

Hi Joydeep,

thanx very much for your time and appreciate your help.
though i hv taken alternate approach with single series , but your code worked and from initial test i think i can give a try latter. I have yet to test deeply as its not very easy or may be something different behavior may result if primary data series period > secondary data series period.
But thanx again.
devdas is offline  
Reply With Quote
The following user says thank you to devdas for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
time / ticks until bar close counter Duval Suggestions And Feedback 7 10-04-2011 03:33 PM
Tick Chart - Yesterday's Time Stamps all set to 00:00:00 mjc4118 Version 7 Beta General Questions & Bug Reports 2 12-23-2009 09:54 AM
tick counter/time and sales lindsayf Charting 2 08-08-2009 04:27 PM
Time Bar Counter GussJ Indicator Development 3 10-27-2008 10:53 AM
Time stamps, tick filtering & throttling ??? dymund13 Charting 6 06-02-2008 10:47 PM


All times are GMT -6. The time now is 05:26 AM.