I'm just coding an if statement and would like to add a condition where the current bar must be half finished or say at least 3 minutes since it started. What would be the syntax for such a thing. Can I do something like this?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Syntax for Currentbar Status
Collapse
X
-
Syntax for Currentbar Status
Hi,
I'm just coding an if statement and would like to add a condition where the current bar must be half finished or say at least 3 minutes since it started. What would be the syntax for such a thing. Can I do something like this?Last edited by stockgoblin; 10-23-2012, 07:48 PM.Tags: None
-
stockgoblin, there would not be a method build in unfortunately to accomplish this, you would need to look into recording the time length of the bar you're working on, for example via a TimeSpan in C#.
Some code to get your started into this territory could be found in our sharing section - http://www.ninjatrader.com/support/f...stogram&desc=1
-
How to do that would depend on what type of bars you are using.Originally posted by stockgoblin View PostHi,
I'm just coding an if statement and would like to add a condition where the current bar must be half finished or say at least 3 minutes since it started. What would be the syntax for such a thing. Can I do something like this?
1. Fixed-time-interval charts have their bars marked with their end time, period. The way to do what you want would be to use another barSeries with a smaller time interval.
2. If you are using other kinds of bars, then the time elasped in the CurrentBar is simply:
at all times. You would have to use COBC = false, so that the indicator will be current at all time points.Code:TimeSpan timeElapsed = Time[0] - Time[1];
Last edited by koganam; 10-24-2012, 12:11 PM. Reason: Corrected posted code, per the comment that followed.
Comment
-
koganam,Originally posted by koganam View PostHow to do that would depend on what type of bars you are using.
1. Fixed-time-interval charts have their bars marked with their end time, period. The way to do what you want would be to use another barSeries with a smaller time interval.
2. If you are using other kinds of bars, then the time elasped in the CurrentBar is simply:
at all times. You would have to use COBC = false, so that the indicator will be current at all time points.Code:TimeSpan timeElapsed = Close[0] - Close[1];
Did you perhaps mean to say Time[0] - Time[1]?
Comment
-
Hey Koganam / Coolmoss,
Thanks for the reply. I'll check that out. Actually what I'm trying to do is add an alert in the Better Volume 3 indicator for a ClimaxChurn bar. I don't know if you use Better Volume 3 but it gives me some added input when the markets are up to something.
I've included my copy with the pathetic attempt at the end. Any chance you could quickly look at it?
Oh, I use Calculate on Bar close set to false which may be a problem for adding an alert. I'm not sure.
Thanks, Any help is appreciated.Attached FilesLast edited by stockgoblin; 10-24-2012, 12:38 PM.
Comment
-
Hey Koganam / Coolmoss,
Thanks for the reply. I'll check that out. Actually what I'm trying to do is add an alert in the Better Volume 3 indicator for a ClimaxChurn bar. I don't know if you use Better Volume 3 but it gives me some added input when the markets are up to something.
I've included my copy with the pathetic attempt at the end. Any chance you could quickly look at it?
Oh, I use Calculate on Bar close set to false which may be a problem for adding an alert. I'm not sure.
Thanks, Any help is appreciated.Attached Files
Comment
-
I am not quite sure what you are asking, but if you want to set an Alert(), all you need to do is determine if your conditions are met, and then call the Alert() method. How did that not work for you?Originally posted by stockgoblin View PostHey Koganam / Coolmoss,
Thanks for the reply. I'll check that out. Actually what I'm trying to do is add an alert in the Better Volume 3 indicator for a ClimaxChurn bar. I don't know if you use Better Volume 3 but it gives me some added input when the markets are up to something.
I've included my copy with the pathetic attempt at the end. Any chance you could quickly look at it?
Oh, I use Calculate on Bar close set to false which may be a problem for adding an alert. I'm not sure.
Thanks, Any help is appreciated.
Comment
-
I guess I don't fully understand the conditions of the indicator. Looking at the code, I thought "bc=4" is what produced the ClimaxChurn bar but setting that resulted in an alert at every new bar. Can your eagle eyes pick out what produces each type of painted bar?Attached Files
Comment
-
if (bc == 4 && (cond2 || cond3 || cond4 || cond5 || cond6 || cond7 || cond8 || cond9 || (cond12 || cond13 || cond14 || cond15 || cond16 || cond17 || cond18 || cond19) && sameday))Originally posted by stockgoblin View PostI guess I don't fully understand the conditions of the indicator. Looking at the code, I thought "bc=4" is what produced the ClimaxChurn bar but setting that resulted in an alert at every new bar. Can your eagle eyes pick out what produces each type of painted bar?
bc = 5; //ClimaxChurn
bc ==4 and all those conditions do
bc=5 is the elevated level when it happens
change your code to check for bc==5
if (bc==5)
{
Alert (...)
}
Comment
-
Thanks, made the changes but I'm still getting an alert at every new bar. Strange. How can that be?Attached Files
Comment
-
Because of you semicolonOriginally posted by stockgoblin View PostThanks, made the changes but I'm still getting an alert at every new bar. Strange. How can that be?
Code:if (bc == 5)[B];[/B] Alert("BLUE BAR", Cbi.Priority.High, "BLUE BAR!", "Alert4.wav", 59, Color.White, Color.Blue);
change to
Code:if (bc == 5) Alert("BLUE BAR", Cbi.Priority.High, "BLUE BAR!", "Alert4.wav", 59, Color.White, Color.Blue);
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

I have corrected the original post. Whew!
Comment