Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Vertical offset in rendering once indicator is exported as assembly to another system

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

    Vertical offset in rendering once indicator is exported as assembly to another system

    My indicator is drawing using OnRender. When executed on my computer (development system) everything is preforming as expected. See the first image below.

    After exporting as Assembly to another computer the rendering is done higher on the screen than it should. See the second image below.

    I am using Wpf, and a set of functions to simplify the translation between price to screen coordinates. Please see the short code for DrawDXLine.

    Click image for larger version  Name:	Screen Shot 2022-07-27 at 4.02.36 PM.png Views:	0 Size:	1.50 MB ID:	1209890

    Click image for larger version  Name:	MichasScreen01.png Views:	0 Size:	1,004.5 KB ID:	1209889

    Code:
    protected void DrawDXLine(int idxslot1, int idxslot2, double val1, double val2, Stroke stroke, ChartControl chartControl, Gui.Chart.ChartScale chartScale)
    {
    DrawDXLine(idxslot1, idxslot2, val1, val2, stroke.Brush, stroke.DashStyleHelper, stroke.Width, chartControl, chartScale, stroke.Opacity);
    }
    
    protected void DrawDXLine(int idxslot1, int idxslot2, double val1, double val2, Brush brush, DashStyleHelper dashStyle, float width, Gui.Chart.ChartControl chartControl, Gui.Chart.ChartScale chartScale, int opacity = 100)
    {
    Point p1 = new Point(BarToX(idxslot1, chartControl), PriceToY(val1, chartScale));
    Point p2 = new Point(BarToX(idxslot2, chartControl), PriceToY(val2, chartScale));
    DrawDXLine(p1, p2, brush, dashStyle, width, chartControl, chartScale, opacity);
    }
    
    protected void DrawDXLine(double x1, double x2, double y1, double y2, Brush brush, DashStyleHelper dashStyle, float width, Gui.Chart.ChartControl chartControl, Gui.Chart.ChartScale chartScale, int opacity = 100)
    {
    Point p1 = new Point(x1, y1);
    Point p2 = new Point(x2, y2);
    DrawDXLine(p1, p2, brush, dashStyle, width, chartControl, chartScale, opacity);
    }
    
    protected void DrawDXLine(Point p1, Point p2, Brush brush, DashStyleHelper dashStyle, float width, ChartControl chartControl, Gui.Chart.ChartScale chartScale, int opacity = 100)
    {
    SharpDX.Direct2D1.DashStyle _dashStyle;
    if (!Enum.TryParse(dashStyle.ToString(), true, out _dashStyle)) _dashStyle = SharpDX.Direct2D1.DashStyle.Dash;
    SharpDX.Direct2D1.StrokeStyleProperties properties = new SharpDX.Direct2D1.StrokeStyleProperties() {DashStyle=_dashStyle};
    SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(Core.Globals.D2DFact ory, properties);
    SharpDX.Direct2D1.Brush dxBrush = brush.ToDxBrush(RenderTarget);
    dxBrush.Opacity = opacity/100f;
    RenderTarget.DrawLine(p1.ToVector2(), p2.ToVector2(), dxBrush, width, strokeStyle);
    dxBrush.Dispose();
    strokeStyle.Dispose();
    }
    //retrieve the x coordinate in pixel of a a relative bar index.
    
    protected double BarToX(int bars, Gui.Chart.ChartControl chartControl, bool atMiddle = false)
    {
    return chartControl.GetXByBarIndex(chartControl.BarsArray[0], bars) - (atMiddle ? (chartControl.Properties.BarDistance / 2) : 0);
    }
    
    //retrieve the y coordinate in pixel of a a relative price.
    protected double PriceToY(double val, Gui.Chart.ChartScale chartScale)
    {
    return chartScale.GetYByValueWpf(val);
    }
    Last edited by Shai Samuel; 07-27-2022, 07:40 AM.

    #2
    Hello Shai Samuel,

    May I confirm the val1 value is coming from WPF (like a mouse click)?

    I see you are using GetYByValueWpf() (used for converting a WPF value to the sharp dx y value) instead of GetYByValue() (used to convert a price to a sharp dx y value).

    https://ninjatrader.com/support/help...byvaluewpf.htm
    https://ninjatrader.com/support/help...etybyvalue.htm

    Does this example have the same behavior on that computer?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes, you are correct. Thank you.

      Comment

      Latest Posts

      Collapse

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