Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Rectangle with Fibonacci tools on chart

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

    Draw Rectangle with Fibonacci tools on chart

    Dear friends:
    I am trying to draw a rectangle with SharpDX.RectangleF, like the photo, when I open the fibo tools, but I have problems with the X, Y coordinates and price levels.
    Would anyone know how I could intertwine XY coordinates with price levels?
    If you have a better idea you can say it.
    Thank you
    Attached Files

    #2
    Hello enric_69,

    Thanks for opening the thread and welcome to our support forums!

    There are some methods that you can use to get X and Y pixel coordinates from ChartScale and ChartControl in OnRender(). I will provide links below:

    ChartScale.GetYByValue() - https://ninjatrader.com/support/help...etybyvalue.htm

    ChartControl.GetXByBarIndex() - https://ninjatrader.com/support/help...bybarindex.htm

    Please let me know if I can be of further help.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Hello enric_69,

      Thanks for opening the thread and welcome to our support forums!

      There are some methods that you can use to get X and Y pixel coordinates from ChartScale and ChartControl in OnRender(). I will provide links below:

      ChartScale.GetYByValue() - https://ninjatrader.com/support/help...etybyvalue.htm

      ChartControl.GetXByBarIndex() - https://ninjatrader.com/support/help...bybarindex.htm

      Please let me know if I can be of further help.


      Thanks Jim for your quick response.
      It's hard to explain my problem in writing, so I've left you a little video.
      I hope you can help me
      regards
      Enric

      I let the video here: https://we.tl/W6u6NB9WIY
      Last edited by enric_69; 06-13-2017, 11:56 AM.

      Comment


        #4
        Hello Enric,

        Thanks for the reply and the video.

        Observing how you have drawn the square, this looks like you have modified a drawing tool to place the square. Without the complete code, I can only guess, but it looks like there is an anchor where the lines are drawn and the square appears to be a set number of pixels away from your lines. When you adjust the scale, the square's distance remains the same in relativity to the lines used to draw it, and it then gets offset from the price level you placed it at.

        As you are saying you want to use SharpDX.RectangleF, I would suggest to modify the SampleCustomRender indicator as it uses the same method to draw rectangles. I would still suggest to use the aforementioned methods to get the pixel values at a certain price.

        When you have been able to draw the rectangle at a designated price through the SampleCustomRender indicator, I would then suggest to modify your drawing object to draw a rectangle at a specific price level.

        Another possible solution could be to modify your drawing object so the square's "offset" from the lines is a variable that changes based on the charts scale. As a rough example, you could use OnCalculateMinMax() to detect when charts scale has changed. Then, you could subtract the MinValue from the MaxValue to get a value that you could use to scale the square's distance from the anchor lines when the Chart's scale changes.

        OnCalculateMinMax() - https://ninjatrader.com/support/help...lateminmax.htm

        MinValue - https://ninjatrader.com/support/help...s/minvalue.htm

        MaxValue - https://ninjatrader.com/support/help...s/maxvalue.htm

        Please let me know if I may be of further help.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by junkone, Today, 11:37 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by frankthearm, Yesterday, 09:08 AM
        11 responses
        43 views
        0 likes
        Last Post frankthearm  
        Started by quantismo, 04-17-2024, 05:13 PM
        5 responses
        35 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by proptrade13, Today, 11:06 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        35 views
        0 likes
        Last Post love2code2trade  
        Working...
        X