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

What method to use instead of GetDayBar to get the current bar from within an AddOn?

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

    What method to use instead of GetDayBar to get the current bar from within an AddOn?

    Hello,

    I am using the AddOn Framework sample code as basis for my add on.

    I am using the DoGetBars function to fetch a dozen of bars of historical data (daily bars). I then use GetDayBar on the bars object to access the data.
    However, the documentation says GetDayBar should only be used for getting historical bars and not the current bar.

    Is there another method I can use in an addon to get reliable OHL information of the current bar, similar e.g. to what CurrentDayOHL() does in the Indicator realm?

    Any help or information would be much appreciated; Also, if possible, it would be useful to understand why the use of GetDayBar() works for historical but not current bars.

    Many thanks,

    Libor
    Last edited by liborc; 06-15-2017, 04:48 PM.

    #2
    Hi Libor,

    at the AddOnFramework sample have a look at DoBarsRequest(). For the loaded instrument DoBarsRequest() sets realtime quotes to true. Now the current bars OHLC can be found at OnBarUpdate() for the loaded instrument:
    Code:
    e.BarsSeries.GetOpen(i),
    e.BarsSeries.GetHigh(i),
    e.BarsSeries.GetLow(i),
    e.BarsSeries.GetClose(i),

    Comment


      #3
      Hello liborc,

      The AddonFrameWork GoSpvC is referring to can be found here,

      A way to get the high of the day would be in OnMarketData, you could use something like the following,
      Code:
      	if (e.MarketDataType == MarketDataType.DailyHigh)
      	{
      	    NinjaTrader.Code.Output.Process(e.Price.ToString(), PrintTo.OutputTab1);	
      	}
      Which would print the daily high to the output window.

      You could see MarketData section of our helpguide,


      Please let us know if you need further assistance.
      Alan P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Gerik, Today, 09:40 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by RookieTrader, Today, 09:37 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by alifarahani, Today, 09:40 AM
      0 responses
      5 views
      0 likes
      Last Post alifarahani  
      Started by KennyK, 05-29-2017, 02:02 AM
      3 responses
      1,284 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by AttiM, 02-14-2024, 05:20 PM
      11 responses
      185 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X