Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawText()

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

    DrawText()

    Using DrawText() with Barsago to set the x position. Is there a way to Reposition/DrawText
    again without having to remember the Color etc. that was used. I am able to recompute the Tag that was used for the DrawObject of interest so possibly the The color and other attibutes of the object could be read before drawing. Or do I have to just create an array of variables for all this stuff.

    thanks
    Jerry

    #2
    Hello Jerry,

    Thank you for your note.

    If I'm following you, you can change the DrawText() placement by changing the BarsAgo and using the same tag name for the first instance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Ninjatrader_Cal,

      I did not think that Drawtext[] had an overload method which took only two arguments. Tag and Barsago, So on your suggestion I tried it. It doesn't. So I think your not following me. I don't want to have to recompute the color, background, opacity etc. for each object I want to move. I know calling DrawText again with the same Tag and different Barsago will move the object. However, How do you get around having to either remember or recompute all the other variables used at the initiation of the DrawObject in order to move it without changing it.

      Jerry

      Comment


        #4
        Jerry,

        It does not have two overloads. You will need to reference the same line of code for the first placement as you would in the second. You can Copy and paste the first line that it is written and change the BarsAgo in the second one.

        Let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Jerry,

          It does not have two overloads. You will need to reference the same line of code for the first placement as you would in the second. You can Copy and paste the first line that it is written and change the BarsAgo in the second one.

          Let me know if I can be of further assistance.
          NinjaTrader_Cal

          Your not answering my question, I have explained that all those other variables in the line your talking about copying have changed. So in order to execute that line properly
          to move the text without changing it all those variables would need to be "example" read back from the DrawObject to properly execute the draw Statement. Is there a way to read back those parameters ?

          Jerry

          Comment


            #6
            Jerry,

            I think we getting lost here.

            Let me give you an example of what you can do here.

            Let's say that the you draw the line using the below -
            Code:
            DrawLine("myTag",  10, Low[0], 0. High[0], Color.Black);
            Now we move on a couple bars and want to change the look back for the bars ago in the first property, 10. We will call the same line as above but change the 10 value
            Code:
            DrawLine("myTag",  15, Low[0], 0. High[0], Color.Black);
            By using the same tag name it will grab the first draw object and redraw it with the updated values.



            Let me know if this makes more sense.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Cal,

              And that does not work because when the second Draw is done we don't know what color it was drawn with unless we either remember it or can read it back from the draw object which the question I keep asking but you seem unwilling to answer.

              Jerry

              Comment


                #8
                Jerry,

                I think I see what you are saying now.

                Let me try this approach, if it is not what you are looking for let me know and I'll consulate with some colleagues.

                You would want to create an IDrawObject here or an ILine object more specifically.

                This will allow you to get and set the values with having to call the entire DrawLine() method again.

                Example -
                Code:
                OnBarUpdate()
                {
                     ILine myLine = DrawLine("myTag",  10, Low[0], 0. High[0], Color.Black);
                
                     myLine.StartBarsAgo = 15;
                }
                You can reference myLine at any point in the script to change these values.

                http://www.ninjatrader.com/support/h...html?iline.htm

                Let me know if I can be of further assistance.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Assuming this works for DrawText() as well this is Exactly what I was looking for. Although it requires rewriting all my DrawText(). In the end it will be more efficient without a lot of overhead code to remember and or recompute variables.

                  Thanks
                  Jerry

                  Comment


                    #10
                    Jerry,

                    With text, use the IText object -
                    http://www.ninjatrader.com/support/h...html?itext.htm
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by JerryWar View Post
                      Cal,

                      And that does not work because when the second Draw is done we don't know what color it was drawn with unless we either remember it or can read it back from the draw object which the question I keep asking but you seem unwilling to answer.

                      Jerry
                      If you use an IDrawObject, you can always query its properties.

                      More usually, I write a new method that calls the Draw...() method that I want to use. This method gets passed only the parameters that I will be changing. I call the Draw...() method with the invariant parameters fixed, and the other parameters assigned from what was passed in the calling signature.

                      Comment


                        #12
                        Originally posted by koganam View Post
                        If you use an IDrawObject, you can always query its properties.

                        More usually, I write a new method that calls the Draw...() method that I want to use. This method gets passed only the parameters that I will be changing. I call the Draw...() method with the invariant parameters fixed, and the other parameters assigned from what was passed in the calling signature.
                        I didn't understand quite how you do this. So I did a bit of searching. Are you using params in the argument list ?

                        Comment


                          #13
                          Cal
                          Yes , I got that from the link you posted before that.

                          J~

                          Comment


                            #14
                            Originally posted by JerryWar View Post
                            I didn't understand quite how you do this. So I did a bit of searching. Are you using params in the argument list ?
                            Not quite what I meant here, but one could of course do so for extreme flexibility, in which case one would set defaults inside the method, and call the base Draw...() method using those local variables to override whatever is passed in the calling signature for the custom method.

                            An example would probably make it clearer, so here goes.
                            Code:
                            		private void CustomDrawText(string strTag, string strText, int barsAgo, double yValue)
                            		{
                            			using (Font drawFont = new Font("Arial", 10.0f))
                            			DrawText(strTag, true, strText, barsAgo, yValue, 10, Color.Black, drawFont, StringAlignment.Near, Color.Empty, Color.Empty, 0); 
                            			return;
                            		}
                            Now you need to specify only 4 parameters, in this case. You can cut that down by simply following the scheme of what to make invariant in the base Draw() call. Needless to say, you can create multiple overrides using different numbers of parameters.

                            Comment


                              #15
                              Koganam,
                              Its not what I thought you meant. Its pretty close to what I do now that is not flexible enough. So I guess I move to IText so I can just change individual elements.

                              Thanks,
                              J~

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by owenwong, Today, 06:34 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post owenwong  
                              Started by REI140205, Today, 06:17 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post REI140205  
                              Started by Gathem, Today, 06:06 PM
                              1 response
                              14 views
                              0 likes
                              Last Post Gathem
                              by Gathem
                               
                              Started by tg1886, Today, 04:09 PM
                              3 responses
                              25 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by mythue, Today, 03:48 PM
                              2 responses
                              13 views
                              0 likes
                              Last Post mythue
                              by mythue
                               
                              Working...
                              X