Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

FirstTickOfBar always true in OnMarketData

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

    FirstTickOfBar always true in OnMarketData

    Well the title pretty much sums it up : when called from OnMarketData, FirstTickOfBar always returns true.

    code:
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Use this method for calculating your indicator values. Assign a value to each[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// plot below by replacing 'Close[0]' with your own formula.[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"OBU"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]+FirstTickOfBar);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
     
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnMarketData(MarketDataEventArgs e)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Use this method for calculating your indicator values. Assign a value to each[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// plot below by replacing 'Close[0]' with your own formula.[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"OMD"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]+FirstTickOfBar);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT]
    output:
    OBUFalse
    OMDTrue
    OMDTrue
    OMDTrue
    OMDTrue
    OBUTrue
    OMDTrue
    OMDTrue
    OBUFalse
    OMDTrue
    OMDTrue
    OBUFalse
    OMDTrue
    OMDTrue
    OBUFalse
    OMDTrue
    OMDTrue
    OBUFalse
    OMDTrue
    OMDTrue
    OBUFalse
    OMDTrue
    OMDTrue

    #2
    gomifromparis,

    FirstTickOfBar only works in OnBarUpdate() as it is in relation to bars. When you are in OnMarketData() you aren't working on bars per se so it should not be used there.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Fair enough, but this restriction is not indicated in the documentation, and it worked OK in 6.5...

      Originally posted by NinjaTrader_Josh View Post
      gomifromparis,

      FirstTickOfBar only works in OnBarUpdate() as it is in relation to bars. When you are in OnMarketData() you aren't working on bars per se so it should not be used there.

      Comment


        #4
        gomifromparis,

        I am not sure how you got it to work in 6.5. In my testing it also returns all true from OnMarketData(). The restriction will be documented in 7.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          On a related note, is CurrentBar set to the latest bar of the main instrument series when OnMarketData is called or is it also not defined?

          Comment


            #6
            aviat72, should be defined for the last bar on the main instrument still in OnMarketData().

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              gomifromparis,

              FirstTickOfBar only works in OnBarUpdate() as it is in relation to bars. When you are in OnMarketData() you aren't working on bars per se so it should not be used there.

              This is why I have abandoned the FirstTickOfBar feature.

              It only responds to changes in price.

              It is not useful with volume indicators.
              Last edited by RJay; 05-01-2010, 02:53 PM.
              RJay
              NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

              Comment


                #8
                rt6176,

                Not true. You do not need price to change to receive a tick. You can receive many many ticks with the same price sequentially and just different volumes or even the same trade volume on these ticks. You can see this very easily when you pull up a 1-tick chart. Each one of those dashes would represent an OnBarUpdate() event when using CalculateOnBarClose = false.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                597 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                343 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                556 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                555 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X