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

    #16
    Hello asmmbillah,

    Thanks for your reply.

    I've created a short video to demonstrate, on a very simple basis, how your script can collect the information from all time frames, perform analysis on all time frame and can update simultaneously on all charts (using calculate.OnEachTick) when the indicator is added to each chart where you want to see the info. With this example, I would suggest that you have some logic issues as this (I think) demonstrates the concept you are trying to employ but with different methods: https://Paul-ninjaTrader.tinytake.co...N18xMTYwNTk5Mw

    Note: for anyone copying the code shown in the video, I did not add a CurrentBars[4] check (I started with just 3 and forgot to change this before the video). Here is what that line should look like: if (CurrentBars[0] < 1 || CurrentBars[1] < 1 || CurrentBars [2] < 1 || CurrentBars[3] < 1 || CurrentBars[4] < 1) return;
    Last edited by NinjaTrader_PaulH; 10-02-2019, 09:32 AM. Reason: Added CurrentBars[4] note.

    Comment


      #17
      Thanks again for the clip. My condition uses both ema and line drawn. so without line with ema only it works exactly like yours. but when line drawn manually on chart and stored in a dictionary where key is barsPeriod and lines as value, then it does not.


      it works for until condition is checking with only ema1, ema2 etc ie, added data series. But next part when it check with line drawn, then it only color changes for one instance where the line is drawn. I am in a kind of deadlock.

      I have made a short clip for you as ref. which you can watch here: https://www.dropbox.com/s/qaev7ebfsd...issue.mp4?dl=0

      It will be really helpful, if you could direct me to the right way. thanks in advance.
      Last edited by asmmbillah; 10-03-2019, 04:28 AM.

      Comment


        #18
        Hello asmmbillah,

        There are alot of unsupported things going on in this script.

        What I can say about this issue is:

        1. The indicator that draws the arrow will need to have its brush updated via external means
        2. The indicator that draws the arrow will need to also force a rendering update so the new brush is seen.

        You could create a public method in your script that updates the brush and then forces a rendering update by adding/removing a draw object or calling ChartControl.InvalidateVisual. You would then need to find all instances of your indicator in all charts and call your method to force the visual update.

        Note: Calling ChartControl.InvalidateVisual is unsupported and not recommended to use under normal circumstances.

        Additional note: The code provided in the attached example is ENTIRELY unsupported. This goes beyond the scope of what NinjaTrader support offers. Our support is limited to providing insight based off of what we have documented in the Help Guide. Unsupported code is not guaranteed to work, and we cannot offer any insight on using. Internal code may be subject to change and updates to NinjaTrader could break this script. The code is provided to give you some insight on how you can achieve your goals on your own.

        We will not have any additional insight we can offer here and hope that the code given can provide some direction for you to accomplish tasks outside of what we can offer insight on. Please do not ask additional questions on how this code can be used. It will be up to you to perform your own investigations and testing.

        If you have questions on a different script which does not take unsupported approaches, please do not hesitate to open a new thread.
        Attached Files
        Last edited by NinjaTrader_Jim; 10-02-2019, 02:08 PM.

        Comment


          #19
          Thanks for your suggestions. I believe below query should be within your support scope.

          I am using a public method for updating brush in OnRender(),
          but i am getting below error.

          2019-10-04 15:42:25:745|3|16|Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'HRESULT: [0x88990001], Module: [SharpDX.Direct2D1], ApiCode: [D2DERR_WRONG_STATE/WrongState], Message: The object was not in the correct state to process the method.

          I have done debuggin with Print(), it does work while using Print();
          But when i am using
          (myIndi as SupplyDemandTrendLine).updateFillArrowUp(colorFu llUp);

          it freezes and does nothing.

          I will requeset, if the above issue is within your support; I will appreciate, if you could advise anything to resolve this error.

          Thanks in advance.

          Please note: it does not give any complile error.
          Last edited by asmmbillah; 10-06-2019, 10:03 AM.

          Comment


            #20
            Hello asmmbillah,

            Please only manage SharpDX resources in OnRender/OnRenderTargetChange. You could have your public method set a bool signaling that the brush needs to be updated, and then update the brush in OnRender when your "needToUpdateBrush" is true.

            When debugging OnRender code, you will want to use prints to see where exactly the code fails, and then look into the resources used for that drawing routine and ensure that the resources are being handled properly.

            Best Practices for SharpDX - https://ninjatrader.com/support/help...arpDXResources

            Comment


              #21
              Hi, Thanks for your suggestions. normally in OnRender(), I am drawing the arrow with
              FillArrowUp(RenderTarget,colorBetween,x,y, textFormat.FontSize,textFormat.FontSize/2,textFormat.FontSize*2);

              But when I am using the below to update arrow color, it does not update.
              (myIndi as SupplyDemandTrendLine).FillArrowUp(RenderTarget,co lorBetween,x,y, textFormat.FontSize,textFormat.FontSize/2,textFormat.FontSize*2);

              But instead of above line, when I use below to print it does print while debugging.
              Print (DateTime.Now+" "+myIndi.ChartBars.Bars.BarsPeriod.ToString()+ " arrowUpGolden Debugging has come to this line ");

              What I understand, it does not have any logic or condition issue. Am I missing something related to update the arrow?

              Whenever I use if statement to render like below, it does not render, but without any condition it does.

              if (arrowUpWhite)
              {
              Print (arrowUpWhite);
              FillArrowUp(RenderTarget,colorNeutral,x,y, textFormat.FontSize,textFormat.FontSize/2,textFormat.FontSize*2);
              }

              I have checked, the bool, it returns true, but still it does not render.

              Any direction or ref or sample within this forum will be highly appreciated. thanks in advance.
              Last edited by asmmbillah; 10-06-2019, 01:52 PM.

              Comment


                #22
                Hello asmmbillah,

                I would not recommend trying to call SharpDX rendering from your public method. I would instead suggest setting a bool in your public method and then to check that bool in OnRender to update the brush.

                See attached example.
                Attached Files

                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