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

Updating price variable on mouse hover over price

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

    Updating price variable on mouse hover over price

    I am trying to make a dynamic variable capture the price that the mouse is currently hovering over on the chart, but this code seems to completely freeze NT8 when I enable the Strategy:

    Code:
    private ChartScale MyChartScale;
    
    int Y;
    double priceHover;
    
    protected void MouseMoved(object sender, MouseEventArgs e)
    {
        TriggerCustomEvent(o =>
        {
            Y = ChartingExtensions.ConvertToVerticalPixels(e.GetPosition(ChartControl as IInputElement).Y, ChartControl.PresentationSource);
            priceHover = MyChartScale.GetValueByY(Y);
    
            if (priceHover != MyChartScale.GetValueByY(Y))
            {
                Print(String.Format("{0}", priceHover));
            }
        }, null);
        e.Handled = true;
    }
    
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        base.OnRender(chartControl, chartScale);
        MyChartScale = chartScale;
    }

    #2
    Hi, thanks for your post.

    I am not aware of a supported example for a mouse move event in NinjaTrader 8. I found this one for NinjaTrader 7:

    This Custom Crosshair will allow you show the horizontal and/or vertical lines. You also have the option to change the colors of the lines and markers. Critical – Specifically for some indicators, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No' Update […]


    I have asked my colleague if they know of any examples in NT8. Ill post them if we find any.

    Thanks in advance for your patience.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      It actually looks like the chart is not freezing, but my crosshair is so I thought the chart was freezing. The code functions fine, but it breaks the crosshair completely (I am using local crosshair, but global crosshair also breaks). Any way to fix this?

      Comment


        #4
        Hi daigo1, I found this sample that will be helpful:



        This example implements a mouse move event. It is not documented so I can not provide support for it beyond this point.

        Please let me know if you have any questions.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thanks Chris. This works great!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by trilliantrader, Today, 03:01 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by geddyisodin, Today, 05:20 AM
          6 responses
          34 views
          0 likes
          Last Post geddyisodin  
          Started by pechtri, 06-22-2023, 02:31 AM
          9 responses
          122 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by frankthearm, 04-18-2024, 09:08 AM
          16 responses
          67 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by habeebft, Today, 01:18 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X