Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Programmatically draw a global draw object

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

    Programmatically draw a global draw object

    From the sample code in help it appeared that adding a "@" to the beginning of a draw tag might do it but it doesn't work. The line I draw on one chart doesn't appear on the others. Any ideas?

    Eg. DrawHorizontalLine("@TopRange", true, RangeHigh, Color.Red, DashStyle.Solid, 2);
    ^

    #2
    Hello,

    Thanks for the note.

    Unfortunately this is not possible to do at this time. The strategy or indicator would need to be run on each chart in this instance.

    Let me know if I can be of further assistance.

    Comment


      #3
      Hi Brett,

      I am having a similar problem as this gentleman. I am just trying to draw a line on a chart in the market replay connection. The code is as follows

      private void drawTrendLine(){
      string label = "trendLine" + drawCounter.ToString();
      int startx = getstartX();
      int endx = getendX();
      double startY = getStartY();
      double endY = getEnd();
      Print("Drawing Trend Line: startx =" + startx + " endx = " + endx + " starty = " + startY + " endy = " + endY);//This prints correct values
      DrawLine(label, startx, startY, endx, endY, Color.Black);

      drawCounter = drawCounter+1;

      } //end drawTrendLine method

      Is there any reason this method should not work? Can you not draw objects in market replay or not draw them with a strategy? If either of those things are possible could you point me to a code example. I don't want to use plots because I am not using a DataSeries Object. I just want to draw the line using my own calculated values.

      Comment


        #4
        Originally posted by ggerstein View Post
        Hi Brett,

        I am having a similar problem as this gentleman. I am just trying to draw a line on a chart in the market replay connection. The code is as follows

        private void drawTrendLine(){
        string label = "trendLine" + drawCounter.ToString();
        int startx = getstartX();
        int endx = getendX();
        double startY = getStartY();
        double endY = getEnd();
        Print("Drawing Trend Line: startx =" + startx + " endx = " + endx + " starty = " + startY + " endy = " + endY);//This prints correct values
        DrawLine(label, startx, startY, endx, endY, Color.Black);

        drawCounter = drawCounter+1;

        } //end drawTrendLine method

        Is there any reason this method should not work? Can you not draw objects in market replay or not draw them with a strategy? If either of those things are possible could you point me to a code example. I don't want to use plots because I am not using a DataSeries Object. I just want to draw the line using my own calculated values.
        From the style of your code, are you sure that this line:

        Code:
        double endY = getEnd();
        is not supposed to actually read:

        Code:
        double endY = getEnd[COLOR=Red][B]Y[/B][/COLOR]();
        ?

        Comment


          #5
          Hello,

          Furthermore, what exactly does not work in the code.

          Do you get Print() to output if you add in Print to make sure it is working as expected?

          -Brett

          Comment


            #6
            Hey Brett,

            Thank you for taking the time to reply. The problem is the the drawing object just does not show up on the chart. Actually you are correct about that function name. That was a typo, but those functions are really just placeholders to show the code they are not the actual functions being called.

            The functions being called for startx, starty, endx, endy all work and return correct values in the output window so I know that the input passed into the DrawLine(label, startx, startY, endx, endY, Color.Black); is valid input.

            What I am thinking now, but haven't tried it yet, is that I have to maybe use a Plot to draw on the chart? That I have to add an indicator of some kind for example using the Add( Indicator Object); in the Strategy and then have the Indicator do the drawing? Is that a correct understanding? I just don't know if you can call DrawLine() from directly within a Strategy. This is really the source of my question. Thank you.

            Comment


              #7
              Originally posted by ggerstein View Post
              Hey Brett,

              Thank you for taking the time to reply. The problem is the the drawing object just does not show up on the chart. Actually you are correct about that function name. That was a typo, but those functions are really just placeholders to show the code they are not the actual functions being called.

              The functions being called for startx, starty, endx, endy all work and return correct values in the output window so I know that the input passed into the DrawLine(label, startx, startY, endx, endY, Color.Black); is valid input.

              What I am thinking now, but haven't tried it yet, is that I have to maybe use a Plot to draw on the chart? That I have to add an indicator of some kind for example using the Add( Indicator Object); in the Strategy and then have the Indicator do the drawing? Is that a correct understanding? I just don't know if you can call DrawLine() from directly within a Strategy. This is really the source of my question. Thank you.
              1. On the line that does not draw, what are the actual startX ... values?
              2. Are there any error messages in your log?

              Comment


                #8
                You can call DrawLine from a strategy no problem.

                You would need to print out your inputs and make sure everything is getting called correctly. More then likely the problem is there.

                If you run out of ideas however you can always send code into support at ninjatrader dot com and I can take a quick look at it. However at this stage first step is to debug with Koganams idea's and also to start adding Prints for all the inputs and the making sure the DrawLine is being called from inside OnBarUpdate().

                -Brett

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                3 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                1 view
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                6 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                10 views
                0 likes
                Last Post bltdavid  
                Working...
                X