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

Fundamentals data access

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

    Fundamentals data access

    I see that you have an OnFundamentalsData() method that fires when there is a change in fundamentals data. At the same time, the market analyzer allows me to show fundamentals data on the UI regardless of whether the data changed or not. Is there a way to access this data in NinjaScript when it did not change?

    #2
    Hello arnonmoscona,

    Yes, you could access these values within OnFundamentalData() and they will be current. It doesn't require a change in order to get the most up to date values.


    Declare a variable in variables region so that's available within the whole script.
    Then assign this variable within OnFundametalData to the value you want.
    You can then access it anywhere, like OnBarUpdate()

    Code:
    #region Variables
    private double myEPS;
    #endregion
    
    
    protected override void OnFundamentalData(FundamentalDataEventArgs e)
    {
     	 if (e.FundamentalDataType == FundamentalDataType.CurrentYearsEarningsPerShare)
            	myEPS =  e.DoubleValue;
    }
    
    protected override void OnBarUpdate()
    {
    	if (!Historical)
    	Print(myEPS);
    }
    Last edited by NinjaTrader_RyanM1; 01-05-2012, 11:39 AM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Yes. But this would trigger a value only when the value changes. My question is - how do I get this value if it did not change? Or in other words, in your example, how would I initialize myEPS?

      Comment


        #4
        I wouldn't worry about the "do not change" aspect here. Please try with the previous snippet (I added additional details) and it should work provided your data provider is supplying you with this data.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I'll try it. I use IQFeed. If this trigger comes every time they send a fundamentals message, then yes, it would come pretty quickly...

          Thanks

          Comment


            #6
            Code:
            #region Variables
            private int myShares;
            #endregion
            
            
            protected override void OnFundamentalData(FundamentalDataEventArgs e)
            {
             	 if (e.FundamentalDataType == FundamentalDataType.SharesOutstanding)
                    	myShares =  (int) e.DoubleValue;
            }
            
            protected override void OnBarUpdate()
            {
            	if (!Historical)
            	Print(myShares);
            }
            Hi,

            I tried the above block of code to extract SharesOutstanding using Yahoo as my data provider. However, I'm getting a constant value of -2147483648, on each bar update, for all stocks I apply the indicator to.

            The SharesOutstanding value, when displayed through a Market Analyzer, using Yahoo is correct.

            Any idea why this is happening?

            Thanks.

            Regards,
            Nick

            Comment


              #7
              Try using e.LongValue instead of e.DoubleValue and let me know if this works out for you.

              LanceNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by r68cervera, Today, 05:29 AM
              0 responses
              2 views
              0 likes
              Last Post r68cervera  
              Started by geddyisodin, Today, 05:20 AM
              0 responses
              3 views
              0 likes
              Last Post geddyisodin  
              Started by JonesJoker, 04-22-2024, 12:23 PM
              6 responses
              34 views
              0 likes
              Last Post JonesJoker  
              Started by GussJ, 03-04-2020, 03:11 PM
              12 responses
              3,239 views
              0 likes
              Last Post Leafcutter  
              Started by AveryFlynn, Today, 04:57 AM
              0 responses
              6 views
              0 likes
              Last Post AveryFlynn  
              Working...
              X