Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator in Minute TF with Ticks data from

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

    Indicator in Minute TF with Ticks data from

    Hi,

    I'm trying to read in a Renko bar chart info from POC indicator, so that I need tick data.

    I've included this sentence to read the tick data:

    else if (State == State.Configure)///
    {
    AddDataSeries(BarsPeriodType.Tick,1);
    }


    I hope it is correct.


    Still I'm printing the output to the output window, but it is there where I get the problems.

    I think my indicator calculates every bar as a "tick" bar, instead as a "Renko" bar, because I'm getting a lot of values at the output window for every time (several times per second).
    I really only want the values after a Renko bar is finished.

    I hope my question is clear

    Thanks,


    #2
    Hello artson,

    Thank you for your post.

    I wanted to clarify, are you applying this to a Renko chart and then trying to use the Renko data? Or are you trying to specifically add a secondary renko series?

    Adding a renko series requires the use of AddRenko: https://ninjatrader.com/support/help...htsub=addrenko

    I look forward to being of further assistance.

    Comment


      #3
      Hi, thanks,

      Ok, it is really not a Renko chart, but a "Momentum" chart, with similar bars to Renko, but better and which can be used for simulating.


      The chart is in these Momentum bars.
      I want to have the results from POC with every Momentum Bar....

      I hope it can be understood....

      Thanks

      Comment


        #4
        Hello artson,

        If this is a custom bars type, you may be able to add it by its ID. There is a sample of the syntax in the AddDataSeries tips:




        For example: AddDataSeries(new BarsPeriod() { BarsPeriodType = (BarsPeriodType)14, Value = 10, Value2 = 20 });

        To find the id of a BarsType you can use the following publically available indicator to identify bars types. https://ninjatraderecosystem.com/use...pe-identifier/


        I look forward to being of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello artson,
          are you applying this to a Renko chart and then trying to use the Renko data? Or are you trying to specifically add a secondary renko series?
          .
          Hi,

          I don't know really how to indicate to use a Renko data or another data loaded in the chart... Is it with Closes[1][0]?
          I've also tried it....

          I have indicated to calculate it only on bar close:
          if(State == State.SetDefaults)
          {
          Calculate = Calculate.OnBarClose;


          But still I get the printoutput with every tick.

          I've tried it with 5 minute bars, but also I get the printout every tick....

          It seems the "main" data is from the ticks, although in my chart I have it at 5 minute.
          How do I define which is the main DataSeries?, is it done with the TimeFrame from the Chart????

          Thanks again!

          Comment


            #6
            Hi again,

            Maybe I to explain me better....

            I have used the code from "SampleStreamWriter" printing to the output window



            namespace NinjaTrader.NinjaScript.Indicators
            {
            public class SampleStreamWriter : Indicator
            {
            private string path;
            private StreamWriter sw; // a variable for the StreamWriter that will be used

            protected override void OnStateChange()
            {
            if(State == State.SetDefaults)
            {
            Calculate = Calculate.OnBarClose;
            Name = "Sample stream writer";
            path = NinjaTrader.Core.Globals.UserDataDir + "MyTestFile.txt"; // Define the Path to our test file
            }

            // Necessary to call in order to clean up resources used by the StreamWriter object
            else if(State == State.Terminated)
            {
            if (sw != null)
            {
            sw.Close();
            sw.Dispose();
            sw = null;
            }
            }
            else if (State == State.Configure)///
            {
            AddDataSeries(BarsPeriodType.Tick,1);/// added to be able to read data from ticks. If not, I got an error message
            }
            Calculate = Calculate.OnBarClose;// I tried it here to read only when a primary chart bar (renko, 5 minute or similar) was finished, but din't work
            }

            @

            protected override void OnBarUpdate()
            {
            if(CurrentBars[0] > 10)
            {
            if (IsFirstTickOfBar)// I tried it also......., but no difference without it
            {
            SimplePoc55 ipocA;
            TimeSpan starttime = new TimeSpan(00,30,00);
            TimeSpan endtime = new TimeSpan(23,00,00);
            ipocA = SimplePoc55(4, starttime, endtime);
            double pocbA=ipocA.POCB[0];
            Print(Times[0][0] + "," + Opens[0][0] + "," + Highs[0][0] + "," + Lows[0][0] + "," + Closes[0][0] + "," + pocbA + "," + CurrentBar);
            }
            }
            }
            }
            }



            and the results are:
            ...
            01/05/2019 11:25:00,26669,26671,26667,26670,26669,274856 -> the tick bar number....
            01/05/2019 11:25:00,26669,26671,26667,26670,26669,274857
            01/05/2019 11:25:00,26669,26671,26667,26670,26669,274858
            01/05/2019 11:25:00,26669,26671,26667,26670,26669,274859
            01/05/2019 11:25:00,26669,26671,26667,26670,26669,274860
            01/05/2019 11:25:00,26669,26671,26667,26670,26670,274861
            01/05/2019 11:25:00,26669,26671,26667,26670,26670,274862
            01/05/2019 11:25:00,26669,26671,26667,26670,26670,274863
            01/05/2019 11:30:00,26669,26671,26668,26670,26669,683
            01/05/2019 11:30:00,26669,26671,26668,26670,26670,274864
            01/05/2019 11:30:00,26669,26671,26668,26670,26670,274865
            01/05/2019 11:30:00,26669,26671,26668,26670,26669,274866
            01/05/2019 11:30:00,26669,26671,26668,26670,26669,274867
            01/05/2019 11:30:00,26669,26671,26668,26670,26668,274868
            01/05/2019 11:30:00,26669,26671,26668,26670,26668,274869
            01/05/2019 11:30:00,26669,26671,26668,26670,26668,274870


            Comment


              #7
              Hello artson,

              Thanks for clarifying with your code example.

              Each data series will call OnBarUpdate() when its bar closes. In this case, you are getting a tick print because the tick data series bar closed and also the bool (IsFirstTickOfBar) would be true for each data series when that series' bar closes (when using Calculate.OnBarClose you only get 1 tick for the bar so IsFirstickOfBar would still be true but clearly at the end of the bar).

              If you only want to print when the Renko Bar calls the OnBarUpdate() then you would need to segment your code so that it only executes when you wish. This is done by using the BarsInProgress[n], where "n" is the number of the bars array that is calling the OnBarUpdate. BarsInProgress[0] will always be the chart bars, BarsInProgress[1] will be the first added data series, BarsInprogress[2] would be the 2nd added and so on for each added data series.
              Reference: https://ninjatrader.com/support/help...inprogress.htm The examples shown in the help guide will show you how to segment your code by BarsInProgress.

              To get a better view of how to work with Multi Time frame (or series) coding we highly recommend a complete review of: https://ninjatrader.com/support/help...nstruments.htm

              Comment


                #8
                Hi, Thanks, thanks, thanks a lot! it works from the very beginning!!

                Comment


                  #9
                  Hi again,

                  Today, I'm in a chart with a primary dataseries and I want to calculate the POC of another dataseries in Momentum bars (I know its ID index).
                  But I get the message "...tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attemted do load FDAX ##-## Eurex: 1 tick"

                  In my OnStateChange I have:

                  else if (State == State.Configure)
                  {
                  AddDataSeries(BarsPeriodType.Tick,1);// 1 - - reading ticks
                  AddDataSeries("FDAX ##-##", (BarsPeriodType)15, 80 );// 2 - - adding the dataseries from the momentum bars
                  }
                  else if (State == State.DataLoaded)
                  {
                  ipocA = SimplePoc55(BarsArray[2], 10, starttime, endtime);// - -> is this defining a "local indicator"?
                  }



                  and when I have inside the OnBarUpdate():

                  pocbA=ipocA.POCB[0];

                  I get this message in the output window:
                  "...tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attemted do load FDAX ##-## Eurex: 1 tick"

                  how can I read the poc value inside the OnBarUpdate()?

                  Thanks

                  Comment


                    #10
                    Hello artson,

                    Thanks for your reply.

                    For future reference, we recommend creating a new topic when the post does not relate to the topic title, this helps us keep the forum organized, thanks for your understanding.

                    Regarding ipocA did you create a private instance of it at the class level? private SimplePoc55 ipocA;

                    Comment


                      #11
                      Hi,

                      Regarding ipocA did you create a private instance of it at the class level? private SimplePoc55 ipocA;
                      Yes, I did, in the "variable" region.

                      For future reference, we recommend creating a new topic when the post does not relate to the topic title, this helps us keep the forum organized, thanks for your understanding.
                      **I wrote it here, because I thought it was related, and it was also a topic started from me..., sorry

                      Comment


                        #12
                        Hello artson,

                        Thanks for your reply.

                        When calling an indicator that loads data, the calling script (host) is responsible for providing that data. I suspect the indicator SimplePoc55 may be based on a 1 tick data series to perform its calculations.

                        Try adding a 1 tick data series of FDAX ##-## in addition to what you have.

                        Comment


                          #13
                          Thanks,

                          I have this
                          "AddDataSeries(BarsPeriodType.Tick,1);// 1 - - reading ticks"
                          is this not enough??

                          Comment


                            #14
                            Hello artson,

                            Thanks for your reply.

                            That would add 1 tick series of the chart instrument. Is the chart instrument FDAX ##-## as the error message specifies?

                            Comment


                              #15
                              Yes, the chart Instrument is the same: FDAX ##-##

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              574 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X