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

Multiple DataSeries

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

    Multiple DataSeries

    Hi, I'm using AddVolumetric in my chart, which I think creates a separate data series in my script. I want to plot values on the first data series, based on values of secondary data series. How do I update the Values object this way?

    #2
    Hi shildebrand324, thanks for posting.

    Please make sure to fully read and understand this page on multi time frame scripts:
    https://ninjatrader.com/support/help...venOnbarupdate Method

    The section I highlighted shows how to filter the primary and secondary bar series. e.g.in OnBarUpdate

    Code:
    if(BarsInProgress == 0)
    {
        //OnBarUpdate called for primary series, fill in Plots here
    }
    if(BarsInProgress == 1)
    {
        //OnBarUpdate called for secondary series, save values here for use in BIP = 0. 
    }


    I also made a related example here:


    Kind regards,
    -ChrisL
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. But how do I update the plot values in the main data series, with the values from my volumetric data series? Currently seems like my plots are off by one bar.

      Comment


        #4
        Hi, thanks for the follow-up. The multi-time frame guide also covers this topic in this section:



        The script will need to run OnPriceChange or OnEachTick in Real Time to get the secondary bars to update in this way.

        Also see this example that shows how you can separate OnBarClose logic from OnEachTick logic:



        Kind regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the example...I'm still not understanding. I have 3 plots that all need to come from the Volumetric data series, and show those values in plots in the primary data series. Is there an example of that?

          Comment


            #6
            Hi, thanks for the follow-up. Unfortunately, we do not have a specific example demonstrating this. I have given all the possible information needed to complete the task. Please make sure to fully read this documentation and test out the behavior on your script after changing the Calculate property to see how it behaves differently.

            Kind regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Click image for larger version  Name:	Screenshot 2022-10-25 122452.png Views:	0 Size:	11.6 KB ID:	1220859

              Hi, I've read and read and read and understand what the articles are saying, but just can't seem to get my marking to show on the correct bar

              I've got the following, and when the * marker prints, some of them print off the bars, like it's a bar off. Please help.

              else if (State == State.Configure)
              {
              AddVolumetric(null, BarsPeriodType.Tick,BarsPeriod.Value,VolumetricDel taType.BidAsk,1);


              }

              protected override void OnBarUpdate()
              {

              if (BarsInProgress == 1) {
              if (Bars == null)
              return;

              NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsSeries.BarsType as
              NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

              if (barsType == null)
              return;
              try
              {
              Print(Time[0] + " ================================================== =======================");

              Print("Maximum Ask: " + barsType.Volumes[CurrentBars[1]].GetMaximumVolume(true, out price) + " at price: " + price);
              Print("Maximum Bid: " + barsType.Volumes[CurrentBars[1]].GetMaximumVolume(false, out price) + " at price: " + price);
              Print("Maximum Combined: " + barsType.Volumes[CurrentBars[1]].GetMaximumVolume(null, out price) + " at price: " + price);


              Text myText = Draw.Text(this, CurrentBars[0].ToString() + @" POC", true,"*", 1, price, 0, Brushes.DarkOrange, font, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
              myText.IsSeparateZOrder = true;
              myText.ZOrder = 1000000;


              }
              catch{}

              }

              }​​
              Attached Files

              Comment


                #8
                Hi shildebrand324, thanks for the follow up. The secondary series is always processed after the primary series. You should be drawing the dot within the primary series, not in BarsInProgress == 1. What should be done is, save the latest values of the Volumetric bar in BIP =1 and draw the dot in BIP = 0. You can also debug this by using Print to print out the CurrentBars[] value of each series to see why it's printing a bar behind e.g.

                Print(CurrentBars[0]);
                Print(CurrentBars[1]);

                This will let you compare the CurrentBar value and you can see why your script is drawing a bar behind.

                Kind regards,
                -ChrisL
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Okay, moved the drawing to BarsInProgress == 0 and seems to be a little closer...could there be an issue that I'm using tick charts for primary and volumetric? When I watch in real time live, it seems the POC is good for part of the time, but will fall out of sync near the end of the tick cycle.

                  CurrentBars[0] seems to always be 1 behind CurrentBars[1]
                  Last edited by shildebrand324; 10-25-2022, 11:38 AM.

                  Comment


                    #10
                    Hi shildebrand324, thanks for the follow up.

                    It depends on what bar series you are using for the primary and secondary series. If the Tick bars are the same value then they will line up together but if there are different Tick bars then they will have different timestamps, so you will get unexpected results when you try to plot on timestamp X when X does not exist on the primary series.

                    Kind regards,
                    -ChrisL
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      I am using 2000 tick for primary and 2000 tick volumetric for the secondary

                      Comment


                        #12
                        Seems like when I do a reload is when it gets messed up, or if I switch to another chart. If I'm watching live, seems okay.

                        Comment


                          #13
                          Hi shildebrand324, thanks for the follow up.

                          If your script is running OnEachTick please make sure to enable Tick Replay for the historical run. The secondary series will be closed after the primary series closes in historical mode when Tick Replay is off.


                          Kind regards,
                          -ChrisL
                          Chris L.NinjaTrader Customer Service

                          Comment


                            #14
                            So, tick replay is only need when looking at non-live chart?

                            Comment


                              #15
                              Is there a way to get wicks to show on Volumetric?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RookieTrader, Today, 09:37 AM
                              3 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by kulwinder73, Today, 10:31 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post kulwinder73  
                              Started by terofs, Yesterday, 04:18 PM
                              1 response
                              23 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by CommonWhale, Today, 09:55 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by Gerik, Today, 09:40 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post Gerik
                              by Gerik
                               
                              Working...
                              X