Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ind. data that stays on chart

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

    ind. data that stays on chart

    I made an indicator that works well, but when the chart refreshes all my data disappears. I notice the data for all the other indicators stay on the chart.

    What is the command to keep data on the chart? Where is it located in the code so I can find it and adjust it to fit my indicator?

    Thank you.

    #2
    Hello,

    Thank you for the question.

    This would depend on how the indicator is programmed.

    If this is using Live market data for plotting, each refresh would clear that data because it is not saved. If instead this is using historical data or data from the built in series like Close, it could be an error occurring.

    Can you tell me are you using OnMarketData for this indicator? if so this is likely the cause.

    I look forward to being of further assistance.

    Comment


      #3
      Yes, I'm using OnMarketData. If this is the problem, how do other indicators that use it stay on the chart?

      Thanks.

      Comment


        #4
        Hello,

        Other indicators using OnBarUpdate can be used historically because OnBarUpdate gets called for historical bars where OnMarketData does not.

        Take the SMA for example, when that indicator is applied it uses OnBarUpdate to calculate its plot for both historical and realtime. Using OnMarketData instead would only be realtime as that is a realtime only method.

        If you do need the values to be retained, you need to create logic to use historical data from OnBarUpdate to produce a plot initially, and then once realtime is met you can switch to using OnMarketData to continue building the plot.

        I look forward to being of further assistance.

        Comment


          #5
          My ind uses OnBarUpdate also. Can you point me to a specific part of an indicator that has the language I need so I can review?

          Thanks.

          Comment


            #6
            Hello,

            I am not sure what you mean to point you to the language you need.

            It would depend what you need to do in OnBarUpdate for your historical calculations or what logic is required to calculate.

            First you would need to review what your logic in OnMarketData does, and see what data it requires to calculate.

            Depending on what data is needed, it may or may not be possible using the available historical data. If for example you are just using Ask and Bid data, you could Add and ask and bid tick DataSeries to use for calculations. This would require a multi bar script.

            Please review what data you need for the calculation, if you can provide a more specific question regarding what needs to be done historically for your calculation I could provide samples or resources of methods to do this.

            I look forward to being of further assistance.

            Comment


              #7
              The best I can do to explain: OnMarketData calculates a number from the order flow, bid & ask volume, of each bar. OnBarUpdate prints this number on my charts, then clears all calculations, and OnMarketData starts all over again with the next bar. Is this the kind of information you're looking for?

              Thanks.

              Comment


                #8
                Hello,

                Thank you for the reply.

                If you are using Ask and Bid data, you could use Ask and Bid secondary data series to do that part of the calculation historically. It really depends on exactly what you are doing in the script, as I have not seen your code I couldn't tell you what all is required. Mainly you would need to in some form replicate the logic from OnMarketData in OnBarUpdate.

                As for the order flow, if you are accessing the level 2 data, that would not be available historically if that is what you are referring to, so that part would likely still only be able to work in realtime.

                I look forward to being of further assistance.

                Comment


                  #9
                  "As for the order flow, if you are accessing the level 2 data, that would not be available historically if that is what you are referring to, so that part would likely still only be able to work in realtime."

                  Each bar has order flow, with a number of bids occurring at a certain price and a number of asks occurring at a certain price. My ind compares the bid to the ask at each price, performs a calculation, then gives me a result. It does this for every bar, resets, then starts the next bar. Is this level 2 data? Can this logic be replicated in OnBarUpdate?

                  Thanks for the input.

                  Comment


                    #10
                    Hello imalil,

                    The CurrentBid and CurrentAsk when bid or ask ticks are received are level information, this could be found using a secondary data series in your script in OnBarUpdate.

                    Add(BarsArray[0].Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);

                    if (BarsInProgress == 1)
                    {
                    Print("Ask price: "+Close[0]);
                    }

                    Level II data are the 10 levels of ask and 10 levels of bid. This information is found in OnMarketDepth and cannot be accessed historically. (Level II data is not stored historically for any data providers)
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    571 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    331 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    549 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    549 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X