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 want to print wingding characters on my chart. I have completed the following steps as described here: http://www.ninjatrader-support2.com/...t=custom+arrow and as an example wish to print the characters as a test from OnBarUpdate using a re-created version of the Bollinger indicator


    1) Added this to #region variables:
    private System.Drawing.Font textFont;

    2) Added to OnBarUpDate():
    textFont = new Font("Wingdings",12);
    DrawText("tag1","‡",period,High[period]+TickSize,Color.Black, textFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);

    But this prevents the bollinger bands from printing at all the chart is blank. Here is the entire OnBarUpDate) method:

    protected override void OnBarUpdate()
    { //Set font type


    Upper.Set(SMA(Period)[0] + NumStdDev * StdDev(Period)[0]);
    Middle.Set(SMA(Period)[0]);
    Lower.Set(SMA(Period)[0] - NumStdDev * StdDev(Period)[0]);
    //DrawText("tag1", "Text to draw", 10, 1000, Color.Black);
    //DrawTextFixed("tag1", "Text to draw", TextPosition.TopRight);
    //DrawText("tag1", "‡", 10, 1000, Color.Black);
    //IndicatorCheck();
    textFont = new Font("Wingdings",12);
    DrawText("tag1","‡",period,High[period]+TickSize,Color.Black, textFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
    }

    I'm doing something wrong, thanks for any advice.

    #2
    If you are saying it only is broken when using wingdings, then...

    I only briefly looked, but in wingdings regular chars (a-z, 0-9) represent special symbols.

    So instead of sending ‡ to be drawn, instead try sending "a" or whatever corresponds to ‡.

    For me when I needed this, I used Word, changed to Wingdings, and just typed out a-z, 0-9 and mapped them. I'm sure there is an easier way.

    Mike

    Comment


      #3
      Originally posted by ctrlbrk View Post
      If you are saying it only is broken when using wingdings, then...

      I only briefly looked, but in wingdings regular chars (a-z, 0-9) represent special symbols.

      So instead of sending ‡ to be drawn, instead try sending "a" or whatever corresponds to ‡.

      For me when I needed this, I used Word, changed to Wingdings, and just typed out a-z, 0-9 and mapped them. I'm sure there is an easier way.

      Mike
      Thanks for the suggestion. I followed your suggestion and entered a , which looks to be wingding code for a down arrow. Unfortunately, it still doesn't print and also prevents the bollingers from printing on the chart.
      I tried for example "9" and "," for the text with no luck.

      Someone else trying to help me suggested adding this:

      vFonts = new Font[4]; vFonts[0] = new Font("Arial", 10);
      vFonts[1] = new Font("Arial", 15);
      vFonts[2] = new Font("Arial", 22);
      vFonts[3] = new Font("Arial", 32);



      but I'm not sure how it relates I am new to Ninjascript

      Comment


        #4
        If its preventing you from printing the Bollingers I suggest you check the Control Center logs for errors.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          If its preventing you from printing the Bollingers I suggest you check the Control Center logs for errors.
          Here is the error:

          5/22/2009 11:28:11 AM Default Error on calling the 'OnBarUpdate' method for indicator 'MyCustomIndicator' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection.
          Parameter name: index

          Comment


            #6
            Originally posted by NinjaTrader_Josh View Post
            If its preventing you from printing the Bollingers I suggest you check the Control Center logs for errors.
            Also note that I copied the code from the Bollinger indicator, pasted it into a new one and did a find and replace. replacing Bollinger with 'MyCustomIndicator'. Wasn't sure how else to do this or if it broke some initialization code..

            Comment


              #7
              Please check into this tip here - http://www.ninjatrader-support2.com/...ead.php?t=3170

              Also please post the full, up to date code that you're using now for review.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Ok I will look at that here is the code I am using attached

                Originally posted by NinjaTrader_Bertrand View Post
                Please check into this tip here - http://www.ninjatrader-support2.com/...ead.php?t=3170

                Also please post the full, up to date code that you're using now for review.
                Attached Files

                Comment


                  #9
                  Hi, you would need to debug your second DrawText statement and input the correct parameters in the overload as per this link - http://www.ninjatrader-support.com/H.../DrawText.html
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    This code can't work because you refer to High[period] in DrawText() and period is set to 14. To get it running you need to skip OnBarUpdate() as long as CurrentBar < period.

                    Regards
                    Ralph

                    Comment


                      #11
                      Originally posted by NinjaTrader_Bertrand View Post
                      Hi, you would need to debug your second DrawText statement and input the correct parameters in the overload as per this link - http://www.ninjatrader-support.com/H.../DrawText.html
                      I am trying it with this format but not seeing the signal, I am at least getting the bollingers to show up though.

                      Using this statement:

                      DrawText("tag1", "v", 0, 5, Color.Black);

                      Complete code attached
                      Attached Files

                      Comment


                        #12
                        dirtybrown,

                        As Ralph mentioned, you need to check that you have enough bars before you can do such an operation. Please see this tip: http://www.ninjatrader-support2.com/...ead.php?t=3170
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks everyone for your help.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by algospoke, Today, 06:40 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post algospoke  
                          Started by maybeimnotrader, Today, 05:46 PM
                          0 responses
                          7 views
                          0 likes
                          Last Post maybeimnotrader  
                          Started by quantismo, Today, 05:13 PM
                          0 responses
                          7 views
                          0 likes
                          Last Post quantismo  
                          Started by AttiM, 02-14-2024, 05:20 PM
                          8 responses
                          168 views
                          0 likes
                          Last Post jeronymite  
                          Started by cre8able, Today, 04:22 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post cre8able  
                          Working...
                          X