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!
See more
See less

Partner 728x90

Collapse

Add(PeriodType.Minute, 1440);

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

    Add(PeriodType.Minute, 1440);

    Hello Support --

    I add additional bars objects by the following

    Add(PeriodType.Minute, 1440);

    then I'm trying to get Close, High and Low of that bars objects

    double d_ldcp = Closes [1] [1]; // close price of the previous bar
    double d_cdhp = Highs [1] [0]; // high price of the cuurent bar
    double d_cdlp = Lows [1] [0]; // low price of the bar

    but when I load a chart set a period type - Minuty, a period value - 1440 I get the different value of previous and current bar,

    what should be the code to get the same valuse.

    Thank you in advance.

    #2
    Hello alex_bbfg,

    That syntax looks correct to get the previous values of the 1440 Minute chart, but you will want to make sure that you are getting the values at the times that you expect.

    If you use:

    Code:
    Print("Time of previous bar: "+Times[1][1]);
    Do you get the same time as the chart that you are looking at?

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hello NinjaTrader_JC

      thank you for your reply. I was tinking about time synchronization regarding of session template and found out that it is the same as the chart a script assigned to.

      What is the way to synchronize time of a chart and the time of the script ?

      Thank you in advance.

      Comment


        #4
        Hello Alex,

        I'm not quite sure I follow - what do you mean the time of the script vs the time of the chart? How are you defining these and how are they different?
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hello Matthew and others

          NinjaTrader_JC wrote

          "Do you get the same time as the chart that you are looking at?"

          and I thought that I should synchronize the time of the script and the time of the chart to get the same results. Earlier, I've met different time standards like GMT time, Server time, Computer time, Local time. So, I thought that the script and the chart has different time standards to build bars objects. Strictly speaking that is the point.

          some more adds to my issue

          this code gives me the script value

          Add(PeriodType.Minute, 1440);

          double d_ldcp = Closes [1] [1]; // close price of the previous bar
          double d_cdhp = Highs [1] [0]; // high price of the current bar
          double d_cdlp = Lows [1] [0]; // low price of the bar

          to get chart value

          I load a chart of 1440 minute, set the cursor mode to "Cross Hair" activate data box window, put on the cursor on the previous bar of the chart and read the values from the data box.

          They are different. The values of the script and the values in the data box window.

          I've read some info here (2nd subsection)

          but it is not quite clear for me. If that is the answer to my issue could you please provide me the code for understanding.

          Thank you in advance.

          Comment


            #6
            Hello alex_bbfg,

            The link to our Help Guide is just a link to our main Index page, but I believe you are talking about the Multi-Time Frame and Instruments page under the section "How Bar Data is Referenced":


            Basically, it is showing how the bars are being referenced which I believe maybe a part of the issue.

            Do you have Calculate on bar close set to True or False?
            JCNinjaTrader Customer Service

            Comment


              #7
              Hello JC --

              protected override void Initialize()
              {
              Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
              Overlay = false;
              Add(PeriodType.Minute, 1440);
              CalculateOnBarClose = false;
              }

              It is critical for me. I'd like to see changing of current bar high and low in a progress.

              Regards

              Comment


                #8
                Hello alex_bbfg,

                Thanks for clarifying that for me.

                So using CalculateOnBarClose (COBC) false, means that each incoming tick of data your Primary Series will be updated and then your secondary Series (1440 Minute) will be updated but you should still be able to get the previous days close value without an issue.

                Could you possibly attach a toy version of your script so that I can take a look at it?
                You can Export it as a Source File using the step from our Help Guide at the link below.


                I have attached a simple indicator that adds a 1440 minute series as well and plots the previous close value of the 1440 minute if you would like to take a look at in reference as well.
                Attached Files
                JCNinjaTrader Customer Service

                Comment


                  #9
                  Hello JC --

                  Thank you very much for your example code. I'm really surprised of your great service.

                  I used your script and the results of its work on the right chart of the image attached. I changed your code by adding the following

                  DrawTextFixed("Closes[1][1]", "Closes[1][1] = "+Closes[1][1]+" Times[1][1]: "+Times[1][1]+ "\n"+"Closes[1][0] = "+Closes[1][0]+" Times[1][1]: "+Times[1][0], TextPosition.BottomRight);

                  You know I still do not know where NT7 prints Print() method results, which window.

                  The left chart of the Image illustrates the work of my script and it gives the correct figures!!! I've just replace Closes [1][1], Highs[1][0] and Lows [1][0] methods from OnStartUp() to OnBarUpdate() Insude OnStartUp() the script gives figures greater on 3 point.

                  The other thing I've noticed is that the scripts are not work if I assigned them to the same chart.

                  Again,
                  Thank you very much.
                  The issue is closed.
                  Attached Files

                  Comment


                    #10
                    Hi Alex_bbfg,

                    Glad to hear your issue is resolved.

                    The Print() will print to the Output window which can be accessed by going to Tools -> Output window from the Control Center.

                    Let us know if we can be of further assistance.
                    Cal H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by RookieTrader, Today, 09:37 AM
                    3 responses
                    15 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by kulwinder73, Today, 10:31 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post kulwinder73  
                    Started by terofs, Yesterday, 04:18 PM
                    1 response
                    24 views
                    0 likes
                    Last Post terofs
                    by terofs
                     
                    Started by CommonWhale, Today, 09:55 AM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by Gerik, Today, 09:40 AM
                    2 responses
                    7 views
                    0 likes
                    Last Post Gerik
                    by Gerik
                     
                    Working...
                    X