Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Analyzer & Series<double>

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

    #16
    Hello Harry,

    Calling an indicator from the market analyzer is going to work like a strategy calling the indicator, if you do not call the indicator first its values will not be updated. Please see Update Section of our helpguide,



    You are referencing the indicators series rather than calling the indicator itself, which is why you may not be seeing OnBarUpdate triggered.

    If you call myIndicator(); prior to myIndicator.ExposedSeries[0], does the indicator values update without having to include Update()?

    In this case where you are not setting a plot but rather a series, and need that series updated, would be an example where you would require the use of Update.

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

    Comment


      #17
      Hello Alan,

      Thank you for your quick reply.

      I have basically used the same approach as you suggested per attachment in post #2 of this thread. If you look at your code, you will find that expPlot.BullIndication[0] is directly called without calling the indicator first.

      Usually this works, and OnBarUpdate() is called from within OnMarketData. However, for unknown reasons it did not work with all of my indicators.

      Indeed, there are two remedies to the problem

      - either call the indicator or a regular indicator plot first
      - or add the Update() instruction to the properties sections for the exposed non-plot series

      I was just trying to find out, why these remedies are needed in some case, while other non-plot series may be accessed without them.

      Comment


        #18
        Hello Harry,

        Would you be able to provide a simple script which demonstrates the behavior please?

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

        Comment


          #19
          Originally posted by NinjaTrader_AlanP View Post
          Hello Harry,

          Would you be able to provide a simple script which demonstrates the behavior please?

          I look forward to your reply.

          The script that I have used is more or less a copy of your sample from post #2. As the indicator that is called by the market analyzer column is a multi-timeframe indicator, I needed to include an instruction to add the bars added by the indicator in State.Configure().

          I have tested this approach with a simple MTF indicator and it worked. The exact same approach does not work, when used with a complex MTF indicator that performs a higher number of computations.

          Please find attached a sample for the simple MTF indicator. When using the market analyzer column with this indicator, OnBarUpdate() is triggered and it is not needed to call the indicator itself prior to the exposed series. The exaxt same approach applied to other MTF indicators may not work without the Update() instruction in the getter.
          Attached Files

          Comment


            #20
            Hello Harry,

            Thank you for the script.

            After I modified the SMA period of the script so that it would teeter on the side of true/false (1 vs -1), I was able to get the indicator to correctly update as long as the Data Series had enough days back. The MA by default sets Bars To Load at 50, so if this is applied to a 1 minute period, you wouldn’t even have 1 period of your secondary series of 60 minute.

            I put together a video of two instances of the column added to the MA window, the only difference is one has Days Back set to 5 and the other with 100 Days Back. The one with ample data is correctly updating.

            Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


            2 Seconds into the video the 2nd instance (far right on the MA window) changes from -1 to 1, whereas the first column remains set at -1.

            Are you able to replicate on your end?

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

            Comment


              #21
              Hello Alan,

              Just to be clear. The script that I had sent you worked on my PC without any problems.

              However, I had an identical script for another more complex multi-timeframe indicator, where OnBarUpdate() could not be called. I am unable to post this complex indicator here, because it is a protected assembly.

              This means that the concept that you suggested works as long as the indicator is simple and fast, but it does not work any more, if the indicator is more complex and slow.

              This points to race conditions related to the multi-threaded architecture of NinjaTrader 8. I had to code around that problem by inserting an Update() instruction in the getter of the series of that complex indicator.

              As the sample concept does not work in all cases - due to multi-threading synchronization issues -, I just wanted to check with you which of the two options is a better choice

              - inserting the Update() instruction in the getter for the non-plot Series <double>
              - or calling the indicator prior to calling the exposed series in the OnMarketData() section of the MarketAnalyzerColumn.

              Comment


                #22
                Hello Harry,

                Without a sample to demonstrate behavior we are unable to diagnose on our end. If you can put one together that would be helpful.

                You could make the case Update() is better as its documented in the helpguide, however both approaches accomplish the same thing.

                If you can get together a sample together we would be interested in testing on our end.

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

                Comment


                  #23
                  Hello Alan,

                  I have now tested market analyzer columns for multi-timeframe indicators with the market analyzer and the conclusion is that the market analyer columns do not work.

                  The Market Analyzer Columns do not properly update and return false values.

                  This is what I did: I have fed values into a series <double> inside the indicator and exposed it via a property. I have also added an Update() instruction inside the public Series prior to the getter:

                  Code:
                  public Series<double> TradeSignal
                  {
                        Update();
                        get { return tradeSignal; }
                  }
                  The public series TradeSignal can be used with the strategy builder (after adding the instructions to load the secondary bars in State.Configure), returns meaningful results when running a strategy and does everything what is expected.

                  However, when calling the public series from a market analyzer column,

                  Code:
                  if (marketDataUpdate.MarketDataType == MarketDataType.Last)
                  {      
                       CurrentValue = myIndicator.TradeSignal[0];
                  }
                  the output is just rubbish. I have inserted print instructions inside the code of the indicator, and this confirms that it is not calculating correctly, as it is not fed with data as needed. It is a big mess, such that market analyzer columns may not be used with any multi-timeframe indicators.

                  Only very simple multi-timeframe indicators such as the sample from post #19 of this thread will return values correctly. I suspect that the problem may be connected to race conditions in a multi-threading environment.

                  Comment


                    #24
                    Other than the difficulties described below, I have seen serious issues with the database cache.

                    I had the market analyzer running for a few hours and then closed my workspace and shut down NinjaTrader as I went for lunch. When I came back and restarted NinjaTrader, loaded the workspace with the market analyzer and connected to my data feed, all rows and columns only showed the value 0.

                    There was no way to get the market analyzer working again, until I had the idea to shut down NinjaTrader and delete the entire data base cache (NinjaTrader 8 -> db -> cache). This fixed the issue and the market analyzer worked again.

                    I am not sure, but maybe the first problem is also related to the database cache.

                    Comment


                      #25
                      Hello Harry,

                      Would you be able to put together a sample so we may test on our end?

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

                      Comment


                        #26
                        Hello Alan,

                        I am still running into issues with custom market analyzer columns.

                        Basically I am comparing the values for a DataSeries (public Series <double>) when running on a chart against the values for the same DataSeries when displayed via a market analyzer column.

                        The comparison can be achived by adding a print instruction in OnBarUpdate() and filtering this instruction with (ChartBars != null). This will only show the signals when created on the chart, but eliminated signals from running the indicator via the market analzyer column.

                        I have also added a print instruction inside the market analyzer column. This allows for showing that the values returned via the market analyzer are false, although I have followed all instructions as usual.

                        Conclusion here:

                        Market Analyzer Columns do not work with MTF indicators. Probably one of the more complex NinjaTrader bugs. I believe it is impossible to discuss the issue here, but would appreciate, if I could explain the issue to someone.

                        I believe that it is a garbage in - garbage out situation, where the DataSeries called by the market analyzer column is fed with false ticks and therefore returns false results. That said, I have coded hundreds of market analyzer columns for non MTF indicators which are working flawlessly. False data input only seems to occur when an indicator adds a secondary bar series.
                        Last edited by Harry; 10-01-2018, 09:59 AM.

                        Comment


                          #27
                          Hello Harry,

                          Could you please send an email to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread.

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

                          Comment


                            #28
                            Hello Alan,

                            Sorry for not coming back earlier. I have had a bad flu and then working again on this subject. I am still running into issues when calling Series<double> objects from a market analyzer column, where the Series<double> relates to BarsArray[0] in a multi-timeframe indicator that loads a series of secondary minute bars. I am not trying to call any series<double> running on BarsArray[1], but just a simple Series<double> running on the primary bars.

                            My analysis has shown that the indicator output from OnBarUpdate() for the Series<double> is different, depending on

                            - whether OnBarUpdate() is called from an indicator applied to a chart
                            - or whether OnBarUpdate() is called from the same indicator instantiated from a market analyzer column

                            In the second case that indicator returns garbage. The indicator itself has been tested with charts, the strategy builder and Bloodhound and works as expected.
                            From this result I am deducting that the indicator, when running in a market analyzer column is fed with false input data, as NT is possibly not correctly differentiating between ticks for primary and secondary bars.

                            For testing this I have put a condition into the code whether ChartBars == null. This conditions will return the value "true", when the indicator is called from the market analyzer, but return "false" when the same indicator is called from a chart. This allows for comparing the values returned in real-time. Everything returned from the market analyzer is garbage and cannot be used, while OnBarUpdate() called from the same indicator added to a chart is returning correct results.

                            I will contact you as requested above.

                            Comment


                              #29
                              Hello Harry,
                              Hope you are feeling better.

                              What settings are you using for that indicator in the Market Analyzer and what settings are you using for that indicator on your chart? Are they set to different periods? Different Calculate settings?
                              Josh G.NinjaTrader Customer Service

                              Comment


                                #30
                                Originally posted by NinjaTrader_JoshG View Post
                                Hello Harry,
                                Hope you are feeling better.

                                What settings are you using for that indicator in the Market Analyzer and what settings are you using for that indicator on your chart? Are they set to different periods? Different Calculate settings?
                                Hello Josh,

                                Thank you for coming back.

                                Settings are 100% identical. Exactly same parameters, same instrument, same chart interval, both instances set to Calculate.OnEachTick. I have also paid attention to the lookback period required by the indicator (training period) and used a lookback period of 1,000 bars or 5 days for a 2 minute chart.

                                The problem only occurs with a MTF indicator. Have never seen this happen with simple indicators, although I have coded hundreds of MA columns.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by rocketman7, Today, 09:41 AM
                                2 responses
                                4 views
                                0 likes
                                Last Post rocketman7  
                                Started by traderqz, Today, 09:44 AM
                                1 response
                                4 views
                                0 likes
                                Last Post traderqz  
                                Started by rocketman7, Today, 02:12 AM
                                7 responses
                                31 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by guillembm, Yesterday, 11:25 AM
                                3 responses
                                16 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by junkone, 04-21-2024, 07:17 AM
                                10 responses
                                150 views
                                0 likes
                                Last Post NinjaTrader_BrandonH  
                                Working...
                                X