Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

InsertComplete

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

    #16
    Using myCollectionChanged

    Here is a modified version of your code
    on this example when a dot is painted on the chart some of its detected settings are correct like its object type, tag name, color, but not its BarsAgo
    May be Im doing something wrong ?

    Thanks !
    Attached Files
    pmaglio
    NinjaTrader Ecosystem Vendor - The Indicator Store

    Comment


      #17
      Are you manually adding the chart object, or is it NinjaScript drawn?

      ChartAnchor.BarsAgo is a NinjaScript property, which would only be set if NinjaScript object drew the object.

      Draw.Dot(this, "dot"+CurrentBar, false, 10, Close[0], Brushes.Blue);

      ChartAnchor.BarsAgo would be 10 in that example.

      If it is a manually drawn object, there is no barsAgo (i.e., what is the bars ago relative to at that point?).

      Instead, you can either get the ChartAnchor.Time or the ChartAnchor.DrawnOnBar.
      MatthewNinjaTrader Product Management

      Comment


        #18
        Thank you Matthew, that was the trouble...
        Thinking it was the same ( manually drawn than ninjascript drawn ) as on n7 with insertcomplete I was testing manually painting the objects...
        ...but through an indicator it works perfect



        but on manually drawn objects it looks like the position can not be retrieved
        Manually Drawn = True
        Bars Ago = -2147483648
        Time = 01-ene-00 00:00:01
        DrawnOnBar = -2147483648

        Print("Manually Drawn = " + x.IsUserDrawn ) ;
        foreach (ChartAnchor anchor in x.Anchors)
        {
        Print("Bars Ago = "+ anchor.BarsAgo);
        Print("Time = "+ anchor.Time);
        Print("DrawnOnBar = "+ anchor.DrawnOnBar);
        }

        I sometimes need to detect when a user paints or moves an object and also know that object chart location....is this possible ?
        Last edited by pmaglio; 10-26-2016, 04:10 PM.
        pmaglio
        NinjaTrader Ecosystem Vendor - The Indicator Store

        Comment


          #19
          The earliest the data you are looking for will be available will be during OnBarUpdate. You will need to use IDrawingTool.Tag and a method similar to the one I posted earlier, with a 1 tick series, to put this information where your event callbacks can get at them.

          I have attached an example where I have done this.

          The attached script will have populated ChartAnchors when an object is removed, but not when it is first added. This code and the sample Matthew posted earlier both act only when a drawing object is created or removed. You will have to use another event to determine whether a drawing tool was modified.

          The attached script also has a method which will tell you the string name (or hex value, if there isn't one) of a passed in brush. For example, if you send it a ForestGreen brush, it will return the string "ForestGreen", and if you send it an RGB FE, DC, BA brush, it will return "#FFFEDCBA" The first FF represents the opacity.
          Attached Files
          Jessica P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AttiM, 02-14-2024, 05:20 PM
          12 responses
          211 views
          0 likes
          Last Post DrakeiJosh  
          Started by cre8able, 02-11-2023, 05:43 PM
          3 responses
          236 views
          0 likes
          Last Post rhubear
          by rhubear
           
          Started by frslvr, 04-11-2024, 07:26 AM
          8 responses
          114 views
          1 like
          Last Post NinjaTrader_BrandonH  
          Started by stafe, 04-15-2024, 08:34 PM
          10 responses
          47 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by rocketman7, Today, 09:41 AM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X