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

Point and Click indicator?

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

  • cassb
    replied
    That did it, thank you!

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello cassb,
    Please use the Print function to get the value of all the methods. If you are getting an unexpected value then you have to recalculate for the right x value.

    A sample code will be like
    Code:
    idx = Math.Min(CurrentBar , Bars.Count - 2) - ChartControl.LastBarPainted + idx;
    Please let me know if I can assist you any further.

    Leave a comment:


  • cassb
    replied
    OK Joydeep, I have been testing the code that finds the bar index from the X position:

    Code:
                    int barclick = (int)(xpos/ChartControl.BarSpace);    //gets the bar, from the painted ones where the mouse is clicked
                    int idx = ChartControl.BarsPainted - barclick ;
                    idx = Bars.Count - 2 - ChartControl.LastBarPainted + idx;
    The only flaw I can find is that if you scroll the chart to the left and then refresh (F5) the chart, when you click on a bar then the idx value is messed up. Somehow, it's offsetting the idx value based on the number of bars that have scrolled out of view off the right side of the chart? If you don't refresh after scrolling though, the idx is still fine. It only gets messed up when you refresh the chart after scrolling.

    Thanks!
    Bryan

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello cassb,
    Yes, you have to know the min and max values.
    To avoid double paint you can also use the unsupported overload GetMinMaxValues instead of the Plot.

    Please let me know if I can assist you any further.

    Leave a comment:


  • cassb
    replied
    Originally posted by NinjaTrader_Joydeep View Post
    Hello cassb,
    It is possible to get the price from the Y value. Please refer here to these posts for some ideas


    Hey, Just saw it... Honestly I don't remember anything from this issue... Good you figured it... Lol Yeah it took a bit of searching around but finally got it. One great thing with forums is that you do get solutions and help if you need but there are many partial or incorrect postings that lead you the wrong way. And when something is incorrect / partial, generally there is no follow up to it. So you dont know why a particular approach does not work. :-) Anyways, I am happy I get what I am looking …


    Please let me know if I can assist you any further.
    Yes, thank you. I found that ChartHelper code and it really did help! :-) The key to getting the price from the Y value is knowing the size and position of the Y axis at the time of the click. So this override routine is critical:

    Code:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) 
    {     
          priceMin = min;     
          priceMax = max;     
          boundsTop = bounds.Top;     
          boundsHeight = bounds.Height;
    }

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello cassb,
    It is possible to get the price from the Y value. Please refer here to these posts for some ideas


    Hey, Just saw it... Honestly I don't remember anything from this issue... Good you figured it... Lol Yeah it took a bit of searching around but finally got it. One great thing with forums is that you do get solutions and help if you need but there are many partial or incorrect postings that lead you the wrong way. And when something is incorrect / partial, generally there is no follow up to it. So you dont know why a particular approach does not work. :-) Anyways, I am happy I get what I am looking …


    Please let me know if I can assist you any further.

    Leave a comment:


  • cassb
    replied
    Actually, if you could help with one more thing. I see that you derive the bar number from the X position like this:

    int barclick = (int)(xpos/ChartControl.BarSpace); //gets the bar, from the painted ones where the mouse is clicked


    How would I also derive the price value using the Y position?

    Thanks!

    Leave a comment:


  • cassb
    replied
    That's perfect, Joydeep, thank you! Just for reference, here's a link to the web page you need if you want to monitor mouse clicks. It's an indicator that shows an alternative data box.

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello cassb,
    Thanks for writing in and I am happy to assist you.

    Yes it is possible to calculate the bar number from the mouse click using unsupported NinjaScript functions.

    Please refer to this thread for more http://ninjatrader.com/support/forum...ight=dsdatabox

    Please let me know if I can assist you any further.

    Leave a comment:


  • cassb
    started a topic Point and Click indicator?

    Point and Click indicator?

    Is it possible to write an indicator that monitors the chart so that when you click the mouse on Panel 1, the indicator can capture the bar number and price where the user clicked? I'm not interested in the X,Y grid value though, unless I can derive the bar number and price from that.

    Thanks!
    Bryan

Latest Posts

Collapse

Topics Statistics Last Post
Started by WHICKED, Today, 12:45 PM
2 responses
16 views
0 likes
Last Post WHICKED
by WHICKED
 
Started by GussJ, 03-04-2020, 03:11 PM
15 responses
3,272 views
0 likes
Last Post xiinteractive  
Started by Tim-c, Today, 02:10 PM
1 response
8 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by Taddypole, Today, 02:47 PM
0 responses
2 views
0 likes
Last Post Taddypole  
Started by chbruno, 04-24-2024, 04:10 PM
4 responses
51 views
0 likes
Last Post chbruno
by chbruno
 
Working...
X