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

islocked

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

    islocked

    Is it possible to apply
    IsLocked to an indicator such as sampledisplaybarsago?

    Everytime it is clicked on the chart the indicator is moving, i would like keep it still.

    Now the code says:

    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
    ;

    I suppose you need to enter a bool in proprieties?

    ty

    #2
    Hello frankduc,

    Thanks for your post.

    The script you have named is not an example I am aware of, but I did find an example my colleague Jesse has provided with the same name. Please be sure to include the script you are inquiring about so we can better understand how we can assist you.

    The example specifically draws at a point fetched from ChartControl.MouseDownPoint, so after every time you click in a new location, the script is giving a new location to draw the text.

    If you want the text to stay "still" you will want to control the coordinates where the text is drawn as opposed to using ChartControl.MousePointDown. I suggest viewing the SampleCustomRender example to see how it uses coordinates for ChartPanel to control where its custom drawing is placed on the chart.

    ChartPanel - https://ninjatrader.com/support/help...chartpanel.htm

    Please let me know if you have any questions.

    JimNinjaTrader Customer Service

    Comment


      #3
      Sorry i dont see how what you explaining helps.

      This is the script to move the indicator on the chart:

      }
      else if (State == State.Historical)
      {
      //add event handler
      if (ChartControl != null) ChartControl.MouseUp += ChartControl_MouseUp;
      }
      else if (State == State.Terminated)
      {
      //remove event handler
      if (ChartControl != null) ChartControl.MouseUp -= ChartControl_MouseUp;
      }
      }

      private void ChartControl_MouseUp(object sender, MouseButtonEventArgs e)
      {
      //cause a refresh to poll after up click
      ForceRefresh();


      There must be a way to include islocked or change the mouse.up ? Like double clicking the chart to move the indicator. Is there a method for that?

      ty

      Comment


        #4
        Hello frankduc,

        IsLocked is specific to DrawingTools. Locking down where you want something that is drawn with custom rendering so it does not move involves controlling your custom drawing to do so.

        The MouseUp event handler calls ForceRefresh() when a mouse button moves to an upward position. This tells NinjaTrader that this indicator will need to process OnRender the next time the chart updates.

        In OnRender, the example is setting the coordinates to the mouse coordinates and is drawing text at those coordinates. As you click on the chart, this coordinate changes, and the text location moves. If you don't want it to move, you will need to change the coordinates where the text is drawn to. Please see how SampleCustomRender draws "Lower Right Corner" starting at line 230.

        Also, if your goal is simply to view BarsAgo values, I suggest enabling the crosshair and enabling BarsAgo indexes in your data box. (Open Data Box > Right Click > Show BarsAgo.)

        I look forward to being of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          In vertical line you can go to the proprieties setting and click islocked box. In this case from the way i see it, from line 230, if i want to prevent the text from moving on the chart to keep it fix i will have to return everytime in editor to make the change in the coordinate. Nothing is simple with NT.

          Comment


            #6
            Hello frankduc,

            VerticalLines are Drawing Objects, so they have the IsLocked property. If you are performing custom rendering you are telling NinjaTrader you want to take full control over where you want your drawings to be placed and how they should be drawn.

            If this is too difficult, you could elect to use Drawing Tools like Draw.TextFixed. As this is a DrawingTool, the Drawing Object is lockable.

            Draw.TextFixed - https://ninjatrader.com/support/help..._textfixed.htm
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rocketman7, Today, 02:12 AM
            2 responses
            16 views
            0 likes
            Last Post rocketman7  
            Started by briansaul, Today, 05:31 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PaulMohn, Today, 03:49 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by frslvr, 04-11-2024, 07:26 AM
            6 responses
            106 views
            1 like
            Last Post NinjaTrader_BrandonH  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            6 responses
            26 views
            0 likes
            Last Post trilliantrader  
            Working...
            X