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

OnBarUpdate not called

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

    OnBarUpdate not called

    Hi there,

    something is not working here... OnBarUpdate prints correctly to the output window for the primary series and BarIndex 1 (MarketDataType.Last), but not for the BarIndex 2 (MarketDataType.Bid) and 3 (MarketDataType.Ask).

    Any idea why? I have a feeling that the bid/ask series might be empty, if so why? I use IQFeed as a data provider.

    Thx, Chris


    Code:
          
    protected override void Initialize()
            {
                CalculateOnBarClose	= false;
                Overlay = true;
    			
    			Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last);			
    			Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);
    			Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);
    			
    			ClearOutputWindow();
            }
    
            protected override void OnBarUpdate()
            {
    			if(BarsInProgress == 0)
    			{
    				
    			}
    			else if(BarsInProgress == 1)
    			{
    				Print("Last: " + Close[0]);
    			}
    			else if(BarsInProgress == 2)
    			{
    				Print("Bid: " + Close[0]);
    			}
    			else if(BarsInProgress == 3)
    			{
    				Print("Ask: " + Close[0]);
    			}	
    	}
    Last edited by Diderino; 05-27-2015, 04:59 AM.

    #2
    You need to use Closes,not Close.

    Should be something like

    Closes [1][0]
    Closes [2][0]
    Closes [3][0]

    For your example prints.

    Comment


      #3
      Post Reported

      Comment


        #4
        Originally posted by sledge View Post
        You need to use Closes,not Close.

        Should be something like

        Closes [1][0]
        Closes [2][0]
        Closes [3][0]

        For your example prints.
        That didn't do the trick...

        Comment


          #5
          It seems like the Bid and Ask Series are empty. The code below prints out this:

          Code:
          426
          638006
          0
          0

          Code:
                  protected override void Initialize()
                  {			
          			Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last);			
          			Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);
          			Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);
          			
          			ClearOutputWindow();
          			CalculateOnBarClose	= false;
                  }
          
          		protected override void OnStartUp()
          		{
          			Print(Closes[0].Count);
          			Print(Closes[1].Count);
          			Print(Closes[2].Count);
          			Print(Closes[3].Count);
          		}

          Comment


            #6
            Hello Diderino,

            Who are you connected to? (This is indicated in green in the lower left corner of the Control Center)

            Below is a link to the help guide on Historical & Real-Time Data. In the section 'Understanding the data provided by your connectivity provider' there is a chart that show the supported connection technologies and the types of data these connections support.
            http://www.ninjatrader.com/support/h...rical_data.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I am connected to IQFeed.

              Comment


                #8
                I found some older posts iqfeed bid /ask issues.

                Which instruments are you using?

                Comment


                  #9
                  To the "ES 06-15" contract, any idea what's going wrong?

                  Comment


                    #10
                    Hello Diderino,

                    Below is a link to the help guide on Historical & Real-Time Data. In the section 'Understanding the data provided by your connectivity provider' there is a chart that show the supported connection technologies and the types of data these connections support.

                    http://www.ninjatrader.com/support/h...rical_data.htm

                    (Look in the Historical Bid/Ask Tick Data column)


                    IQFeed does not provide historical tick ask or bid data.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I just asked IQFeed and they say they do provide historical (180 days back) bid/ask data, so the table in the link must be incorrect...

                      Comment


                        #12
                        Hello Diderino,

                        Open a 1 tick chart with the instrument. Set the data type to Bid.

                        Is there data on the chart?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by Diderino View Post
                          I just asked IQFeed and they say they do provide historical (180 days back) bid/ask data, so the table in the link must be incorrect...
                          Does this post help?

                          Comment


                            #14
                            Originally posted by NinjaTrader_ChelseaB View Post
                            Hello Diderino,

                            Open a 1 tick chart with the instrument. Set the data type to Bid.

                            Is there data on the chart?
                            When I set the data type to Bid, indeed no chart shows except for the last day, which is probably when I set the option "save chart data as historical"...

                            Comment


                              #15
                              Hello Diderino,

                              Saving the chart data is fine to do if this is not provided by the connection type.

                              If the data is saved with save chart data as historical a constant connection to that instrument is required to have consistent data. This just means keep a chart open to that instrument and data type or use the Market Analyzer with any indicator and a row with that instrument and data type set.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,603 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X