Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StringFormat Error

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

    StringFormat Error

    I get a compiling error on StringFormat.

    Typ or namespacename "StringFormat" could not be found.....

    Even after adding the System.Drawing.dll to the references the error persists.


    Can anyone help?

    #2
    Hello Atreio,

    What the full error message?

    What is the line of code causing the error?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      first error in the attached file

      the code line is

      private StringFormat stringFormat;


      I understand the error, but the recommended solution doesn't work

      Attached Files

      Comment


        #4
        Hello Atreio,

        Thank you for the screenshot.

        I am not able to read this language, however, I think the error message is saying that StringFormat does not exist.

        That I know of, StringFormat is not something that already exists in C#.
        What is StringFormat? Is this a custom class that you have made?

        Are you trying to make a string to supply to string.Format()?
        https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

        For example:

        In Initialize():
        private string myFormatString = "{0} | {1}";

        In OnBarUpdate():
        Print(string.Format(myFormatString, Time[0], Close[0]));
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          sorry, I'm not such a coding expert. As far as I understand "Stringformat" is a class belonging to the namespace "system.drawing" which was used in NT7. In NT8 "system.drawing" is replaced by another namespace "System.Windows.Media" with different classes, methods and so on.

          in the link below, NinjaTrader_MichaelM say it was possible in NT8 to establish a reference to the library of the "system.drawing" class, which would solve the problem. But still, I cannot compile the code even with the reference to the "system.drawing.dll"

          Comment


            #6
            Hello Atreio,

            Thanks for the link. I understand you are looking for System.Drawing.StringFormat.

            Michael is correct. The System.Drawing reference was removed from NinjaTrader 8 as NT8 will no longer use GDI+ to render. Instead, all rendering is done with SharpDX and rendered on the GPU instead of the CPU.

            May I confirm that you have added the reference to System.Drawing.dll?
            May I have a screenshot of the references you have added?

            To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

            Click here for instructions

            Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

            Click here for detailed instruction
            Last edited by NinjaTrader_ChelseaB; 04-04-2016, 08:39 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea,

              thank you for the answer. Would be great if I really could run the NT7 script with NT8 just by referencing to the .dll file. Changing to SharpDX would be difficult for me
              Attached Files

              Comment


                #8
                Hello Atreio,

                Thanks for the screenshot.

                I think the issue is the path.

                %windowsdir%\Microsoft.NET\Framework\v4.0.30319

                In the screenshot I am seeing Framework64 in the path (though this is partially covered by a tooltip).

                Try using the non-64 version. This does appear to work on my end.


                Also, no it will not be possible to use a NinjaTrader 7 script in NT8. There are many code breaking changes designed to improve reliability, efficiency, and performance.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  unfortunately, still doesn't work with the new path.

                  Comment


                    #10
                    Hello Atreio,

                    I would like to schedule a call with you to assist.

                    Please send an email to platformsupport [at] ninjatrader [dot] com. In the email, please include a link to this forum thread.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      May be you can replace StringFormat with TextFormat. Try to take a part of the following instruction in order to replace the part that you need

                      private TextFormat _fontVar = new TextFormat(Core.Globals.DirectWriteFactory, "Arial", SharpDX.DirectWrite.FontWeight.Normal, SharpDX.DirectWrite.FontStyle.Normal, SharpDX.DirectWrite.FontStretch.Normal, 8)
                      { TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading, WordWrapping = WordWrapping.NoWrap };

                      Comment


                        #12
                        Hello ChelseaB,

                        I have very similar issue with StrinFormat. Is there some solution how to convert it from NT7 to NT8?

                        Here is the code I am trying to convert:

                        private StringFormat stringFormat = new StringFormat();

                        Thank you

                        Miroslav

                        Comment


                          #13
                          Hello Miroslav,

                          Are you wanting to draw text on the screen with SharpDX?

                          An example of drawing text can be found in the help guide on the OnRender page.


                          Attached is the example from the help guide added to a simplified script.

                          The equivalent of System.Drawing.StringFormat is SharpDX.DirectWrite.TextFormat.
                          Attached Files
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello Chelsea B, thank you for your replay.

                            yes. I am trying to plot some text + symbol.

                            I have looked on what you send me but I am not able to link script from NT7 ton NT8 new methods. It is beyond my coding knowledge.

                            Isn´t there some way how I can use sting, DrawString methods also in NT7?

                            Mirolsav

                            Comment


                              #15
                              Mirolsav,

                              GDI+ is used for the chart rendering area in NinjaTrader 7. You must use System.Drawing with NinjaTrader 7.

                              There is no longer a GDI+ rendering target created for the chart in NinjaTrader 8. The chart rendering area in NinjaTrader 8 is a SharpDX rendering area. You must use SharpDX to draw on the charts in NinjaTrader 8.

                              The benefits of SharpDX is that this uses the graphic card (GPU) to render instead of the CPU, allowing for more objects to be rendered faster, and freeing up the CPU for doing other calculations and no longer having to do drawing.
                              GDI+ uses the CPU to render and causes higher CPU usage.

                              If you were to make your own GDI+ rendering area in NinjaTrader 8, this would be outside the realm of what NinjaTrader is able to support, but may be possible. I don't think this could be on a chart, however. This would have to be in an addon. (I'm not certain on this)

                              You can also contact one of our professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Irukandji, Today, 09:34 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by RubenCazorla, Today, 09:07 AM
                              1 response
                              5 views
                              0 likes
                              Last Post RubenCazorla  
                              Started by TraderBCL, Today, 04:38 AM
                              3 responses
                              25 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              11 responses
                              1,423 views
                              0 likes
                              Last Post jculp
                              by jculp
                               
                              Working...
                              X