Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Lines out of place: RenderTarget.DrawLine

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

    Lines out of place: RenderTarget.DrawLine

    Hello, a month ago I developed an Indicator that allows me to see the POCs for each candle and also projects the Naked POCs for each one. My Indicator was working fine. But a few days ago, I accidentally closed my chart, created a new one, and added my component again. Now the POC lines appear out of place, and I repeat that everything was working fine. My question is, why is this happening? Is there a property I should set on the new chart? Or do you have any idea what could be happening? I am using something like this:

    PHP Code:
     private void DrawPocBar(ChartControl chartControl, ChartScale chartScale){  //......... (Rest of the code)
    //and
    
     RenderTarget.DrawLine(
                                new SharpDX.Vector2(x1, y),
                                new SharpDX.Vector2(x2, y),
                                pocBrush,
                                PocWidth 
                            );
    
    }​ 
    

    And finally, I apply my method here:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale){

    DrawPocBar(ChartControl chartControl, ChartScale chartScale);
    }
    Attached Files
    Last edited by icebergdelphi; 05-08-2025, 04:54 AM.

    #2
    Hello icebergdelphi,

    This is likely due to the calculation of the values assigned to the x1 and x2 variables.

    Add prints to your script to understand the behavior.


    Print the bar time, price value supplied to GetYByValue(), the return value from GetYByValue(), and the value of x1 and x2 after they are assigned.

    Include labels for each value.

    Save the output to a text file and include this with your next post.

    Comment


      #3
      Just an idea: try changing your indicator to update on bar close.

      Comment


        #4
        Originally posted by MiCe1999 View Post
        Just an idea: try changing your indicator to update on bar close.
        Thank you MiCe1999, you say, move my code from Onrender to BarUpdate? I didn't understand very well, it's strange because yesterday I did tests and changed from MES to ES and in ES it works fine, except that if I change the number of days in the DataSeries, that is, if I put more days, I have the problem that the lines are out of place.

        Comment


          #5
          Interesting artifacts. The issue is obscure, hard to tell what could be the problem w/o the code. Try adding debug statements to print your variables to the console:

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by abelsheila, 05-14-2025, 07:38 PM
          2 responses
          30 views
          0 likes
          Last Post hglover945  
          Started by nailz420, 05-14-2025, 09:14 AM
          1 response
          57 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
          0 responses
          327 views
          1 like
          Last Post NinjaTrader_Brett  
          Started by domjabs, 05-12-2025, 01:55 PM
          2 responses
          62 views
          0 likes
          Last Post domjabs
          by domjabs
           
          Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
          1 response
          81 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Working...
          X