Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

DrawText

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

    DrawText

    I'm trying to build a small dashboard.

    I loop through a small array were I've load in the instrument names and one time it worked then it stopped. It seems pretty straight forward.

    int y = 8;
    for (int z = 1; z < 1; z++)
    {
    Draw.Text(this, z.ToString(), Pairs[z], 18, 250 - (z * y), Brushes.White);
    }

    Thanks in advance!!

    #2
    Hello,

    Thank you for the post.

    I would not expect this loop to do anything currently due to the values being used.

    You have int z = 1 and are checking that 1 is less than 1: z < 1.

    When this had worked previously, were you using 0 for int z by chance? That would have iterated one time:

    Code:
    for (int z = [B]0[/B]; z < 1; z++)
    {
    Otherwise you would need to increase the limit of the loop to have at least one iteration:

    Code:
    for (int z = 1; z < [B]2[/B]; z++)
    {
    Code:
    for (int z = 1; z [B]<=[/B] 1; z++)
    {
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      That was a typo:

      int y = 8;
      for (int z = 1; z < 10; z++)
      {
      Draw.Text(this, z.ToString(), Pairs[z], 18, 250 - (z * y), Brushes.White);
      }

      Thanks!!

      Comment


        #4
        Hello,

        In this case, that would not be enough information to know why that is not working on your specific script.

        A loop would loop if possible if the objects are not being drawn that would likely be for another reason.

        I would suggest using Prints to see if your logic is happening to start with if so you can also check other variables to see what may be happening.

        Code:
        int y = 8;
        Print("Before loop");
        for (int z = 1; z < 10; z++)
        {	
        Print("in loop" + z);
        Draw.Text(this, z.ToString(), Pairs[z], 18, 250 - (z * y), Brushes.White);	
        }
        I noted you are not using the overloads with AutoScale, are you certain the prices being used are within the current chart view and would be visible? Have you also checked in Historical data or scaled the chart to see if they are outside of the view?



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Is there a post to show me how to use overloads with AutoScale?

          Thanks!!

          Comment


            #6
            Hello,

            Thank you for the reply.

            We have examples of all the overloads for each tool in the help guide article for each tool.


            Any that include "bool isAutoScale" would be fine to use to enable autoscale, it would just depend on what other parameters you may need as to which overload set you might pick.

            Draw.Text(this, "TestTag", true, "Some Text", 0, Close[0], 0, Brushes.Red, new SimpleFont(), TextAlignment.Center, Brushes.Orange, Brushes.Black, 10);

            I look forward to being of further assistance.
            Last edited by NinjaTrader_Jesse; 05-11-2017, 07:00 AM.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Here is the script that I'm using, still can't get it to work.

              Thanks!
              Attached Files

              Comment


                #8
                Hello,

                Thank you for the post.

                I see that you are adding multiple series are you able to view data for all the added instruments in a chart currently? In the case one of the added series is not loading data, you would likely see this fail.

                Additionally, I see you are only executing this in Realtime, are you allowing a Bar to close in realtime while testing?

                I can see the code in OnBarUpdate works if I remove the additional series, I was unable to get data for all the instruments in question so the indicator was stopped before doing any work in that situation.

                I look forward to being of further asssitance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Actually, it shouldn't have worked since in my attempt to sanitize the script I removed the step that loads the array.Try this version.

                  Thanks!!
                  Attached Files

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    My questions would still be the same after your changes, are you getting data for all the instruments you are using? Could you try opening a chart for each of these instruments and ensure you can receive live data?

                    I see that you changed the check for BarsInProgress so that the script only executes on the secondary series added after the primary, I do see this working on my end so long as I use instruments I have live data for and wait at least 5 minutes of realtime for one of the secondary series to close a bar.

                    Could you confirm you checked these items?

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Yes, I'm getting data. I use it to get data for several indicators, so the data is there, I'm also only testing when the market is open.

                      Thanks!!

                      Comment


                        #12
                        Hello,

                        I could really only suggest to reduce the code you are using and start from a point where you can see your prints and a Drawing object without any secondary series or the logic associated. Again I can see this working as it stands so it may be something to do with the setup, or expectation on how it should run on your end.

                        I had to wait around 6 minutes to see the text initially appear because I had to wait for a secondary close.

                        It may be easier to start more simple with a single series and ensure you can both Print and Draw Text to the chart. After doing this, you could add 1 secondary series and then ensure that works before adding more. This would likely be the approach I would suggest to find where the problem is on your end.

                        Additionally, if you have not removed the indicator from the chart since you have added the secondary series, please also try removing it from the chart completed and the re-apply it. When changing DataSereies for scripts this is a necessary step.

                        I look forward to being of further assistance.
                        JesseNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Rapine Heihei, Today, 07:51 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post Rapine Heihei  
                        Started by frslvr, 04-11-2024, 07:26 AM
                        5 responses
                        96 views
                        1 like
                        Last Post caryc123  
                        Started by algospoke, 04-17-2024, 06:40 PM
                        6 responses
                        49 views
                        0 likes
                        Last Post algospoke  
                        Started by arvidvanstaey, Today, 02:19 PM
                        4 responses
                        11 views
                        0 likes
                        Last Post arvidvanstaey  
                        Started by samish18, 04-17-2024, 08:57 AM
                        16 responses
                        61 views
                        0 likes
                        Last Post samish18  
                        Working...
                        X