Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

unable to access info in another region

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

    unable to access info in another region

    When I am execute a print statement in an initialize region [for debug/trace purposes] I get the error message “BarsInProgress property can’t be accessed from within Initialize method”. Is there a way I can make it work, like maybe make something public instead of private, etc?

    the print statement is:
    Print(" ");//blank line separator
    Print(" lanceV3indicator@OBUentry "+Time[0].ToString("MM/dd/yy h:mmtt")+ "//"+Time[0].ToString("HH:mm ")+Time[0].DayOfWeek);

    #2
    You cannot access any bar index values (.e.g, Time[0]) from here.

    If you'd like to add this print statement for debug purposes when the indciator is started, you will need to use OnStartUp



    Depending on what you're looking to debug, you may want to use DateTime.Now to get the exact time the indicator was started?

    At any rate, I'd suggest putting your debug statements in OnStartUp unless you're debugging something specific to Initialize. The reason for this recommendation is that Initialize is called across all indicators and you may get this debug info called when you do not expect. OnStartUp would only be called at the exact moment the indicator is started.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Presently my debug/tracing messages are an attempt to understand the complex [complex for me] program flow control which occurs when running the strategy analyzer. intellectual curiosity is not my motivation – I just need to know to then be able to effectively create more ‘print to output’ commands to do further checking. I am trying to use a custom indicator created by Lance for me which accomplishes a variation on ‘GetDay Bar’ which I needed. I have no idea how he did it, I just use it. As you point out, when I run the analyzer I am seeing all kinds of unexpected trace messages from the indicator and from the analyzer, and that is my confusion. So ……………. therefore it sounds to me like I need to maybe experiment around with using OnStartUp, DateTime, etc.

      Is an indicator’s OnStartUp called only once during an analyzer run no matter how many times the indicator is used?
      Please provide me with any links which may help me better understand all this.
      This may be gibberish but want to get it off before shop closes up for the week in an hour or so.
      Thanks for the help.

      Comment


        #4
        INVALID PARAMETER WHEN TRYING TO USE SampleDateTimeFunctions()

        I am trying to make SampleDateTimeFunctions() work.
        the following results in trying to pass an incorrect parameter. any help will be much appreciated.

        Add(SampleDateTimeFunctions());//this in initialize region
        SampleDateTimeFunctions("07/29/09 14:30:00");//this in onbarupdate region

        Comment


          #5
          Originally posted by joemiller View Post
          I am trying to make SampleDateTimeFunctions() work.
          the following results in trying to pass an incorrect parameter. any help will be much appreciated.

          Add(SampleDateTimeFunctions());//this in initialize region
          SampleDateTimeFunctions("07/29/09 14:30:00");//this in onbarupdate region
          What method is SampleDateTimeFunctions(), and where is/are they from?

          You usually call a method, and if it returns a value, assign that value to a variable. Without more information of what the SampleDateTimeFunctions() is, and how it is implemented, there is little that can really be helpfully said.

          Comment


            #6
            SampleDateTimeFunctions() is described in forum thread http://www.ninjatrader.com/support/f...ad.php?t=19292.
            I don’t know what method SampleDateTimeFunctions() is. it came from
            the zip file presented in the forum thread. I imported it into my indicator folder and then started experimenting from there.

            Comment


              #7
              Originally posted by joemiller View Post
              SampleDateTimeFunctions() is described in forum thread http://www.ninjatrader.com/support/f...ad.php?t=19292.
              I don’t know what method SampleDateTimeFunctions() is. it came from
              the zip file presented in the forum thread. I imported it into my indicator folder and then started experimenting from there.
              That is just a file containing code that demonstrates various ways of using the .NET DateTime functions. It was not designed to return any data, as is shown by the fact that it has no publicly exposed methods or properties.

              While definitely a class that can be imported as an indicator, it is pretty much as the Description says.
              /// <summary>
              /// A reference sample demonstrating the more common DateTime properties and methods.
              /// </summary>
              [Description("A reference sample demonstrating the more common DateTime properties and methods.")]
              It is more in the nature of a compendium of routines to be studied for ideas to copy and use in other indicators: not an indicator to be used for anything else, really.

              Comment


                #8
                you forum guys are one of my best resources because I am not a programmer, I hate programming and try to do it only because I have to. It would be nice if I understood the meaning and the difference between a method and a class etc. but thus far no time to do so. I do pick up on a few concepts now and then..

                anyhow, thanks for the help.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                59 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                36 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                7 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                21 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                9 views
                0 likes
                Last Post cre8able  
                Working...
                X