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

OnRender(Brakes the graph with strong scaling)

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

    OnRender(Brakes the graph with strong scaling)

    Hey. Here is the usual piece of code that draws on each candle a rectangle. The question is: why, when the graph is compressed heavily and its time axis is moved, a braking occurs. I made measurements on the time of drawing and received delays from half a second to a half seconds.

    How to fix the code so that there are no brakes?
    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    		{
    			for (int chartBarIndex = ChartBars.FromIndex; chartBarIndex <= ChartBars.ToIndex; chartBarIndex++)
                    {
                        // current bar prices
                        double barClosePrice = ChartBars.Bars.GetClose(chartBarIndex);
                        double barOpenPrice = ChartBars.Bars.GetOpen(chartBarIndex);
                        double barHighPrice = ChartBars.Bars.GetHigh(chartBarIndex);
                        double barLowPrice = ChartBars.Bars.GetLow(chartBarIndex);
    					
                        // current bar X and Y points
                        int x = chartControl.GetXByBarIndex(ChartBars, chartBarIndex) - (int)chartControl.BarWidth;
                        float barX = chartControl.GetXByBarIndex(ChartBars, chartBarIndex);
                        float barOpenY = chartScale.GetYByValue(barOpenPrice);
                        float barCloseY = chartScale.GetYByValue(barClosePrice);
                        float barHighY = chartScale.GetYByValue(barHighPrice);
                        float barLowY = chartScale.GetYByValue(barLowPrice);
    					
    					SharpDX.Direct2D1.Brush footPrintBarBrushDX = Brushes.White.ToDxBrush(RenderTarget);
    					RenderTarget.FillRectangle(new RectangleF(barX, barOpenY, 2, barCloseY - barOpenY), footPrintBarBrushDX);
    					footPrintBarBrushDX.Dispose();
    				}
    		}
    Attached Files

    #2
    Hello,

    Thank you for the post.

    Could you define what you mean by brakes?

    I tried the sample but I am not seeing any errors, could you provide more detail on the specifics of causing this to break?

    Also if you could provide the error you are seeing or an image of whatever happens that would be helpful.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey. I will try to describe my problem in more detail. I experience a problem on the indicator written according to the example of another indicator. Assumed that this is due to the rendering of a large number of objects in the OnRender method.
      Began to check the code that was laid out and it really works very well, then I assumed that there are few objects drawn and added 4 times more. The result was not worse, which suggested that the OnRender method works quickly. So the problem in speed of work is elsewhere. I will attach an indicator on the basis of which I did my own. Its meaning is that it collects data into the List <class> object, and in the OnRender method finds the desired values ​​and displays them. It turns out that the problem lies in working with this List <class> object. Can eat a more efficient way of implementation ???
      Attached Files

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello,

        Thank you for the post.

        Could you define what you mean by brakes?

        I tried the sample but I am not seeing any errors, could you provide more detail on the specifics of causing this to break?

        Also if you could provide the error you are seeing or an image of whatever happens that would be helpful.

        I look forward to being of further assistance.
        I really hope for help.

        Comment


          #5
          Hello,

          Thank you for the post.

          What is the problem you are seeing with the list? I am still unsure of what the problem is that you are seeing.

          As noted I was unable to see a crash or other errors when I ran the first script, can you provide an image or some detail on what the problem is?

          I ran the second script and see this is a different indicator, do the two different files provided share a common problem? Can you provide further details?

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Hey. Problems in the first script there is no, it displays on the screen very quickly and you can not see any braking of the graph when moving. However, in the second script, this is clearly visible when you load the number of days (for example, 50), then do the scaling along the time axis so that you can see the maximum number of bars, and try to move it. For clarity, I can make a video and attach it if required.

            Comment


              #7
              Hello,

              Yes, if you could include a video or an image of the "breaking" that would be helpful. I am not sure what you mean by breaking, a more detailed description or image/video would be needed in this case.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Christopher_R, Today, 12:29 AM
              0 responses
              6 views
              0 likes
              Last Post Christopher_R  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              166 responses
              2,234 views
              0 likes
              Last Post sidlercom80  
              Started by thread, Yesterday, 11:58 PM
              0 responses
              3 views
              0 likes
              Last Post thread
              by thread
               
              Started by jclose, Yesterday, 09:37 PM
              0 responses
              7 views
              0 likes
              Last Post jclose
              by jclose
               
              Started by WeyldFalcon, 08-07-2020, 06:13 AM
              10 responses
              1,414 views
              0 likes
              Last Post Traderontheroad  
              Working...
              X