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

How to make Indicator Values accessible by another indicator

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

    How to make Indicator Values accessible by another indicator

    Hi, I have an indicator that plots each bars sum of bid and ask values. I want to make this indicators bar values store in history. This way I can access the bar history with other indicators. Is this possible? The indicator is attached. Anybody's help would be appreciated. Thanks,
    Attached Files

    #2
    Hello woodyfox,

    You would not be able to access historical bid/ask values within OnMarketData. See the 2nd note at the following link for more information.



    You may use TickReplay to accomplish this, or you may consider using a secondary series of tick data, and calculate buys as those that traded above the previous trade and sells as those that traded below the last trade. This would give you a historical plot.

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

    Comment


      #3
      Hey.
      You can sample a ready-made strategy file to understand how it works. If you can examples of two options.
      Thank you.

      Comment


        #4
        Here's what I got:
        I pointed out in the strategy
        Code:
        else if(state == state.dataloaded)
        		{
            			gomdeltavol = gomdeltavolume(multipler, true);
        			addchartindicator(gomdeltavol);
        
                        }
        in the indicator
        Code:
        protected override void OnMarketData(MarketDataEventArgs e)
                {
        			if(backtest)
        			{
        				if (e.MarketDataType == MarketDataType.Last)
        					  {
        					    if (e.Price >= e.Ask)
        					    {
        							Ask[0] += e.Volume;
        					        Print(e.Volume + " contracts traded at asking price " + e.Ask);
        					    }
        					 
        					    else if (e.Price <= e.Bid)
        					    {
        							Bid[0] += e.Volume;
        					        Print(e.Volume + " Contracts Traded at bidding price " + e.Bid);
        					    }
        					  }
        			}
        when executing it produces an error
        Indicator 'GomDeltaVolume': Error on calling 'OnMarketData' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
        How will I correctly access the DataSeries [] and store the value of the volume in it?

        Comment


          #5
          Hello woodyfox,

          Does your strategy have a current bar check? See the following for more information,


          What data series are you trying to access?

          Here is a link that demonstrates how to access indicator values that are not plots,


          I look forward to your reply.
          Alan P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by f.saeidi, Today, 11:02 AM
          0 responses
          0 views
          0 likes
          Last Post f.saeidi  
          Started by geotrades1, Today, 10:02 AM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by rajendrasubedi2023, Today, 09:50 AM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by lorem, Today, 09:18 AM
          2 responses
          11 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by geddyisodin, Today, 05:20 AM
          4 responses
          30 views
          0 likes
          Last Post geddyisodin  
          Working...
          X