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

Problems with the Height of rectangle fro Delta Indicator

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

    Problems with the Height of rectangle fro Delta Indicator

    Hi from Spain.. I'am new developing indicators for NT8.

    I'am doing my owns indicators, for distincts reason..

    The problema that I have if, the Height of the rectangle...It does not much and the Delta value..This is the code:


    if (deltaItem > 0.0)
    {
    //Print(chartScale.GetYByValueWpf(deltaItem));
    //Print(chartScale.GetValueByYWpf(chartScale.GetYByV alueWpf(deltaItem)));

    LD1.X = (float)(chartControl.GetXByBarIndex(ChartBars, i)-(chartControl.BarWidth/2));
    LD1.Y = LT1.Y;

    SharpDX.RectangleF recF = new SharpDX.RectangleF(LD1.X, LD1.Y, (float)chartControl.BarWidth, (float)deltaItem*(-1));

    RenderTarget.DrawRectangle(recF, AskBrush,1);


    }
    else
    {
    LD1.X = (float)(chartControl.GetXByBarIndex(ChartBars, i) - (chartControl.BarWidth / 2));
    LD1.Y = LT1.Y;

    SharpDX.RectangleF recF = new SharpDX.RectangleF(LD1.X, LD1.Y, (float)chartControl.BarWidth,(float)deltaItem*(-1));

    RenderTarget.DrawRectangle(recF, BidBrush, 1);

    }

    How can see in the image, the height of the rectangle does not much, with the value of the delta.. or positive or negative.

    I have prove other options, but it's not working fine...

    PD: I upload the image, where I have draw a line, where the height of the rectagle should be got...
    Thaks to everyone..
    Attached Files
    Last edited by brokerbombero; 10-05-2017, 08:59 AM.

    #2
    Hello from Denver CO, and welcome to the forums!

    I do not know the calculation you are using for deltaItem, and I don't know the exact value you are supplying to the rectangle's height so my input will be limited.

    SharpDX rendering would be in terms of pixels as opposed to the price levels that we can use in Drawing Objects and in plots. Any scaling of this rectangle to reach the proper levels would have to be done by you when you are using SharpDX for custom rendering. ChartScale can be used to get the pixel coordinates of a given value.

    When you use (float)chartScale.GetYByValueWpf(deltaItem) for height do you get the desired output?

    What is the value of deltaItem when you print it in the output window?

    I'll provide a link to the documentation page for the thread's reference.

    ChartScale - https://ninjatrader.com/support/help...chartscale.htm

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

    Comment


      #3
      Hello..Thaks for yours answer..

      I found the solution...With this code:


      SharpDX.Vector2 beginPoint = new SharpDX.Vector2();
      SharpDX.Vector2 Point_1 = new SharpDX.Vector2();
      SharpDX.Vector2 Point_2 = new SharpDX.Vector2();
      SharpDX.Vector2 Point_3 = new SharpDX.Vector2();

      beginPoint.X = (float)(chartControl.GetXByBarIndex(ChartBars, i) - (chartControl.BarWidth / 2));
      beginPoint.Y = LT1.Y;

      Point_1.X = beginPoint.X;
      Point_1.Y = chartScale.GetYByValue(deltaItem);

      Point_2.X = (float)(chartControl.GetXByBarIndex(ChartBars, i) + (chartControl.BarWidth / 2));
      Point_2.Y = Point_1.Y;

      Point_3.X = Point_2.X;
      Point_3.Y = beginPoint.Y;


      SharpDX.Direct2D1.PathGeometry RecPathGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFac tory);


      SharpDX.Direct2D1.GeometrySink geometrySink = RecPathGeometry.Open();


      geometrySink.BeginFigure(beginPoint, SharpDX.Direct2D1.FigureBegin.Filled);

      geometrySink.AddLine(Point_1);
      geometrySink.AddLine(Point_2);
      geometrySink.AddLine(Point_3);


      geometrySink.EndFigure(SharpDX.Direct2D1.FigureEnd .Closed);
      geometrySink.Close();

      BuyBrush.Opacity = OpacidadBuyColor;

      RenderTarget.DrawGeometry(RecPathGeometry, ContornoBuyColorBrush, 1);
      RenderTarget.FillGeometry(RecPathGeometry, BuyBrush);


      RecPathGeometry.Dispose();

      The deltaitem is a double number between -2500 and 2500, depend of the instrument.. I establish the escale on the OnCalculateMinMax() method...

      Now is working fine..

      Thaks a lot..
      Attached Files

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      19 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X