• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart Objects Enhancements

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

    Chart Objects Enhancements

    I have implemented Ninjascript that will send me alerts whenever price crosses a chart object (Ray, Line, Horz Line, Vert Line, etc, Circle, etc). This is not too hard to do. Where I am running into a problem is the way that NT stores Chart Objects. They do not have any identifier as to what Instrument they are are tied to. This creates several problems if I have drawn lines for more than one Instrument on the same chart

    1. when I am getting the list of Chart Objects I get all Chart Objects no matter what Instrument they were drawn on, and I am unable to tell in my code whether or not I should check that Chart Object against the current prices on the Chart Control.

    2. (a bug) If you draw a Chart Object on one Instrument that happens to extend out to values that your next Instrument has in its visible range, then you will see that Chart Object on this Instrument as well which is obviously a bug. This might not be noticed if you are never changing symbols on a chart or your Instruments vary greatly in price.

    It ought to be a easy fix to add an Instrument field to the Chart Object class and to filter the visible Chart Objects using this Instrument value so that only the respective Chart Objects for the current Instrument appear on the Chart. Script would also be able to then determine if a Chart Object was acceptable for the current chart by checking the Instrument of the Chart Object against the Instrument of the ChartControl.

    I like that the Chart Objects stay on the chart no matter if I change the time frame of the bars for a chart.

    #2
    Not sure I follow. NT charts only support 1 instrument for this time. This is a limitations which will be overcome by NT7 later down this year. Thus, there is no such scenario where you would need a "per instrument" logic for your chart objects, since chart objects are unique per chart.
    DierkNinjaTrader Customer Service

    Comment


      #3
      It is correct that you can only show one Instrument at a time, but I often have linked charts or use the Format Dataseries menu item to change the Instrument for a chart. In that case, your Chart Objects now can overlap between Instruments because there is no way to tell which Instrument the Chart Object was drawn on - they will show up for any Instrument that happens to be displayed.

      I have included an example of this below. I have included two screen shots to make this clear using forex EURUSD and EURCAD. First, on EURUSD, I have drawn a vertical line, a ray on price, and a ray on CCI. Next I change the Instrument to EURCAD, and now I still see the ray on price, the vertical line, and the ray on CCI that were drawn on EURUSD. This may not happen as frequently on the price panel for non vertical lines, but it will happen almost everytime with vertical lines and the indicator panels.

      The chart should know that a Chart Object belongs to a certain Instrument and not display it if the current Instrument is not the Instrument that the Chart Object was drawn on.

      Since the chart is storing all these Chart Objects in a single list regardless of what Instrument they were drawn on, it makes it impossible to know which Chart Objects apply to Instrument that is currently on the chart. Here is some code that shows all I can know about any ChartRay objects on a chart:

      foreach (ChartObject co in ChartControl.ChartObjects)
      {
      if (!(co is ChartRay))
      {
      ChartRay cr = co as ChartRay;
      Print("Type: " + cr.ToString());
      Print("Panel: " + cr.Panel.ToString());
      Print("Begin Bar: " + cr.Bar.ToString());
      Print("Begin Time: " + cr.Time.ToString());
      Print("Begin Value: " + cr.Value.ToString());
      Print("End Bar: " + cr.EndBar.ToString());
      Print("End Time: " + cr.EndTime.ToString());
      Print("End Value: " + cr.EndValue.ToString());
      }
      }

      As you can see, there is not any field that I can check for to see what Instrument this object was drawn on - could have been for EURUSD or EURCAD or any indicator on any Instrument that has displayed at one time on that chart. If my code is spinning through these using simple geometry to calculate intercepts and create alerts, it needs to know which ones apply to the current Instrument price series.

      The only way around this oversight is to have to be forced to erase all previously drawn items for previous Instruments before drawing any new items on the current instrument - which is not desirable as one wants to keep those drawn items around for the next time they bring up the same Instrument on that chart.
      Attached Files

      Comment


        #4
        Thanks for clarification. We'll add your suggestion to the list of future considerations.

        Also: working with the ChartObjects collection is not supported at this time. You can achieve what you are looking for by adding the instrument name to the object tag on the Draw... methods.
        DierkNinjaTrader Customer Service

        Comment


          #5
          Way to check VisibleOnInstrument tag for ChartObject?

          This thread is 2008, but it's 2014 and I've noticed that NT7 still does not have this functionality and shares one common chart name space.

          However, I do see that in the Workspaces XML files that there is stored a tag that looks like:

          <VisibleOnInstrument>DIA</VisibleOnInstrument>

          Is there a method perhaps something like:

          class Ninjatrader.Gui.Chart.ChartObject.HasVisibleOnInst rumentTag

          That can be used for a quick check to see if a chart object was drawn on the currently displayed instrument?

          Is there a listing of the ChartObject methods URL that someone can point me to please?

          I am trying to get the NT Public forum LabelHorzLinesAlerts script indicator to only label when a horizontal line is applicable to the instrument currently being displayed on the chart. Otherwise the ChartObject will return a lot of labels associated with other Instruments, but loaded into the same chart at some time in the past.

          Right now, the publicly downloadable script does this:

          foreach (ChartObject co in ChartControl.ChartObjects)
          {
          if (co is ChartHorizontalLine)
          {
          // actions

          I would like it to look more like this:

          string instrumentName = Chart.CurrentInstrumentName;
          foreach (ChartObject co in ChartControl.ChartObjects)
          {
          if (co is ChartHorizontalLine && co.HasVisibleOnInstrumentTag == instrumentName)
          {
          //actions

          Thank you.

          Comment


            #6
            Hello Claybuddy,

            You may want to look at the DrawObjects from the help guide. This is going to be a list of the draw objects added either manually or through script.

            The sample in there show's how to get tag names for global objects of the same instrument, which might get you in the right direction for what you need.

            http://www.ninjatrader.com/support/h...rawobjects.htm
            Cal H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bosajin, Today, 06:27 PM
            0 responses
            2 views
            0 likes
            Last Post bosajin
            by bosajin
             
            Started by saltminer, Today, 06:11 PM
            0 responses
            2 views
            0 likes
            Last Post saltminer  
            Started by epitoma, Today, 05:21 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_ShawnB  
            Started by BatBart, Today, 01:24 PM
            1 response
            23 views
            0 likes
            Last Post NinjaTrader_Melissa  
            Started by ezrakoper, Today, 03:05 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X