Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
indicator jumps around ?
Collapse
X
-
indicator jumps around
The redline indicator shown in the attachments is a function of the previous bar open and close. Those open and close values never change, yet the last segment of the indicator jumps around as shown in the two attachments. Any comments or suggestions will be appreciated.
-
thanks Matthew
the indicator file is attached.
the code which creates the indicator is as follows:
if(BarsPeriod.Id == PeriodType.Day)//for day bars [don't use GetDayBar for day bars]
{
XXCloseyest=((Open[1]+High[1]+Low[1]+Close[1])*0.25);
XXOpen=((XXCloseyest+XXOpenyest)*0.5);
XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest
}Attached Files
Comment
-
Hi Joemiller,
I'm not seeing any errors with the compile and code.
Are you seeing this with all your charts and instruments or just this one in particular?
I see you are using the Print() for your values, are they correct ones being plotted?
What are you setting the Calculate on Bar Close to?Cal H.NinjaTrader Customer Service
Comment
-
Originally posted by joemiller View Postthanks Matthew
the indicator file is attached.
the code which creates the indicator is as follows:
if(BarsPeriod.Id == PeriodType.Day)//for day bars [don't use GetDayBar for day bars]
{
XXCloseyest=((Open[1]+High[1]+Low[1]+Close[1])*0.25);
XXOpen=((XXCloseyest+XXOpenyest)*0.5);
XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest
}That block of code, when you use COBC=false, is effectively a loop, changing the value of XXOpenyest on each tick, and hence also changing the value of XXOpen.Code:XXOpen=((XXCloseyest+XXOpenyest)*0.5); XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest
Remember that OnBarUpdate(), while an event-handler, is at base, a loop construct. We often forget that the whole paradigm of event-driven programing is to process messages in either a loop, or based on an interrupt scheme.
Last edited by koganam; 08-26-2013, 06:40 PM.
Comment
-
damn, I don't have a clue what you said but, no matter, I do think it sounds like I may somehow be able to correct the issue by finding some way to preserve XXOpenyest. because I think I have to Keep COBC = false?
if you guys have any suggestions I will be eternally grateful.
Comment
-
Cal,
forgot to answer your questions.
Are you seeing this with all your charts and instruments or just this one in particular?
ALL CHARTS
I see you are using the Print() for your values, are they correct ones being plotted?
LOOKS LIKE THEY ARE THE SAME ... THE OUTPUT WINDOW KEEPS UPDATEING WITH INCOMING PRICE FEED.
What are you setting the Calculate on Bar Close to?
DIDN'T KNOW I SHOULD SPECIFY ANYTHNG BEYOND COBC = FALSE?Last edited by joemiller; 08-26-2013, 05:51 PM.
Comment
-
Joemiller,
You can set the indicator to calculate on bar close set to true when you first enable the indicator on the chart.
I will agree with Koganam that your variable is most likely getting reset over and over with the indicator set to false, thus causing the indicator to act the way you see it from the screenshots.
Let me know if I can be of further assistanceCal H.NinjaTrader Customer Service
Comment
-
CalculateOnBarClose is set false in the initialize region of the indicator to force last day display of the indicator.
do you mean I should set it to true ... because if I do I think the indictor will not be displayed on the last currently developing bar, which is what I need?
Comment
-
In which case, all you are really saying is that you want your code block to be run only once per bar, even though you are processing every tick. There is more than one way to do that using a bool flag, but NT actually already provides a ready-made flag called FirstTickOfBar, which is just what it says.Originally posted by joemiller View Post
CalculateOnBarClose is set false in the initialize region of the indicator to force last day display of the indicator.
do you mean I should set it to true ... because if I do I think the indictor will not be displayed on the last currently developing bar, which is what I need?
Just encase your block and use FirstTickOfBar as a filter.
Code:[B][SIZE=3][COLOR=#000000][FONT=Calibri]if(BarsPeriod.Id == PeriodType.Day)//for day bars [don't use GetDayBar for day bars] [/FONT][/COLOR][/SIZE][/B] [B][SIZE=3][COLOR=#000000][FONT=Calibri]{[/FONT][/COLOR][/SIZE][/B] [COLOR=Red][B]if (FirstTickOfBar) {[/B][/COLOR] [B][SIZE=3][COLOR=#000000][FONT=Calibri]XXCloseyest=((Open[1]+High[1]+Low[1]+Close[1])*0.25);[/FONT][/COLOR][/SIZE][/B] [B][SIZE=3][COLOR=#000000][FONT=Calibri]XXOpen=((XXCloseyest+XXOpenyest)*0.5);[/FONT][/COLOR][/SIZE][/B] [B][SIZE=3][COLOR=#000000][FONT=Calibri]XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest[/FONT][/COLOR][/SIZE][/B] [COLOR=Red][B]}[/B][/COLOR] [B][SIZE=3][COLOR=#000000][FONT=Calibri]} [/FONT][/COLOR][/SIZE][/B]
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
110 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
59 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
37 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
41 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
78 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment