![]() |
|
|||||||
| Miscellaneous Support Miscellaneous support issues. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#31 |
|
Senior Member
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
|
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? |
|
|
|
|
|
#32 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#33 |
|
Senior Member
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
|
|
|
|
|
|
|
#34 | |
|
Senior Member
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
|
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) );
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:
Last edited by Harry; 05-23-2011 at 06:31 PM.
|
|
|
|
|
|
|
#35 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#36 | |
|
Senior Member
Join Date: Oct 2007
Posts: 1,864
Thanks: 17
Thanked 100 times in 82 posts
|
Quote:
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. |
|
|
|
|
|
|
#37 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#38 |
|
Junior Member
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
|
i ran into similar problem. Let me cut long problem in short , i am seeking correct use of
Code:
this.LastBarIndexPainted say , in my indicator i Add a data series like Code:
protected override void Initialize()
{
Overlay = true;
Add(PeriodType.Minute,15);
}
Code:
if(BarsInProgress == 0)
{
rmb_index0 = CurrentBars[0] - this.LastBarIndexPainted;
Print(rmb_index0);
}
Code:
if(BarsInProgress == 1)
{
rmb_index1 = CurrentBars[1] - this.LastBarIndexPainted;
Print(rmb_index1);
}
|
|
|
|
|
|
#39 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#40 |
|
Junior Member
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#41 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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)];
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#42 |
|
Junior Member
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
|
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));
}
|
|
|
|
|
|
#43 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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());
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Joydeep for this post: |
|
|
|
#44 |
|
Junior Member
Join Date: Feb 2010
Posts: 13
Thanks: 1
Thanked 1 time in 1 post
|
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. |
|
|
|
|
The following user says thank you to devdas for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |