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 junkone, 04-28-2024, 02:19 PM
          8 responses
          92 views
          1 like
          Last Post brucerobinson  
          Started by mkouitra, 10-23-2021, 04:40 PM
          17 responses
          1,962 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by Vietanhnguyen2hotmailcom, 05-03-2024, 10:29 AM
          4 responses
          29 views
          0 likes
          Last Post Vietanhnguyen2hotmailcom  
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          37 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          40 views
          0 likes
          Last Post ageeholdings  
          Working...
          X