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

AddDataSeries vs AddRenko - Errors and Incorrect Plotting

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

    AddDataSeries vs AddRenko - Errors and Incorrect Plotting

    Hello:

    I have a few messages on this board about issues I have been having about getting an indicator to plot using a secondary data series. Over this last week, I have been experimenting with suggestions from the help team on this forum, and so far, I still cant get it to work.

    I will summarize what I have done to resolve these issues below:

    I have a custom bar type that plots correctly and a custom indicator that also plots correctly when applied to a chart. What I am trying to do is take this working indicator and plot it a second time on the same chart with double the current charts bar value. This is where my problem comes in.

    I began this journey by using AddDataSeries to add my second second data series. The produced an error

    All data must first be loaded by the hosting NinjaScript in its configure state.
    Support personal on these forums recommended that I use AddRenko(), which resulted in incorrect plotting.

    If I create a new chart and apply this indictor to the chart with the custom bars, whose Bars.BarsPeriod.Value is = 8 I receive the following values at time stamp (Feb 12, 2019 @0356.30)
    Up = 1528.7
    Dn = 1528.6
    These values are correct values on the Bars.BarsPeriod.Value = 8 chart. I then create a new, second chart, whose Bars.BarsPeriod.Value = 4. I apply this indicator to that chart and it also plots correctly. I then apply a second version of this indicator, pulling data from the secondary data series using AddRenko onto the Bars.BarsPeriod.Value = 4 chart using the following code:

    //_DoubleBarPeriod = Bars.BarsPeriod.Value;
    _DoubleBarPeriod = Bars.BarsPeriod.Value * 2;
    BarsPeriodType bt = this.Bars.BarsPeriod.BarsPeriodType;
    string iName = Instrument.ToString();

    Print("barP= " + _DoubleBarPeriod.ToString());
    //AddDataSeries(BarsPeriodType.Tick, _DoubleBarPeriod);
    //AddDataSeries(bt, _DoubleBarPeriod);
    //AddRenko(Instrument.ToString(), 8, MarketDataType.Last);
    AddRenko(Instrument.ToString(), _DoubleBarPeriod, MarketDataType.Last);
    This second version of the same indicator, using data values from BarsInProgress == 1, plots incorrect values. Again looking at time stamp (Feb 12, 2019 @0356.30) on my Bars.BarsPeriod.Value = 4 chart, this secondary data series plots 1529.3 instead of 1528.7for up and 1529.2 instead of 1528.6 for down. I get the same values when I use the
    _DoubleBarPeriod variable or when I simply hardcode the value of 8 into the AddRenko function.

    When I right click on the
    Bars.BarsPeriod.Value = 4 chart and add a dataseries to the second panel whose resulting Bars.BarsPeriod.Value = 4, then apply the orginal indicator to the second panel data series (the one that dose not pull from a secondary data set) i receive the correct plots, but this requires a second data series in a second panel with the indicator plotted in the second panel instead of panel one. This is making the charts too clustered.

    I am looking for any other suggestions on how to resolve this value discrepency.

    Thaks


    Last edited by jeliner; 02-12-2019, 10:33 AM.

    #2
    Hello jeliner,

    Thanks for your post.

    Although not the issue you are currently facing, we do not support dynamically using variables or objects that are dependent on data being loaded with AddDataSeries() methods in State.Configure. We would recommend passing null for the instrument name to use the primary data series and we recommend to hard code other values. Please see AddDataSeries documentation for more details.

    AddDataSeries() - https://ninjatrader.com/support/help...dataseries.htm

    If you are trying to plot data based off of a secondary data series, we recommend setting a temporary variable to hold the plot value, and then assign the plot value on the next BarsInProgress == 0 iteration. This is advised because the indicator plot will be synchronized to the primary data series. I have included an example that can be used for reference.

    If you are seeing results that you would not expect for your plot following this approach, I would suggest to take debugging steps to print out the values used to calculate the plot and what is being stored in your temporary variable which then gets plotted later. If you follow the number back, you will be able to get a better idea on why it is calculating the values you are receiving.

    BarsInProgress 1 Iteration > Calculate value to plot > store value in temporary variable > BarsInProgress 0 Iteration > assign temporary variable to Values[][] or the Plot's Series

    Our Multi Time Frame and Instruments documentation provides a complete walkthrough for building multi series script and using BarsInProgress to identify which data series is iterating in OnBarUpdate().

    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    Please let me know if I can be of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Although not the issue you are currently facing, we do not support dynamically using variables or objects that are dependent on data being loaded with AddDataSeries() methods in State.Configure. We would recommend passing null for the instrument name to use the primary data series and we recommend to hard code other values. Please see AddDataSeries documentation for more details.



      Yes I am aware of this issue. Right now, I am getting the same values weather I pass variables or hard code the values. Between the symbols and time frames, I have 144 variations on thes values. When I know this indicator is working, I will create 144 versions to support the symbols and time frames. I would suggest to NT that they fix this particular issue. What if I wanted to distrubute this indicator later. Its not reasonable for this to work this way, there would be litterally millions of versions of this indicator to support this issue.

      I have read your suggestion about assigning the value during BarsinProgress==1 and then adding those to a dataseries when the BarsinProgress == 0. I considered that as a posibility before I wrote my first message and implemented a test using that approach. It still provided the wrong values.

      I did as you suggested and obtained values using print statements. On the Bars 4 chart, the output of this particular area is ...


      BarsInProgress = 1 jelValue = 1529.30365591398 smoothValue = 1528.95073978487
      BarsInProgress = 0 jelValue = 1529.30365591398 smoothValue = 1528.95073978487
      BarsInProgress = 0 jelValue = 1529.30365591398 smoothValue = 1528.95073978487
      BarsInProgress = 0 jelValue = 1529.30365591398 smoothValue = 1528.95073978487
      BarsInProgress = 0 jelValue = 1529.30365591398 smoothValue = 1528.95073978487
      BarsInProgress = 0 jelValue = 1529.30365591398 smoothValue = 1528.95073978487
      BarsInProgress = 0 jelValue = 1529.30365591398 smoothValue = 1528.95073978487
      BarsInProgress = 1 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 0 jelValue = 1529.32107526882 smoothValue = 1529.24084442518
      BarsInProgress = 1 jelValue = 1529.55720430107 smoothValue = 1529.32082083981
      This is the chart ….



      The green values plotted above with the output before it represents the values of the second data series. For the sake of eliminating the variables passed into the AddRenko() function as a possibility, the values are hardcoded for this test as follows:

      AddRenko(null, 8, MarketDataType.Last);
      Making this change produced the same results with variables instead of hardcoded values.

      The values of this area that I should be receiving from the larger bar size (8) are as follows:


      jelValue = 1527.35763440859 smoothValue = 1527.0389091087
      jelValue = 1527.31720430107 smoothValue = 1527.10848290679
      jelValue = 1527.43505376343 smoothValue = 1527.19012562095
      jelValue = 1527.60451612902 smoothValue = 1527.29372324797
      jelValue = 1527.82559139784 smoothValue = 1527.42669028544
      jelValue = 1527.99161290322 smoothValue = 1527.56792093988
      jelValue = 1528.14559139784 smoothValue = 1527.71233855437
      jelValue = 1528.28236559139 smoothValue = 1527.85484531363
      jelValue = 1528.5034408602 smoothValue = 1528.01699420027
      jelValue = 1528.76064516128 smoothValue = 1528.20290694052
      jelValue = 1528.85096774193 smoothValue = 1528.36492214087
      jelValue = 1528.88623655913 smoothValue = 1528.49525074544
      jelValue = 1528.87161290322 smoothValue = 1528.58934128488
      jelValue = 1528.81225806451 smoothValue = 1528.64507047979
      jelValue = 1528.71333333332 smoothValue = 1528.66213619317
      jelValue = 1528.67634408601 smoothValue = 1528.66568816638
      jelValue = 1528.63763440859 smoothValue = 1528.65867472693
      jelValue = 1528.69870967741 smoothValue = 1528.66868346455
      jelValue = 1528.81139784945 smoothValue = 1528.70436206078
      jelValue = 1528.97569892472 smoothValue = 1528.77219627676
      jelValue = 1529.19161290322 smoothValue = 1528.87705043338
      jelValue = 1529.25612903225 smoothValue = 1528.9718200831
      jelValue = 1529.28107526881 smoothValue = 1529.04913387952
      jelValue = 1529.27161290322 smoothValue = 1529.10475363545
      jelValue = 1529.43591397849 smoothValue = 1529.18754372121
      jelValue = 1529.56064516128 smoothValue = 1529.28081908123
      jelValue = 1529.68881720429 smoothValue = 1529.38281861199
      The bolded area above is seen in the chart below:



      As you can see, nothing is lining up. The blue plots on the 8 bar chart is supposed to be the green plots on the 4 bar chart. I have place a data window on the side showing the values in the same time spot of both charts. In this particular area, the values are off by 5 ticks. This may seem like straining hairs, but a comparison is made on these values that changes the color of the plot and its causing the colors to plot incorrectly as well. The color issue is directly related to the incorrect values passed into the coloring logic. The color and placement do have meaning on what I am trying to accomplish.

      Also, This issue is much worse at larger bar values such as replacing the 4 with 50 which would require a secondary data series of 100 bars and not 8. I am using smaller bar values to help pinpoint were the error could be.
      Last edited by jeliner; 02-12-2019, 06:23 PM.

      Comment


        #4
        Hello jeliner,

        I have submitted a vote on your behalf for SFT-882 where we are tracking interest to dynamically add data series.

        I am not seeing an issue with the way the value is plotting, although it does look you are performing some math in your prints which may be clouding the matter. We should expect a jaggy plot line since we only get a new bar for the secondary data series every so many number of bars for the primary series.

        I created a video demonstration explaining how we can expect this data to be plotted. I suggest to take a similar approach as I have to first check that you can plot the raw data series values for the secondary series. This is how we should expect the data to be plotted. After confirming this, I would then suggest to add your math to the plot to make it more meaningful to your study.

        Demo - https://drive.google.com/file/d/12XV...w?usp=drivesdk

        If this does not resolve your inquiry, could you illustrate what you are expecting to see when only presenting the secondary series price values as a plot on the primary series?

        I look forward to being of any further assistance.
        Last edited by NinjaTrader_Jim; 02-13-2019, 07:57 AM. Reason: Corrected demo link
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello jeliner,

          I have submitted a vote on your behalf for SFT-882 where we are tracking interest to dynamically add data series.

          I am not seeing an issue with the way the value is plotting, although it does look you are performing some math in your prints which may be clouding the matter. We should expect a jaggy plot line since we only get a new bar for the secondary data series every so many number of bars for the primary series.

          I created a video demonstration explaining how we can expect this data to be plotted. I suggest to take a similar approach as I have to first check that you can plot the raw data series values for the secondary series. This is how we should expect the data to be plotted. After confirming this, I would then suggest to add your math to the plot to make it more meaningful to your study.

          Demo - https://ninjatrader.com/support/foru...rrect-plotting

          If this does not resolve your inquiry, could you illustrate what you are expecting to see when only presenting the secondary series price values as a plot on the primary series?

          I look forward to being of any further assistance.
          I don't see the video you mentioned. The images that I posted in the prior message contained only the indicator with the plot in question. There are two versions of the indicator, one where the math applies values to a local variable during BarsinProgress==1. Those values are then added to the Values[0] and Values[1] data series when BarsinProgress==0. In the other version of the indicator, the same math is applied and stored in local variables. However, there is no BarsinProgress sections because there is no data series on the high time frame. The print statements in both are generated just before the values are added to the Values[0] and Values[1] datasets respectively.

          Comment


            #6
            Thanks for the catch, I've updated the link in post #4.

            The demo will show what we can expect to see since the plot that is synchronized to the primary data series. We are essentially only displaying the last update seen for the secondary data series at the time the primary data series calculated a bar.

            You should be able to get your secondary series to print out in the same way and that is how we would expect to see that data plotted. I recommend using a Price Series like Close and add similar prints to verify data is getting plotted in this fashion properly, and then to add the math in second.

            I look forward to being of further assistance.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by BarzTrading, Today, 07:25 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by EB Worx, 04-04-2023, 02:34 AM
            7 responses
            161 views
            0 likes
            Last Post VFI26
            by VFI26
             
            Started by Mizzouman1, Today, 07:35 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Radano, 06-10-2021, 01:40 AM
            20 responses
            616 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by i019945nj, 12-14-2023, 06:41 AM
            6 responses
            68 views
            0 likes
            Last Post i019945nj  
            Working...
            X