Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volume Based Indicator Help

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

    #16
    Hello StoneMan78,

    Yes, this would be to prevent the strategy from processing historically.

    You had previously inquired:
    Could you instruct me on how to ensure real-time data loads in first?
    If you were not wanting to only process real-time data and not historical data, can you further clarify what you are wanting to achieve?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Of course, as it is currently written, my interpretation of the logic is the code first checks if the data is historical. If that check is true the return statement is triggered and the logic ends. (I may be wrong in this interpretation). If that check for historical data is false, the data is real time and the code will continue on to run the rest of the logic and load in the the indicator. The problem here is that there is no way for the code to go back and load in the historical data after that initial check prioritizes the real time data. I tried messing with where I put the return statement but couldn't figure it out. The goal I am trying to achieve is when you told me, "And be sure that is real-time data and not historical data that loads before real-time data." What I currently have can isolate the real time data but doesn't allow me to work with the historical data. The logic I am looking for is more along the lines of > if data is real-time, load indicator, then, after that, use historical data to load in the rest of the indicator. I believe that should meet the goal of making sure it is, "real-time data and not historical data that loads before real-time data." Thank you so much for your help and continued support, it is greatly appreciated.

      Comment


        #18
        Hello StoneMan78,

        The BuySellPressure is a real-time indicator and does not produce values historically.. Add this to a chart.. Are you wanting the all of the blank values before the indicator starts processing in real-time?
        What are you trying to load historically?

        Also see TickReplay.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Due to the real time nature of the underlying indicator I am working with, I have had tick replay enabled. When tick replay is enabled, the BuySellPressure indicator back fills perfectly and still processes real time data just fine. Considering that is the indicator mine is built from, I would hope to be able to replicate that behavior on my indicator. After seeing the "developing for tick replay" section there appears to be more going on here than I thought. At some point I would like to be able to use my custom indicator to develop a strategy. What sort of changes do you think need to be made to my logic in order to allow for that? I have the examples to work from, but how do you think I could apply those to my indicator to meet my goals?

          Comment


            #20
            As an aside, when I was talking about historical data, I was interpreting that back filled data from tick replay as "historical". In reality it seems that may not be the case. But I hope that clears some things up for you in my previous posts.

            I would also like to clarify what my goals are here:

            My immediate goal is to have the indicator prioritize real time data then back fill the tick replay data. I would like the behavior of my logic to be able to match that of BuySellPressure indicator it is based off of when back filling and running.

            Once that is working. I would like to know if there are any other steps I need to take to prepare my indicator for use in strategy development. Working with tick based data with tick replay enabled appears to offer up some unique challenges. Would speacil steps need to be taken in indicator development, strategy development, or both to allow for the use tick replay in strategy development and back testing?

            Comment


              #21
              Hello StoneMan78,

              Thank you for clarifying your question is about how to work with tick replay in OnMarketData.

              The market data type will always be last.

              This means if '(argument.MarketDataType == MarketDataType.Ask)' will never be true.

              If you need the ask / bid price, get this from the argument.Ask / argument.Bid when the MarketDataType is .Last. In the case of the BuySellPressure the argument is e (e.Ask / e.Bid).

              https://ninjatrader.com/support/help...ick_replay.htm
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22
                Thank you for the reply. Going forward I have made an assumption on what historical data is defined as in the tick replay engine. My theory is that historical data is interpreted as any market event, ordered chronologically tick by tick, that has a piece of data in front of it. The front most piece of data will be considered "real time". Please correct me if I am wrong in that assumption. In all this talk of "real-time" vs "historical" data I haven't been working off of a strict definition so it helps to have one.
                Also, I believe I have found a solution to my most immediate goal. The logic is as follows:

                If the first tick of a new bar is historical run the traditional script (look back one tick on BuySellPressure to calculate net pressure from conditions of last bar)
                If not (else) run the "real time" condition that also looks back one tick on BuySellPressure to calculate net pressure from the conditions of last bar.

                Both conditions run the same calculation but create the necessary bifurcation between real time and historical data we are looking for on an indicator to work with tick replay enabled.

                If there are any holes in this logic or if I am working with data wrong could you point them out? Will implement as soon as possible. Thanks for all of your help.

                Comment


                  #23
                  Hello ChelseaB,

                  I have tried to implemented my logic and it did not go as planned. The historical data loads in fine but the real time data causes the indicator to flatline to zero this was made clear when I set the period to 10 seconds for testing. I also tried switching from OnBarUpdate to OnMarketUpdate but that made no difference either. You can see what I attempted to implement in the commented out sections in the attached image. It made no difference over the more bare bones code that is currently compiled. Any idea on how to get the real time stuff running? Any help will be greatly appreciated, thank you so much.

                  Attached Files

                  Comment


                    #24
                    Hello StoneMan78,

                    I'm uncertain but this may be due to the condition if (CurrentBar != activeBar). When is activeBar assigned?

                    I've made a test script and attached without that custom logic.

                    Below is a link to a video of the test.
                    https://drive.google.com/file/d/1QpN...w?usp=drivesdk
                    Attached Files
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      Hello ChelseaB,

                      I just tested the code you sent and everything is working exactly as I had intended from the outset of this project. The changes you made appear to have fixed all problems present. I cannot thank you enough for doing this for me. I leave you with what is hopefully the last question regarding this indicator: considering the final output is an array how should I reference this indicator (let's call it BuySellNetPressure) if I would like to use it in other indicator development? Such as a new indicator that takes a fast and slow moving average of this signal. I'll lead with some example logic that would just be printing out BuySellNetPressure values in a new indicator.

                      public class NewIndicator : Indicator
                      {
                      private BuySellNetPressure BSNP;
                      .
                      .
                      .
                      else if (State == State.DataLoaded)
                      {
                      BSNP = BuySellNetPressure();
                      }
                      .
                      .
                      .
                      protected override void OnBarUpdate()
                      {
                      Print(string.Format("{0} | BSNP[0]: {1}", Time[0], BSNP.Values[0][0]));
                      }

                      Does this look right to you? Particularly the part where I call on BSNP.Values[0][0], referencing that array has me a bit confused and I want to make sure this is the right way to do it. Thank you!

                      Comment


                        #26
                        Hello StoneMan78,

                        This is Jim responding on behalf of Chelsea who is out of the office at this time.

                        Values would be used to reference plots, which are effectively Series<double>'s. If you want to expose indicator values that are not plots so they can be referenced in another NinjaScript, you can create public properties and access those properties from your instantiated indicator in the hosting script. Please be sure to follow the practices Chelsea has provided for properly updating the indicator.

                        You may see an example for exposing indicator values that are not plots below. Depending on what you wish to expose, you could consider making multiple public Series<double>'s to expose values that should exist for each bar in the data series.

                        Exposing indicator values that are not plots - https://ninjatrader.com/support/help...alues_that.htm

                        We look forward to assisting.

                        Comment


                          #27
                          Hello Jim/ChelseaB

                          It sounds like there are a couple of ways to proceed here. I could either:

                          1.) Expose both of the component parts of the array in order to work with them in a new indicator.

                          Or

                          2.) Convert the array to a single value in the original indicator, making it more straightforward to work with when called upon in a new indicator.

                          I'm very curious if there is a way to do 2. If you look at the code ChelseaB sent me you can see that Values[0][0] is just the difference between two numbers. Would there be a way to convert that array into a simple double without losing any of the indicators functionality? Thank you so much the help. It is greatly appreciated.

                          Comment


                            #28
                            Hello StoneMan78,

                            Values[][] is an array of plot values and each plot is a Series<double>. Values[0] represents the Series<double> of the first added plot, Values[1] would represent the Series<double> of the second added plot.

                            Values[0][0] would reflect the current bar's value for the first plot and Values[1][0] would represent the current bar value of the second added plot.

                            Values[0][1] would reflect the previous bar's value for the first plot and Values[1][1] would represent the previous bar value of the second added plot.

                            I think it may be easiest to create two plots, and then instead of incorporating in an array, to save each value to a designated plot.

                            More information on creating plots and assigning values can be found here - https://ninjatrader.com/support/help...8/?addplot.htm

                            We look forward to assisting.

                            Comment


                              #29
                              Hello,

                              Thank you for the explanation in how Values[][] works Jim. It really helped me understand what was going on. When I look at the code and see only Values[0][0] is being used, I interpret that as only one Series<double> is being used. So my thinking is it would be easier to just declare the Series<double> outright instead of storing it in an array. I tried to take a pass at this using two different methods but ran into the error code "The type 'NinjaTrader.NinjaScript.Indicators.BuySellNetPres sure' already contains a definition for 'NetPressure'" when I tried to name my double NetPressure. It looks like NetPressure is used in the #region Properties but I'm not sure how that ties into the rest of the indicator. When I changed the double to the name NetP I ran into the error code "Cannot apply indexing with [] to an expression of type double". The two attached screen shots show how I attempted to implement a couple of different solutions, the third shows the conditions of OnStateChange for completeness where no changes were made. Am I wrong in my thinking that an array is not necessary here? If not is there a way around these error codes? Thank you so much for your continued support it is greatly appreciated.
                              Attached Files

                              Comment


                                #30
                                Hello,

                                I believe I may have found a solution. When I first set up the indicator in the setup wizard I defined NetPressure under the plots and lines section. When I used that variable for my plot (you can see in the code attached below) the indicator worked just fine. I have also attached the print the takes the values from buypressure - sellpressure used in the array and net pressure to show they are the same. While happy to have found a solution I am still not entirely clear on the process of defining variables under #region properties the way the wizard did for me. What is the difference between defining them here and in other sections? From the links I was sent it seems like this sort of definition would allow me to reference NetPressure in other indicators. Am I correct in that assumption? And if so what would the exact syntax for that reference be? Thank you for your continued assistance.
                                Attached Files

                                Comment

                                Latest Posts

                                Collapse

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