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

when is the barupdate created and bar object created

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

    when is the barupdate created and bar object created

    my strategy involves setting the buy stop of the prev bar high.
    i do not want to use the "commenly and incorrectly recommended "
    FirstTickOfBar" as part of barupdate because

    1. barupdate is called only when there is a change in price.
    2. if the price closes @ high of the bar, the next time i will get a barupdate is when the price moves even higher.
    so my strategy of buy stop @ high of last bar will trigger error from IB becaues the stop price will be lower than the market price.

    I also dont wnat to use onmarketupdate for such a small issue. So my plan is to run a timer that will raise a event at the end of the bar. so i will get a event exactly @ 2009-05-11 12:50:00

    Now if i want to set a buystop High[1], the new bar obect needs to have been created.
    So would the bar object be created automatically at the end of the bar time or would it wait for market data?


    #2
    junkone,

    I am not sure I understand you. FirstTickOfBar is the same event as the closing of a bar. The closing of a bar only occurs when the first tick of the new bar is received.

    OnBarUpdate() is called depending on what you have CalculateOnBarClose set to. If false then it will update every tick.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      your statement contradicts
      Support for the development of custom automated trading strategies using NinjaScript.


      "OnBarUpdate() only updates once for each price move. OnMarketData() may come with 3 updates representing bid, ask, and last. You filter it to choose which one you want to look at."

      if i get a new bar and there is no price move for the entire bar period, i probably will not be getting a onBarUpdate.

      Comment


        #4
        Not following you. Where is the contradiction? OnBarUpdate() is for incoming ticks. To build a bar you absolutely have to have ticks coming in. Only then will a bar be built. If no ticks are coming in, no bar is built, and no OnBarUpdate() will be received.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          if the bid and ask is the same, then there will be no price change. so, there will be no barupdate becuase price has not changed.

          in my dictionary, there is a price change if the bid/ask is different from the previous bid/ask.
          in NT dictionary, how do you define price change.

          Comment


            #6
            There is no definition. NinjaTrader receives data from your data provider. Your data provider stamps them either as last, bid, or ask. OnBarUpdate() comes from last ticks. Last means the last traded price. This does not need to mean a "change". It can very well be a sideways "move".

            There is no check for bid or ask.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              IB forex does not have last. it only has bid and ask. so what does NT use

              Comment


                #8
                NT would use the bid (if provider would not support "last").

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by cocoescala, 10-12-2018, 11:02 PM
                7 responses
                939 views
                0 likes
                Last Post Jquiroz1975  
                Started by oviejo, Today, 12:28 AM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by geddyisodin, Yesterday, 05:20 AM
                7 responses
                46 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by gbourque, Today, 06:39 AM
                2 responses
                5 views
                0 likes
                Last Post gbourque  
                Started by cre8able, Yesterday, 07:24 PM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X