Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender() drawing object to draw Globally on all charts of same instrument

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

    OnRender() drawing object to draw Globally on all charts of same instrument

    Hi,

    I am rending an green arrow when ema> price and line drawn's slope is up and red arrow for opposite. I wanted to render that arrow on all charts open for the same instrument, when an instance of that indicator is active.
    Please suggest, whether is it possible to do in NT8? if yes, any ref or example will be appreciated.
    Thanks in advance.

    #2
    Hello asmmbillah,

    Thanks for your post.

    There would be no direct/easy way to accomplish your goal if you are drawing arrows in the OnRender() method.

    Alternately, this has been built-in to the Draw methods by setting the IsGlobal bool in the Draw methods overload (In OnBarUpdate) with the IsGlobal bool. This would be the recommend way to go.

    For example: Draw.ArrowUp(NinjaScriptBase owner, string tag, bool isAutoScale, int barsAgo, double y, bool isGlobal, string templateName)

    Draw.ArrowUP("this", "test"+CurrentBar, true, 0, Low[0] - 4 * TickSize, true, ""); // draw a global Arrow up 4 ticks below the low (of the source chart) with th default color (otherwise specify a template).

    ​​​​​​​




    Comment


      #3
      Thanks for your reply. I have checked the built in draw method, unfortunately that does not help to what I am trying to do here. I have so far rendering the arrows for different time frame at a corner of the chart like the screenshot attached. based on the condition, colour of the arrow changes, but it changes color only on the time frame I have drawn the line and ema condition met. I am trying to synchronise the same to other time frame charts where this indicator is running as well. I would appreciate, if you could direct me to the way to a solution to achieve that in NT8. thanks in advance.

      Comment


        #4
        Hello asmmbillah,

        Thanks for your reply.

        I recognize the indicator based on some of your other threads.

        Can you confirm that the indicator is set to run Calculate.OnEachTick, and has added the data series for each time frame show by the arrows (so in addition the charts data series).

        Comment


          #5
          Thanks for your reply. That is correct. Good to know that you rememberred. Yes, I can confirm.

          Comment


            #6
            Hello asmmbillah,

            Thanks for your reply.

            To recap then, you have applied the indicator to multiple charts, of the same instrument, and all of the indicators are running Calculate.OnEachTick and the issue is that the color/arrows on one chart may not match another as would be expected?

            Are you checking the condition that determines the arrow/color in OnBarUpdate()? If not that would be the suggested way to approach this. As we discussed before you would need to create a class level bool or variable that you set in OnBarUpdate() and then read/use in Onrender().

            Using Calculate.OneachTick would provide the same information to all instances so I would expect all instances to reflect the same thing.

            Comment


              #7
              Thanks for your reply. Yes, calculating on OnEachTick. I have checked the condition for bool in OnBarupdate()? for both ema and line. I think, the condition or logic works fine, as it does render the arrow type with desired color on chart like the screenshot attached here now, for your ref. But as you can see in the screenshot, left side there is a white arrow beside 15 min, but it does not render on the right chart beside 15 min, same for right chart 60 min, there is a red down arrow, but it does not render on left 15 min chart.

              please advise.
              Last edited by asmmbillah; 10-03-2019, 04:52 AM.

              Comment


                #8
                Hello asmmbillah,

                Thanks for your reply.

                I would suggest debugging with print statements to understand why the indicator is not performing as expected.

                Reference: https://ninjatrader.com/support/help...script_cod.htm

                Comment


                  #9
                  Thanks for your reply. I have done debuggin and found an issue which is logically looks impossible for me, which is below:

                  if (Instrument.MarketData.Last.Price> EMA(BarsArray[0], Period)[0])
                  {
                  arrowUpGolden = true;
                  }
                  else if (Instrument.MarketData.Last.Price < EMA(BarsArray[0], Period)[0])
                  {
                  arrowDownGolden = true;
                  }
                  When I am printing, both the bool are returning true at the same time. I don't get it, because conditions are completely opposite. i am checking it in OnBarUpdate. Any advise?

                  Comment


                    #10
                    Hello asmmbillah,

                    Thanks for your reply.

                    Perhaps you are setting/resetting the bools elsewhere as well (perhaps in OnRender()?

                    As a sanity check I would print in both logic cases the values of Instrument.MarketData.Last.Price and EMA(BarsArray[0], Period)[0] as well as both bools.

                    Comment


                      #11
                      Hi, thanks for the suggestion. I have fixed that problem. But after doing all these, now color and arrows for all periods are showing same. As I informed initially, desired is to draw arrows different depending on the conditions set for that period's chart. I am attaching screenshot taken from 15 min chart, condition is ok, it is suppose to draw red down arrow, but it is now showing the same for all periods. where as other periods chart should have shown differnt color and different arrows. Please advise. thanks in advance.
                      Last edited by asmmbillah; 10-03-2019, 04:53 AM.

                      Comment


                        #12
                        Hello asmmbillah,

                        Thanks for your reply.

                        For your indicator to work as you wish, you would have to add each data series to check in the indicator. In the OnBarUpdate(), running with Calculate.OnEachTick, you would have to check the conditions of each time frame and through class level variables in OnRender() you would need to use those variables to then control Onrender to provide the chart indication desired.

                        You will need to continue debugging to see what is missing.


                        Comment


                          #13
                          Hi Paul, thanks for your suggestion. I have attached a screenshot for your ref. Only problem since begining is, when arrow/color of left hand chart beside any time frame changes it does not change for the other instance of that specific time period on different chart. for example you can see 15 min. is there any way this is possible in NT8? thanks in advance.

                          Comment


                            #14
                            Hello asmmbillah,

                            Thanks for your reply.

                            Yes, I would expect that when your conditions are true that the arrows reflect the state of the bools you are setting at that moment.

                            You are looking at some very long time frames, are you adding enough days to load to support accurate values of the moving average you are using?

                            Comment


                              #15
                              Sorry, my mistake, I forgot to mention for debugging, I am just trying only 15 min and 60 min. rest of the time frames I am not testing at the moment. My query was about synchronizing color and direction of the arrows in both instances. It does not. for example, in the attached screenshot 15 min arrow different in two seperate instances of the same indicator. I want them to synchronize in all instances of the same indicator. I hope that clarifies.
                              Last edited by asmmbillah; 10-02-2019, 09:10 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              601 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
                              559 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