• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Image (png) on Chart

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

    Draw Image (png) on Chart

    Hello,

    I'm trying to load an image from file and display it on the chart; a company logo.

    Using the example NinjaJess posted here, I am getting an exception "Unsupported Pixel Format." I have connected with the debugger and changed to the PixedFormat that RenderTarget is using, but the same exception persists.

    Any light you may be able to shed would be helpful.

    Thank you
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    #2
    Hello mrlogik,

    Thanks for opening the thread.

    I recently made some changes to the example Jesse posted to dispose of any resources needed to create the bitmap on RenderTarget changes and on the indicator's termination.

    Attached is an updated example. If you are still able to encounter issues with this script, could you provide us some steps we could take to reproduce on our end?

    We are happy to look into this further as needed.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Works perfectly, thank you Jim
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        Thank you Jim.

        How can I test if the file exists?

        In NT7 all is very easy with Drawing and Drawing2D namespaces, but in NT8 are limited !? why?

        I cant use the simple code: if (File.Exists(@"C:\Users\Public\signal_short.wav") ...

        Comment


          #5
          Hello ninjo,

          File.Exists would be included with System.IO. You will need to add a using statement to use System.IO with your script. An example that uses System.IO with NT8 can be found below.

          https://ninjatrader.com/support/help..._propertie.htm

          Let us know if you have any questions.
          JimNinjaTrader Customer Service

          Comment


            #6
            Hello Jim,

            i tried using your draw bitmap example in a code I built for a client and NT crashes if the indicator isn't set to OnBarUpdate as the calls to get the picture are too frequent.
            Is there a way to cache the bitmap in memory and just retrieve it without getting the Direct X error?

            Comment


              #7
              Hello MazaMaza,

              Thanks for your post.

              The example disposes and recreates in OnRenderTargetChange and draws in OnRender. It stays in memory until it the RenderTarget changes and we need to update the bitmap.

              If you need to update the bitmap in OnBarUpdate, I would recommend setting some class level variables and a bool for "NeedsUpdate" Then on the next OnRender, you could check the bool and call a method that does the regular disposing and recreating that is done in OnRenderTargetChange to load the new bitmap.

              I'm not exactly sure of the full scope of your issue without seeing an example. If you would like to modify the script so it is showing what you are doing, I could give further insight.

              ​​​​​​​I look forward to assisting.
              JimNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ttodua, Today, 01:52 PM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by muisca, 05-19-2017, 11:49 AM
              8 responses
              6,466 views
              0 likes
              Last Post NinjaTrader_Tyler  
              Started by NinjaTrader_Brandon, Today, 12:08 PM
              0 responses
              77 views
              0 likes
              Last Post NinjaTrader_Brandon  
              Started by iq200, Today, 12:00 PM
              2 responses
              11 views
              0 likes
              Last Post iq200
              by iq200
               
              Started by valhallafutures, Today, 11:33 AM
              1 response
              20 views
              0 likes
              Last Post NinjaTrader_PatrickG  
              Working...
              X