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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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=1BertrandNinjaTrader Customer Service
-
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:
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
-
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:
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
-
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
-
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
-
Originally 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 Lele2k24, Yesterday, 11:24 AM
|
12 responses
36 views
0 likes
|
Last Post Today, 03:07 PM | ||
Started by RaygunWizzle, Yesterday, 08:52 PM
|
3 responses
11 views
0 likes
|
Last Post Today, 02:50 PM | ||
Started by Tim-c, Today, 08:36 AM
|
4 responses
14 views
0 likes
|
Last Post Today, 02:45 PM | ||
Started by JohnS52, 03-22-2024, 08:06 AM
|
4 responses
28 views
0 likes
|
Last Post
by JohnS52
Today, 02:30 PM
|
||
Started by carnitron, 03-25-2024, 01:59 PM
|
11 responses
53 views
0 likes
|
Last Post
by carnitron
Today, 02:18 PM
|
Comment