Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating signal value based on drawobject of another indicator

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

    Creating signal value based on drawobject of another indicator

    I am using 3rd party indicators that unfortunately fire signals only as draw objects on the chart (ArrowUp, ArrowDown...), and have no output dataseries. I would like to use this data in strategy, so I am trying to build an indicator that will create a signal output data series base on these draw signals, probably 2 series: one with the current price (intrabar close) and the other with 0,-1,1 for the signals.

    I was looking at the documentation https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?drawingtools_drawobj ects.htm, but testing it, it seems that my indicator doesn't see and drawobject that was created by another indicator. On the other hand, if my indicator creat and object, it works. Here is what I am trying to do as a test (first draw a line to see that it works):

    Code:
    protected override void OnBarUpdate()
    {
      // Loops through the DrawObjects collection via a threadsafe list copy
      foreach (DrawingTool draw in DrawObjects.ToList( ))
      {
        if (draw is DrawingTools.ArrowUp || draw is DrawingTools.ArrowUp)
        {              
            // Indicates if this is a manually drawn or script generated line
            Draw.VerticalLine(this, @"Signal " + Convert.ToString(CurrentBars[0]), 0, Brushes.White);
        }
      }  
    }
    I also tried to do the same on OnStateChange for (State == State.Historical) or (State == State.Realtime) with the same results: the DrawObjects shows 0 items.

    I did search the forum and couldn't find any similar issue. I know this is possible, as there are some solutions out there to execute orders based on the same input. Any suggestions?

    #2
    Hello,

    It would be recommended to set a plot value when the drawing object is drawn, which can easily be read as a signal to a calling host script.

    Below is a link to an example.


    However, you can loop through the indicators DrawObjects collection from a host script. myIndy.DrawObjects.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you ChelseaB, for your quick reply. I probably did not explain myself clearly.

      I am using a 3rd party indicator on the chart, which I have no control of, nor the code. This indicator is creating buy and sell signals, by drawing up arrows and down arrows on the screen. I would like to read these markers and input my indicator based on these drawn objects.

      So the plot issue (which I clearly understand), is not the issue. The issue is how can I "see" the drawn objects that are shown on the chart. Here is the chart, with these arrows. The objects are shown in the list (Chart->Drawing Tool->Drawing Objects...). But in my indicator, which tries to loop through these objects, don't "see" anything (the DrawObjects list is empty). When I add objects using my indicator, it works.

      So there might be a different list of the entire chart draw object? If there is, how do I access it from OnBarUpdate?

      Code:
      protected override void OnBarUpdate()
      
      {
      // Loops through the DrawObjects collection via a threadsafe list copy
        foreach (DrawingTool draw in DrawObjects.ToList())
        {
          // Finds line objects that are attached globally to all charts of the same instrument
          if (draw is DrawingTools.ArrowDown || draw is DrawingTools.ArrowUp)
          {
             Draw.VerticalLine(this, @"Signal " + Convert.ToString(CurrentBars[0]), 0, Brushes.White);
          }  
        }  
      }
      Click image for larger version

Name:	Screen Shot 2022-05-09 at 11.27.38 AM.png
Views:	308
Size:	53.2 KB
ID:	1200471

      Comment


        #4
        Hello Shai Samuel,

        The last sentence in post #2. Loop through the indicators DrawObjects.

        Instantiate the indicator to a variable.

        private MyIndicatorName myVariableHoldingTheIndicator;

        myVariableHoldingTheIndicator = MyIndicatorName();

        Loop through the indicators DrawObjects.

        foreach (DrawingTool draw in myVariableHoldingTheIndicator.DrawObjects.ToList() )


        That said, the better way would be to contact the 3rd party and request they set plot values so that these can be used as signals. You can provide them my example.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        345 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X