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

Syntax first bar of contract ES12-20

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

    Syntax first bar of contract ES12-20

    Hello everyone!
    I'm working on a stat Arb strategy using Distance approach. I want to calculate normalized price of the two stocks. for that aim, i want to take my refernce bar the first bar of each contract. for example, ES 12-20 started 12/9/2020, i wonder if you can help me get the syntax:
    RefES=Close[firstInstrument][...]=......!!!
    thank you!

    #2
    Hello KacemRhaz,

    Thanks for your post.

    Each bar consists of 4 price series, Open, High, Low, and Close. As a series, you can refer to the "bars ago" of the series. Please see this link: https://ninjatrader.com/support/help...ice_series.htm

    For example, High[0] would be the high of zero bars ago (also called the current bar). Reference: https://ninjatrader.com/support/help...riceseries.htm

    The system uses a bar counter called CurrentBar and it holds the count of the bars. Reference: https://ninjatrader.com/support/help...currentbar.htm

    When you say take the first bar of the contract, what exactly do you mean? Are you meaning the first bar of loaded data series, so if you had 5 days of data, do you mean the first bar of data 5 days ago? Do you mean the first bar of an intraday session?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks mr Paul for your interaction! es 12-20 started 12/09/2020. i want to return the first value of this contract

      Comment


        #4
        Hello KacemRhaz,

        Thanks for your reply.

        If I understand correctly, you are looking for the first bar of the ES 12-20 from today.

        What trading hours are you using? This can be identified in the data series of the chart. Right mouse click on the chart and select "data series"

        In the data series window, scroll down until you see "Trading Hours" and advise the selection shown.

        What bar type and bar size you are using?



        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I'm using 5 minutes bar. in trading hours a dfault selection is selected

          Comment


            #6
            for example, if i take the first bar of session as a reference,i use the code :
            if(Bars.IsFirstBarOfSession){
            RefES = Closes[1][0];
            RefNQ = Closes[2][0];
            }
            i want the same syntax for the first bar at the start of es12-20 occured 12/9/2020

            Comment


              #7
              Hello KacemRhaz,

              Thanks for your reply.

              The code you show would provide the close price of both contracts on the first bar of the current session which would have been 12/08/2020.

              The default trading hours for those instruments would be the CME US Index Futures ETH which shows a session start of 4:00 PM (CST) the previous day (12/08/2020).

              The first bar of the session for 12/09/2020 will not occur until 4:00 PM CST today.

              You can review the trading hours information under Ninjatrader controlcenter Tools>Trading hours
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                i'm sorry for the confusion 12/9/2020 means twelfth day of spetember 2020. i want to get the first bar of the current contract es 12-20

                Comment


                  #9
                  Hello KacemRhaz,

                  Thanks for your reply.

                  My apologies for the misunderstanding, I should have considered that but was confused by the proximity of the current date.

                  Assuming your charted data goes back to that date, I recommend using GetBar() where you provide a date/time of the bar needed and it will return the bar number. You can then use CurrentBar minus the bar number for the barsago value that you can use in the Close series. Please see the help guide link (with example) here: https://ninjatrader.com/support/help...t8/?getbar.htm

                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks mr Paul! i will try it!
                    But, with this method i will return it by a static way! i want a methode to update the reference value with each refreshment of a contract (12-20, es 09-20
                    Last edited by KacemRhaz; 12-09-2020, 02:45 PM.

                    Comment


                      #11
                      Hello KacemRhaz,

                      Thanks for your reply.

                      If I understand correctly the need is to pull the close value of the first bar of the first day of the contract.

                      There would be no method that would provide this.

                      You could build something using these references:




                      You might also look at the market analyzer column "days until rollover" for some coding ideas.

                      If you would like something created for you, we can provide references to 3rd party programmers in the NinjaTrader Ecosystem.
                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks mr Paul! Your answers were helpful!
                        Last edited by KacemRhaz; 12-09-2020, 04:16 PM.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by md4866, 05-01-2024, 08:15 PM
                        2 responses
                        18 views
                        0 likes
                        Last Post md4866
                        by md4866
                         
                        Started by samish18, Today, 12:20 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post samish18  
                        Started by thread, 04-15-2024, 11:58 PM
                        3 responses
                        48 views
                        0 likes
                        Last Post Georg1o
                        by Georg1o
                         
                        Started by leojimenezp, 04-20-2024, 05:49 PM
                        4 responses
                        50 views
                        0 likes
                        Last Post leojimenezp  
                        Started by nicthe, Today, 09:24 AM
                        1 response
                        8 views
                        0 likes
                        Last Post nicthe
                        by nicthe
                         
                        Working...
                        X