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 cyberpete76, 03-27-2023, 12:29 AM
            7 responses
            265 views
            1 like
            Last Post slightly  
            Started by renewsaltwater, Today, 01:15 AM
            0 responses
            2 views
            0 likes
            Last Post renewsaltwater  
            Started by slightly, Today, 12:49 AM
            0 responses
            3 views
            0 likes
            Last Post slightly  
            Started by sdauteuil, 09-23-2021, 10:16 AM
            4 responses
            1,209 views
            0 likes
            Last Post jacobpescaia44  
            Started by agclub, 04-21-2024, 08:57 PM
            5 responses
            36 views
            0 likes
            Last Post agclub
            by agclub
             
            Working...
            X