Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Syntax for Currentbar Status

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by stockgoblin View Post
      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?
      How 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 = Time[0] - Time[1];
      at all times. You would have to use COBC = false, so that the indicator will be current at all time points.
      Last edited by koganam; 10-24-2012, 12:11 PM. Reason: Corrected posted code, per the comment that followed.

      Comment


        #4
        Originally posted by koganam View Post
        How 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];
        at all times. You would have to use COBC = false, so that the indicator will be current at all time points.
        koganam,

        Did you perhaps mean to say Time[0] - Time[1]?

        Comment


          #5
          Originally posted by coolmoss View Post
          koganam,

          Did you perhaps mean to say Time[0] - Time[1]?
          Absolutely! Thanks for the correction. I have corrected the original post. Whew!

          Comment


            #6
            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
            Last edited by stockgoblin; 10-24-2012, 12:38 PM.

            Comment


              #7
              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


                #8
                Originally posted by stockgoblin View Post
                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.
                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?

                Comment


                  #9
                  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


                    #10
                    Originally posted by stockgoblin View Post
                    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?
                    if (bc == 4 && (cond2 || cond3 || cond4 || cond5 || cond6 || cond7 || cond8 || cond9 || (cond12 || cond13 || cond14 || cond15 || cond16 || cond17 || cond18 || cond19) && sameday))
                    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


                      #11
                      Thanks, made the changes but I'm still getting an alert at every new bar. Strange. How can that be?
                      Attached Files

                      Comment


                        #12
                        Originally posted by stockgoblin View Post
                        Thanks, made the changes but I'm still getting an alert at every new bar. Strange. How can that be?
                        Because of you semicolon


                        Code:
                        	if  (bc == 5);
                        			
                        				
                        				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


                          #13
                          Wow, you just cured me of semi colon cancer.

                          thanks

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by DTSSTS, Today, 11:35 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post DTSSTS
                          by DTSSTS
                           
                          Started by op1031, Yesterday, 05:16 PM
                          1 response
                          8 views
                          0 likes
                          Last Post NT-Roland  
                          Started by sinpeople, Today, 07:20 AM
                          1 response
                          3 views
                          0 likes
                          Last Post NT-Roland  
                          Started by Frank1000, Today, 03:05 AM
                          1 response
                          8 views
                          0 likes
                          Last Post NT-Roland  
                          Started by ntdev, Today, 01:14 AM
                          4 responses
                          16 views
                          0 likes
                          Last Post ntdev
                          by ntdev
                           
                          Working...
                          X