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

    http://www.ninjatrader.com/support/f...6&postcount=14
    http://www.bigmiketrading.com/ninjat...ime-price.html

    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

    http://www.ninjatrader.com/support/f...6&postcount=14
    http://www.bigmiketrading.com/ninjat...ime-price.html

    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.

    http://www.volumedigger.com/NinjaTra...dsDataBox.aspx

    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 focus333, Today, 05:34 PM
1 response
25 views
0 likes
Last Post bltdavid  
Started by RaddiFX, Today, 07:48 PM
0 responses
8 views
0 likes
Last Post RaddiFX
by RaddiFX
 
Started by smcllr, Today, 05:41 PM
0 responses
23 views
0 likes
Last Post smcllr
by smcllr
 
Started by trader3000a, Today, 02:28 PM
1 response
24 views
0 likes
Last Post NinjaTrader_Kate  
Started by mcosta72, Today, 02:25 PM
0 responses
19 views
0 likes
Last Post mcosta72  
Working...
X