Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Storing manually drawn ray data of different time frame

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

    Storing manually drawn ray data of different time frame

    Hi,

    I am trying to customize an indicator where green triangle will be drawn when price is higher than ema and down trend ray line drawn manually and vice versa for uptrend for red triangle.

    I am trying to draw these green / red triangle on the same chart for all three time frames.

    so far, I have added additional data series for additional 2 barperiods and storing ema and price in a dictionary where barperiod is the key and value is ema/price. I have been able to draw the gree or red triangle so far for one time frame and it works fine. But I am confused whether is it possible to store manually rendered ray data like above or any other way in NT8 in different time frames, where these rays are drawn in different time frame?

    Any suggestion and direction towards correct way will be highly appreciated.

    Thanks in advance.

    #2
    Hello asmmbillah,

    Thanks for your post.

    For a manually drawn object, on the chart where your script is applied, you can iterate through the draw objects collection to find that draw object of interest and once found can then collect the information about that object (such as the start/end anchors price/time and then in the case of a Ray, project the rays value as previously shown in post #8 of your thread: https://ninjatrader.com/support/foru...pe-line-in-nt8

    Please see, "Looping through the collection to find specific draw objects" here: https://ninjatrader.com/support/help...rawobjects.htm

    Regarding, "I am confused whether is it possible to store manually rendered ray data like above or any other way in NT8 in different time frames, where these rays are drawn in different time frame?" A script would only be applicable to the chart that it is applied to.

    Comment


      #3
      Thanks for your reply.

      Comment


        #4
        Hi,

        I am using below code to store and print ema value for multi time frame on single chart:

        private Dictionary<string,EmaValue> emaValue = new Dictionary<string,EmaValue>();

        private class EmaValue
        {
        public double emaValue {get; set;}
        }

        foreach (KeyValuePair<string,EmaValue> kvp in emaValue)
        {
        string strBarsPeriod = kvp.Key;

        double emaPoint = (kvp.Value.emaValue);

        ClearOutputWindow();
        Print(DateTime.Now+"emaPoint value :"+emaPoint);
        }

        But Output window print for the emaPont value shows always 0, am I doing something wrong here?

        I will appreciate your help here. thanks in advance

        Comment


          #5
          Hello asmmbillah,

          Thanks for your reply.

          Forgetting about dictionaries for the moment, can you clarify if you trying to obtain the current value of the EMA on other time frames in your script or something more than that?

          Comment


            #6
            Thanks for your reply. I am trying to obtain current value of the ema on other time frames in my script and use it if statement for a condition to fillArrows on chart.

            Comment


              #7
              Hello asmmbillah,

              Thanks for your reply.

              If I may suggest it would be easier to obtain the current values by using something like:

              EMA(Closes[1], period1)[0] where Closes[1] points to the close series of the 1st added data series (period1 is whatever you need for that EMA)
              EMA(Closes[2], period2)[0] where Closes[2] points to the close series of the 2nd added data series (period2 is whatever you need for that EMA)

              Please see, " Using Bars Objects as Input to Indicator Methods" here: https://ninjatrader.com/support/help...nstruments.htm

              another example where using the same EMA period on 3 data series

              if (Closes[0][0] > EMA(Closes[0], 14)[0] && Closes[0][0] > EMA(Closes[1], 14)[0] &&Closes[0][0] > EMA(Closes[2], 14)[0]) // is the current price (closes[0][0]) greater than the EMA on the chart bars (Closes[0]), greater than the EMA on the 1st added series and greater than the EMA on the 2nd added data series.

              Please see the section, " Accessing the Price Data in a Multi-Bars NinjaScript" in the same link above.

              Comment


                #8
                thanks for your reply. Your suggestion is absolutely correct. but the problem is I have to use the plot this ema value relative to the time frame periods. that's why I need to use dictonary where time period is key and I am trying to store the ema as value and render the info on chart. I hope that make sense. I have made a quick clip for you to explain what I am trying to do and the link is below:
                https://www.dropbox.com/s/u6l6o69e9a...plain.mp4?dl=0

                I am also attaching the trimmed code related to the issue here with for your ref.
                Probably I am missing something. any help and direction to the rsolution will be very helpful.
                Last edited by asmmbillah; 09-19-2019, 08:53 AM.

                Comment


                  #9
                  Hello asmmbillah,

                  Thanks for your reply and appreciate the video.

                  You should still be able to use the current values, from each time frame, as I explained previously as it is much simpler and direct process As you are ultimately using the values in OnRender, what I recommend is that in OnBarUpdate() you access the current EMA values and store them in class level double values and then in OnRender() access those class level variables for the latest values. As you are using Calculate.OnEachTick you will be able to retrieve the very current values.

                  I've created a short script and applied that to a chart along with proof of how the values match what is shown on the other time frames: https://Paul-ninjaTrader.tinytake.co...Nl8xMTUxMjk0Nw

                  Comment


                    #10
                    Thanks for the reply and the clip. That was very helpful.

                    I would appreciate, if you could give a hint on how you would implement those EMA values in OnRender(). That could help me to make rest of the changes.

                    Thanks in advance.

                    Comment


                      #11
                      Hello asmmbillah,

                      Thanks for your reply.

                      At the class level, create double variables for each different EMA value to provide to Onrender(), example

                      private double ema1, ema2, ema3;

                      Here is an example specifically where the class level variables can be created:

                      public class PriceAlertNT8 : Indicator
                      {
                      private double price = 0;
                      private bool triggered = false;
                      private bool triggerOnGreaterThan = false;
                      private bool triggerSet = false;
                      private HorizontalLine alertLine = null;
                      private double lineVal = 0;
                      protected override void OnStateChange()


                      In the OnBarUpdate() section:

                      ema1 = EMA(Closes[n], 10)[0]; // store the current 10 period EMA from the added data series n where you would replace n with the specific added data series number, into the double ema1.

                      In OnRender(), use ema1 as needed.

                      Comment


                        #12
                        Thanks a lot, that solved the problem. Following your suggestions, I could resolve the problem. thanks again.

                        Comment

                        Latest Posts

                        Collapse

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