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

get text to draw in Indicator window

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

    get text to draw in Indicator window

    Hello,

    I have an indicator that draws the bar's number, giving the value of 1 to the 1st bar of the session, 2 to the second, etc... One version draws the text at an offset off the high of the bar, another version draws the text at a value defined in the input.

    I want to create a version that puts the number in the indicator window with reference to the bar above it.

    I have tried a number of ways but can not get drawtext to put text in the indicator window. I am successful in making drawdot work in the indicator window as I need. With my simple example I only change the value of DrawOnPricePanel = true to DrawOnPricePanel = false and the dots get drawn as required, but drawtext will only draw in the main bar chart window.

    Any ideas?


    I have the latest version of 6.5. My OS is Vista 32 bit.





    #2
    Hello Tulanch,

    This should work the same way with DrawText as DrawDots.




    A couple notes:
    • Look closely at the Y value where you are drawing, because if you were drawing from bar highs or lows, this might not use the same scale as the indicator pane.
    Example below will draw near the MACD value + .1


    Code:
     
    Plot0.Set(MACD(12, 26, 9)[0]);
     
     
    DrawText("a" + CurrentBar, CurrentBar.ToString(), 0, MACD(12,26,9)[0] + .1, Color.Black);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      still not progress... dots will draw, text will not draw....
      here is my code snipit:
      private Font textFont = new Font("Courier", 11, FontStyle.Bold);
      protectedoverridevoid Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGree n), 10, "Cen0"));
      DrawOnPricePanel = false;
      CalculateOnBarClose = true;
      Overlay = false;
      }
      protectedoverridevoid OnBarUpdate()
      {
      Plot0.Set(MACD(12, 26, 9)[0]);
      DrawDot("dot" + CurrentBar, false, 0, MACD(12,26,9)[0] + .1, Color.Blue);
      DrawText("a" + CurrentBar, CurrentBar.ToString(), 0, MACD(12,26,9)[0] + .1, Color.Black);
      }

      Comment


        #4
        Tulanch,

        Please make sure you've recompiled recently and then remove and reapply the indicator. It may help to comment out the dot reference so you can verify the text is drawn. Attached screenshot shows what it should look like.
        Attached Files
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I am quite positive I have saved and recompiled the code... I have ensured to remove it and then re-apply it. I have also ensured that it is not in any of the multiple charts I have up. I have also tried it with and without the dots - getting the same results.

          In another thread on this subject there was a MACD2 example given that put text on the MACD (it was the full code example, not just the snipit). I downloaded, saved, and complied that code and it would not draw text either.

          I have read others having issues with this, indicating they edited something in an XML file assocated with the install which fixed this issue - they said is was something akin to doing a re-install of ninja... any idea what that may be?

          Comment


            #6
            Hi Tulanch,

            We don't support modifying xml files to fix NinjaScript issues. I'm not familiar with the method you describe but if you can link to the discussion I'll see what I can find out. If you feel there may be issues with your installation, can follow the steps below for a complete uninstall / reinstall.

            1. Close all running applications.
            2. Then from the Start menu select --> Control Panel --> Add and Remove Programs.
            3. From Add and Remove Programs select NinjaTrader 6.5 and click Remove.
            4. Then manually delete the folder "NinjaTrader 6.5" located under Start --> My Documents.
            5. Delete any NinjaTrader installation files. This can be done by going to Start --> My Computer --> Search button --> search for (NinjaTrader*) --> select Local C Disk and then press search.
            6. Then you will need to clear your internet browser cache and history. You will clear this from within your internet browser (with IE, Tools-->Options, delete cookies and files, clear history).
            7. Reboot your machine.
            8. Once these steps are completed, download NT6.5 from the link below:
              Download
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              I got it working by saving my workspace to something named other than "default" and then exited ninja.

              I then re-booted my machine.

              Upon restarting ninja the text and dots appeard from my code that I supplied in this link.

              From what I read, this appraoch makes the default.xml file empty.

              Here is the the link....

              Comment


                #8
                Hello tulanch,

                Thanks for sharing that link and I'm glad to see that it offered a solution for you.

                Correct, renaming or deleting default.xml causes it to create a new file.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Brevo, Today, 01:45 AM
                0 responses
                2 views
                0 likes
                Last Post Brevo
                by Brevo
                 
                Started by aussugardefender, Today, 01:07 AM
                0 responses
                3 views
                0 likes
                Last Post aussugardefender  
                Started by pvincent, 06-23-2022, 12:53 PM
                14 responses
                238 views
                0 likes
                Last Post Nyman
                by Nyman
                 
                Started by TraderG23, 12-08-2023, 07:56 AM
                9 responses
                384 views
                1 like
                Last Post Gavini
                by Gavini
                 
                Started by oviejo, Today, 12:28 AM
                0 responses
                4 views
                0 likes
                Last Post oviejo
                by oviejo
                 
                Working...
                X