Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

position.ToString()

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

    position.ToString()

    Hello,

    with "DrawTextFixed("MyTag", position.ToString(), TextPosition.BottomLeft)"

    there appear so many informations in the chart (instrument, Account, Avg.Price, Quantity, Marketposition).

    How can one have only Quantity and marketposition?

    Thanks
    Tony

    #2
    Hello tonynt,

    Thanks for your note.

    You can access these individual properties of Position and create a new string to display.

    For example:
    Code:
    DrawTextFixed("MyTag", Position.MarketPosition.ToString() + " - " + Position.Quantity.ToString(), TextPosition.BottomLeft);
    Below is a link to the help guide language reference on Position.
    http://www.ninjatrader.com/support/h...7/position.htm


    Please do not hesitate to contact us for any other NinjaTrader inquiries you may have.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your support. And how to add please "$EURUSD" (without "instrument =" ) This is not shown in the link of the help-guide.

      And how one can plot this informations (instrument, quantity, marketposition) not in one line but one below the other eg on bottom left?

      Thanks
      Tony

      Originally posted by NinjaTrader_ChelseaB View Post
      Hello tonynt,

      Thanks for your note.

      You can access these individual properties of Position and create a new string to display.

      For example:
      Code:
      DrawTextFixed("MyTag", Position.MarketPosition.ToString() + " - " + Position.Quantity.ToString(), TextPosition.BottomLeft);
      Below is a link to the help guide language reference on Position.



      Please do not hesitate to contact us for any other NinjaTrader inquiries you may have.

      Comment


        #4
        Hello tonynt,

        Thanks for your reply.

        To add an additional instrument to your script use the Add() method within the script Initialize() function.

        For example:
        Code:
        Add( "$EURUSD", PeriodType.Minute, 1);
        Below is a link to the help guide language reference on the Add() method.
        http://www.ninjatrader.com/support/h...s/nt7/add3.htm


        And how one can plot this informations (instrument, quantity, marketposition) not in one line but one below the other eg on bottom left?
        The Plot class uses a double for its value to plot on the y-axis. You will not be able to use a plot for the instrument name, or market position unless you translate those to numbers somehow.

        If you would like to draw text at the bottom left of the chart you will need to calculate the x (bars ago) and y (price) values and supply those to the DrawText method.

        Below is a link to another forum thread where calculating the x axis value to the left side of the screen is discussed.
        http://www.ninjatrader.com/support/f...43306#poststop


        To get each info piece on its own line you will need to add line breaks to your string.

        An example of a string with line breaks:
        String myString = Instrument.MasterInstrument.Name.ToString() + "\r\n" + "Quantity - " + Position.Quantity.ToString();


        Please let me know if I can be of further assistance.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          ChelseaB,

          thank you for your support!

          Can you please give me also a sample referring your information to drawtextfixed with y-value:
          "If you would like to draw text at the bottom left of the chart you will need to calculate the x (bars ago) and y (price) values and supply those to the DrawText method."

          In all the threads in the support forum there is the answer that one can plot in the determined psoition with drawtextfixed and the other way is to plot with drawtext. But how one can plot eg in the bottomright but 1 line above because in the bottomright there is already a drawtextfixed and therefore to avoid overwriting and for having both (one above the other). And with Drawtext one can plot y below a certain bar or x-bars ago - but how to plot in the corner of the chart with y above to avoid this overwriting.

          Thank you!

          Best
          Tony

          Originally posted by NinjaTrader_ChelseaB View Post
          Hello tonynt,

          Thanks for your reply.

          To add an additional instrument to your script use the Add() method within the script Initialize() function.

          For example:
          Code:
          Add( "$EURUSD", PeriodType.Minute, 1);
          Below is a link to the help guide language reference on the Add() method.





          The Plot class uses a double for its value to plot on the y-axis. You will not be able to use a plot for the instrument name, or market position unless you translate those to numbers somehow.

          If you would like to draw text at the bottom left of the chart you will need to calculate the x (bars ago) and y (price) values and supply those to the DrawText method.

          Below is a link to another forum thread where calculating the x axis value to the left side of the screen is discussed.



          To get each info piece on its own line you will need to add line breaks to your string.

          An example of a string with line breaks:
          String myString = Instrument.MasterInstrument.Name.ToString() + "\r\n" + "Quantity - " + Position.Quantity.ToString();


          Please let me know if I can be of further assistance.
          Last edited by tonynt; 03-15-2013, 02:36 PM.

          Comment


            #6
            Solution.

            If anyone is interested in the solution (maybe there is another one, but I didnt receive an answer, so I tried it myself) one can solve this as follows to bring up in the corners of the chart different text lines with drawtextfixed OBJECTS:

            * the first text is in the corner
            * to bring up another one above (below) you add "\r\n"+ (+ "\r\n") to the parameter "text" (not to Textposition) so that this text is plotted above or below the existing line

            Set outline color and area color to transparent to avoid overlay.

            Best
            Tony

            Originally posted by tonynt View Post
            ChelseaB,

            thank you for your support!

            Can you please give me also a sample referring your information to drawtextfixed with y-value:
            "If you would like to draw text at the bottom left of the chart you will need to calculate the x (bars ago) and y (price) values and supply those to the DrawText method."

            In all the threads in the support forum there is the answer that one can plot in the determined psoition with drawtextfixed and the other way is to plot with drawtext. But how one can plot eg in the bottomright but 1 line above because in the bottomright there is already a drawtextfixed and therefore to avoid overwriting and for having both (one above the other). And with Drawtext one can plot y below a certain bar or x-bars ago - but how to plot in the corner of the chart with y above to avoid this overwriting.

            Thank you!

            Best
            Tony

            Comment


              #7
              Hello tonynt,

              I am glad you were able to find and use the solution of line breaks in your DrawTextFixed.

              I believe that would be the best method of accomplishing multiple messages in the same corner of the chart.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                problem onposition - quantity drawn

                Hello,

                I´m working now fine for weeks with

                DrawTextFixed("TradeSTO",Position.MarketPosition.T oString() + " " + Position.Quantity.ToString(), TextPosition.TopRight,Color.Black, new Font ("Arial",8), Color.Transparent,Color.Transparent,0);

                to make visible trades and positions in the chart.

                Now it occurs that the initial quantity persists here during the trade and scales out are not recognized ("3000", 1000 off and then "2000" and then "1000")

                In the meantime I use "ToString()" in my scripts for counting also other actions.

                Do I have to assign somehow "xy" for "ToString(xy) to work with, when used for different actions?

                Thanks
                Tony




                Originally posted by NinjaTrader_ChelseaB View Post
                Hello tonynt,

                I am glad you were able to find and use the solution of line breaks in your DrawTextFixed.

                I believe that would be the best method of accomplishing multiple messages in the same corner of the chart.

                Comment


                  #9
                  Hi tonynt,

                  The ToString() does not take any overloads parameters.

                  Your usage of this is correct (i.e. Position.MarketPosition.ToString()).

                  To clarify, your script had been showing the correct market position and quantity in the past and is now no longer behaving correctly, is that correct?

                  If you print the position and quantity to the output window are those prints also not reflecting the correct position/quantity?


                  I look forward to your reply.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello,

                    thank you for your reply.

                    Printing in output window didnt work, I have to do again. But I have put chart window to the tab and made a region-screenshot. Here in the screenshot you see that in strategy tab = 2000 for both strategies while same moment in chart there is the entry quantity of 3000 still drawn in the chart.

                    Thanks
                    Tony

                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hi tonynt,

                    The ToString() does not take any overloads parameters.

                    Your usage of this is correct (i.e. Position.MarketPosition.ToString()).

                    To clarify, your script had been showing the correct market position and quantity in the past and is now no longer behaving correctly, is that correct?

                    If you print the position and quantity to the output window are those prints also not reflecting the correct position/quantity?


                    I look forward to your reply.
                    Attached Files

                    Comment


                      #11
                      Hi tonynt,

                      To debug this I recommend you print the values of Postion.Quantity to the output window just before the DrawTextFixed call. This will ensure that the DrawTextFixed is not the issue.

                      Please let me know if printing Position.Quantity just before the DrawTextFixed call shows the correct position quantity.


                      I look forward to working with you further.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello,

                        as I do debugging all the time I changed the print-statement so now one can see the print from onposition. The value - right before the drawtextfixed - is correct and changes quantity (here my 3 stops) as you see:
                        Position.Quantity from OnPosition: 3000
                        09.05.2013 20:12:01
                        Position.Quantity from OnPosition: 2000
                        09.05.2013 20:14:16
                        Position.Quantity from OnPosition: 1000
                        09.05.2013 20:14:16
                        Position.Quantity from OnPosition: 0
                        09.05.2013 20:14:16

                        but still 3000 in the chart.


                        As the Position.Quantity is from the system direct I can not change something of the value and I do not understand why it draws the initial 3000 all the time - and the value 3000 is from Position. Quantity in Onposition with

                        Print("Position.Quantity from OnPosition: " + Position.Quantity); Print(Time[0]);
                        DrawTextFixed("TradeD","\r\n"+ " " + Position.MarketPosition.ToString() + " " + Position.Quantity.ToString(), TextPosition.TopRight,Color.Black, new Font ("Arial",8), Color.Transparent,Color.Transparent,0);

                        Thanks
                        Tony

                        Originally posted by NinjaTrader_ChelseaB View Post
                        Hi tonynt,

                        To debug this I recommend you print the values of Postion.Quantity to the output window just before the DrawTextFixed call. This will ensure that the DrawTextFixed is not the issue.

                        Please let me know if printing Position.Quantity just before the DrawTextFixed call shows the correct position quantity.


                        I look forward to working with you further.
                        Last edited by tonynt; 05-09-2013, 01:45 PM.

                        Comment


                          #13
                          Hello tonynt,

                          Thank you for that test. This helps to see that the issue seems to be with the DrawTextFixed call itself.

                          May I have this script to test with, or a "toy" of this script to test with?

                          If that would be alright, please attach it to your next post. If not or if you would like to send me the code privately please let me know.


                          I look forward to your reply.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            ChelseaB,

                            thank you for your support. I have sent the reduced script by email to you.

                            In the meantime I try to find out and I want to ask if the problem could be that in onExecution I have to cancel 2 stops for one position (but only one of the stops is true in a certain moment of time). I dont want to cancel the stoporders with doubles or flags, this needs more lines in the coding. So I do cancel all stops for a position once exit is filled. Maybe I should move this to onbarupdate?

                            I mean there is for me no logical reason why the drawtextfiext will not draw correctly. Just an idea because I get an error message in the outputwindow for onexecution with "Object not set to an instance..."


                            Best
                            Tony

                            Originally posted by NinjaTrader_ChelseaB View Post
                            Hello tonynt,

                            Thank you for that test. This helps to see that the issue seems to be with the DrawTextFixed call itself.

                            May I have this script to test with, or a "toy" of this script to test with?

                            If that would be alright, please attach it to your next post. If not or if you would like to send me the code privately please let me know.


                            I look forward to your reply.

                            Comment


                              #15
                              Hi tonynt,

                              Thanks for sending in the scripts. I will be replying to your personal email moving forward.

                              In answer to the OnExecution stop orders, these would only affect the DrawTextFixed if they are causing an error, so yes that may be a possibility. I will know more after I have thoroughly tested your script which I am in progress of now.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by mjairg, 07-20-2023, 11:57 PM
                              3 responses
                              213 views
                              1 like
                              Last Post PaulMohn  
                              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                              4 responses
                              543 views
                              0 likes
                              Last Post PaulMohn  
                              Started by GLFX005, Today, 03:23 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post GLFX005
                              by GLFX005
                               
                              Started by XXtrader, Yesterday, 11:30 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post XXtrader  
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Working...
                              X