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

ChartControl.MouseUp lock

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

    ChartControl.MouseUp lock

    Hello,

    Is there a way i can lock the
    Code:
    ChartControl.MouseUp (int cursorPointX = ChartingExtensions.ConvertToHorizontalPixels(chart Control.MouseDownPoint.X, chartControl):
    I want the text i click on the chart to be lock on the chart so when i click elsewhere on the chart the text dont follow.
    Something that would trigger a lock and unlock by hiting a key?

    Thank you
    Last edited by NinjaTrader_ChrisL; 07-29-2020, 09:04 AM. Reason: added code formatting

    #2
    Hi frankduc, thanks for your question.

    It seems like your drawing code is tied too closely to the mouse click code, so it changes every time (that's what I am guessing here without the full context).

    We have these examples that might be useful:


    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Sorry i was not clear.

      Its base on the samplestremwriter

      Code:
      public override void OnRenderTargetChanged()
              {
                  textBrush = Brushes.Lime.ToDxBrush(RenderTarget);
              }
      Can i use IsLocked to freeze the textBrush?

      Code:
      public override void OnMouseMove(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, Point point)
      {
        if (IsLocked) //if the object is locked, do not attempt to move
          return;
      }
      Do i have to replace public override void OnRenderTargetChanged() by public override void OnMouseMove(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, Point point)

      Will it freeze only the textBrush or also the calculation that comes with it? Since i am using
      cursorPointX in my for loops i wonder if the text will stop moving but the calculation will still follow the cursor? TY

      Comment


        #4
        Hi frankduc, thanks for your reply.

        Using a bool like this is a good way to prevent code from running if you do not want it to. I don't have the full context of what this script is supposed to do. Could you let me know what the script is supposed to do and where the issue is originating?

        Best regards.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Chris,

          If i use IsLocked

          Code:
          public override void OnRenderTargetChanged()
                  {
                      if (IsLocked) 
          
          
              return;
          
                      else {
                      textBrush = Brushes.Lime.ToDxBrush(RenderTarget);
                      }
                  }
          That's what i thought uncheck or check the square box and text vanish from the chart instead of just freezing it at specific place where i clicked on the chart.

          there is something i dont get,

          TY

          Comment


            #6
            Hello frankduc, thanks for your reply.

            OnRenderTargetChanged is used to clean up or update objects that render to the SharpDX RenderTarget. See the notes on the documentation here for examples on when the render target changes. This is not a good place to control the position of a sharp dx object. I am seeing you are using an OnMouseMove event, The first thing to test would be if we are seeing a call to OnRender every time MouseMove is called. That would be required for any rendered object to be controlled by the mouse. I am assuming it doesn't because of this note :

            For performance optimizations, the timing of the calls to OnRender() are buffered to at least 250ms, and re-renders once internal logic determines that values may be out-of-date. See also ForceRefresh() for more details

            Please let me know if I can assist any further.
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jjs12, Today, 10:29 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by lakman184, 03-24-2024, 01:30 PM
            5 responses
            28 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by thumper57, 05-11-2024, 04:30 PM
            16 responses
            44 views
            0 likes
            Last Post thumper57  
            Started by Salahinho99, 05-05-2024, 04:13 AM
            10 responses
            72 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by lorem, 04-25-2024, 09:18 AM
            13 responses
            56 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X