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

Custom Market Analyzer Columns

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

    Custom Market Analyzer Columns

    I am regularly running into issues when developing custom market analyzer columns, Indicators are not called or bars are not properly synchronized. Maybe the code I am using is not correct.
    I would like to post a few samples here:

    Market Analyer Columns are based on a sample script ExposedPlotMA distributed by NinjaTrader. The sample script is attached,

    I have now taken the NinjaTrader in-built PriorDayOHLC indicator and added a single DataSeries. The DataSeries returns a value of +1, if the instrument trades above yesterday's high, it returns a value of -1 if the instrument trades below yesterday's low and returns the value of 0, if the instrument trades inside yesterday's range. This is a simple, but powerful trend filter. The DataSeries is exposed via a public property. Other than DataSeries and public property the indicator is identical with the in-built PriorDayOHLC.

    In a second step I have created a simple market analyzer column calling the DataSeries of the modified PriorDayOHLC for display on the market analyzer. The market analyzer column follows the model posted by NinjaTrader support. However, the column does not call the indicator and nothing is displayed on the market analyzer.

    Would you have an idea what causes the malfunction? Is there anything missing?

    Please find the sample script and the market analyzer column for the PriorTrendOHLC attached.
    Attached Files

    #2
    Hello Harry,

    To use an indicator from the market analyzer column you would need to configure the column to support using bars.

    Code:
    IsDataSeriesRequired = true;
    You would also need to uncomment your OnBarUpdate in the column and the you can remove the other code you added to OnMarketData.

    I would also suggest to just make this a Plot if the purpose is a signal for the analyzer, you could do that like the following:

    Code:
    AddPlot(new Stroke(Brushes.SlateBlue,    DashStyleHelper.Dash,    2),    PlotStyle.Hash, "SignOfDay");
    
    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> SignOfDay
    {
    get { return Values[4]; }
    }
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      Thank you for your answer.

      However, this does not fix the problem. When I add "IsDataSeriesRequired = true", the market analyzer column still returns nothing,

      Also I cannot make the SignOfDay series an indicator plot, because the indicator plots on the price panel, while SignOfDay also returns negative values that would distort the chart.


      Harry

      Comment


        #4
        Hello Harry,

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

        We should note that we do not have full OnBarUpdate support in a MarketAnalyzerColumn, so we are limited with what we can do here.

        I find that Jesse's advise to use the plot is necessary to get the value to populate in the MarketAnalyzerColumn. I am also finding that creating a "Shell Indicator" that simply reads the public Series<double> and applies it to a plot will not work in this case. However, if the "Shell Indicator" performs the same calculation from the PriorDayOHLCTest indictor's plots to create a SignOfDay plot, this will work.

        Otherwise if you wanted everything in one script, you would be looking at custom rendering with SharpDX to draw your regular plots as per normal, and to ignore drawing anything for the SignOfDay plot.

        I have added the test scripts I was using to display SignOfDay here. In this case also, you could just add an Indicator MarketAnalyzerColumn to show the Shell Indicator's plot.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Hi Jim,

          Thank you for your explanation.

          I perfectly understand the workaround. However, this approach is somehow peculiar.

          I have coded quite a few indicators, and most of these have one or several non-plot data series that feed market analyzer columns. In fact NinjaTrader 7 was able to read these data series, while NinjaTrader 8 can no more read them. Therefore, it became necessary to use separate market analyzer columns for accessing the non-plot data series of the indicators. Most of the time these market analyzer columns work as expected, but in some cases they don't.

          Now you are suggesting that I use a shell indicator such that the master indicator feeds the shell indicator which then feeds the market analyzer column. However, in such a case the market analyzer column is not needed, because the market analyzer could directly access the shell indicator. So the whole idea of using market analyzer columns for displaying the output of a data series from indicators is taken ad absurdum.

          Also for the shell indicators I would then have to create a subfolder "ShellIndicators" that shows in the indicator dialogue box and hides the shell indicators which are not designed for applying them directly to a chart.

          Please let me summarize and ask two more questions:

          Coding separate market analyzer columns was a workaround to make the market analyzer access public non-plot data series from indicators. Now I understand that I need to add a shell indicator to feed the market analyzer column.

          1. In which case is such a shell indicator needed and why?

          I am asking this questions as I would like to understand in which cases shell indicators are needed and in which cased the market analyzer columns will work without.

          2. Is any solution available to code market analyzer columns without using an intermediate shell indicator?

          I would prefer not to have any shell indicators.

          Comment


            #6
            Hello Harry,

            1. In which case is such a shell indicator needed and why?

            I am asking this questions as I would like to understand in which cases shell indicators are needed and in which cased the market analyzer columns will work without.
            There may be other cases to outline with MarketAnalyzerColumns as using OnBarUpdate is not fully supported, but for this specific case, it is required when accessing a public Series<double> that is not a plot.

            2. Is any solution available to code market analyzer columns without using an intermediate shell indicator?
            The other solution then using a "Shell Indicator" to develop a new plot from existing plots of the original indicator, would be to implement the public Series<double> as a plot in the original indicator.

            As you noted, this would cause problems for rendering as the SignOfDay plot would affect the scaling of the indicator or price panel. Getting around the scaling means that you would have to take control of what specific plots get rendered using SharpDX and the OnRender method. This adds a bit of code for having one indicator that has all the bells and whistles to work well on a chart and serve your MarketAnalyzerColumn needs.

            I have an example indicator that describes how plots can be added dynamically that can show how to draw plot lines with SharpDX (Really it involves creating Series<double>'s in State.DataLoaded, and how you can draw plot lines in a similar fashion to a plot drawn from the indicator base class, but the render code would still be applicable.)

            As we can start to see, overriding OnRender without calling base.OnRender and drawing our own plot lines adds quite a bit of work to have an all-in-one solution. Creating a "Shell Indicator" would be much easier.

            (This example only demonstrates drawing lines with PathGeometry and does not demonstrate how to build other PlotStyles. I haven't gone that deep in the example.)
            Attached Files
            JimNinjaTrader Customer Service

            Comment


              #7
              Hello Jim,


              Thank you for your detailed explanations and the sample code.

              I am to some extent familiar with overriding OnRender and would be able to pick the plots that shall be displayed on the chart. As a result, "unwanted plots" only needed for the market analyzer will not be displayed. I think it is also possible to eliminate them from the data box by setting them to transparent in State.Configure().

              I will try this out, as it looks like a more elegant solution than adding a shell indicator.

              Comment


                #8
                I am looking into making a custom MarketAnalyzerColumn that would also use an indicator but OnBarUpdate is not being reliably called. I am curious how IndicatorsMarketAnalyzerColumn handles this. This is one of the few MarketAnalyzerColumns included with NinjaTrader for which the source code not included.

                Comment


                  #9
                  Hello ntbone,

                  There are several fixes included in the internal MarketAnalyzerColumn to make it work well with indicators and OnBarUpdate.

                  I cannot share what these internal fixes are, and I cannot comment if they can be easily implemented in an external MarketAnalyzerColumn script.

                  If we are able to create a better public facing example to help others explore this unsupported area, we will post here.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by algospoke, Yesterday, 06:40 PM
                  2 responses
                  20 views
                  0 likes
                  Last Post algospoke  
                  Started by ghoul, Today, 06:02 PM
                  3 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by jeronymite, 04-12-2024, 04:26 PM
                  3 responses
                  45 views
                  0 likes
                  Last Post jeronymite  
                  Started by Barry Milan, Yesterday, 10:35 PM
                  7 responses
                  21 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  10 responses
                  181 views
                  0 likes
                  Last Post jeronymite  
                  Working...
                  X