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

Understand the FirstTickOfBar with COBC=false

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

    Understand the FirstTickOfBar with COBC=false

    Hi,
    I am trying to understand the FirstTickOfBar with COBC=false.
    I have added 2 data series in my code ( 3 min and 5 min) and main data series is 500 tick

    For BarsInProgress == 0 (main data series)
    If I use Closes[0][0], will it give currently closed 500 tick bar or the closing price of first tick of the new bar? (closing price of currently closed bar can be different than the first tick of new bar).
    At what point of time FirstTickOfBar code will get executed? Is it before forming the new bar or on the first tick of new bar? Can I expect tick delay between COBC= true and FirstTickOfBar?

    I have synchronized the idataseries object to hold SMA of 3 min and 5 min data series
    Is it possible to recalculate (SMA) based on the current price on 3 min and 5 min data series on the first tick of 500 tick data series?
    Thanks
    gsreddy

    #2
    If you're using FirstTickOfBar, it will only execute once at the close of the bar as indicated by the open of the next bar. Which means that Closes[0]0] will give the close price of the last closed bar on the chart. This would be executed on the first tick of the new bar. There should not be a noticeable delay between using COBC true and FTOB

    As long as you're running the calculations for your SMA 3 minute and 5 minute array within BarsInProgress == 0 and FTOB, they should update when this event is called.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi,

      thanks for quick reply, i have built the sample program to test this out and seeing the stepped increase or decrease EMA or SAM on the 500 tick chart values from 3 min series.
      looks like 3 min series values are not getting updated on the close of 500 tick bar. i am expecting the smooth increase or decrease of indicator values from 3 min bars.

      can you please check and help me with the attached code?

      thanks
      gsreddy
      Attached Files
      Last edited by gsreddy; 10-17-2012, 03:06 PM.

      Comment


        #4
        This will occur if you're using a smaller input series than the added series and the equidistant bar spacing. The visual plots will appear as you are seeing. If you switch the primary input series to a 5 minute chart for example, you will see the EMA's plotted smooth as you expect.

        This is just how the the plots will update visually as it will need to use an equal amount of space between bars, however the updates you receive for the calculates will work as you're expecting.
        MatthewNinjaTrader Product Management

        Comment


          #5
          thanks for the response, i will try to place some Print statements to validate the calculated data.

          thanks,
          gopi syamala.

          Comment


            #6
            Hi,

            i have done some testing to understand more on the calculations using the same attached sample in previous post with print statement and COBC=false. i have noticed EMA calculations on the higher time frame is not getting update with the latest price (close of main bars series). please check the attached results and suggest me how to get the higher time frame EMA values based on the current close of the main bars series or using the current prince when ever higher time frame EMA is called.
            i have attached the excel file (.zip) with sample data.

            thanks,
            gsreddy
            Attached Files

            Comment


              #7
              Were these results based off historical data or real-time data?
              MatthewNinjaTrader Product Management

              Comment


                #8
                it is based on the historical data. i know, with the real-time data this will not happen,
                is there a way to simulate real time calculations with historical data?

                thanks
                gsreddy

                Comment


                  #9
                  FirstTickOfBar only works on real-time data. If you would like to run calculations on historical data, you'd need to specify the time you'd like the updates using ToTime():

                  MatthewNinjaTrader Product Management

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by knowmad, Today, 03:52 AM
                  1 response
                  19 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by llanqui, Yesterday, 03:51 PM
                  5 responses
                  23 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by MSerag, Yesterday, 11:52 PM
                  1 response
                  17 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by tradingnasdaqprueba, Today, 03:42 AM
                  1 response
                  18 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by DynamicTest, Yesterday, 11:18 PM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X