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

saving a screenshot doesnt work on historical data

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

    saving a screenshot doesnt work on historical data

    Hello,

    I want to take screenshots of my chart and save it to my drive when certain conditions are met.
    I use the below code (which is taken from SendMailChart on this site), but it only works on new bars, the image is blank on historical data.

    Any ideas, how i can get a screenshot for historical data as well?

    Thanks a lot!

    Code:
    private void SaveScreenShot(ChartControl chart){
                // get bitmap of chart panel
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(chart.ChartPanel.Width, chart.ChartPanel.Height, PixelFormat.Format16bppRgb555);
                chart.ChartPanel.DrawToBitmap(bmp, chart.ChartPanel.ClientRectangle);
            
                bmp.Save(imageDirectory + fileName, ImageFormat.Png);
                
            }

    #2
    Hi,

    Thanks for posting the code sample. When exactly is this called?

    If the chart is coming back blank, this is hinting that your method isn't being called when the bars data has completed. For example if when currentbar == 0, the chart would be blank.

    You might want to revist this while waiting for OnBarUpdate to complete. You can use the Count property to count how many bars are on the chart and wait until CurrentBar has met the count.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hello,

      Thanks for your quick answer.

      Let me start off by explaining a bit more what i actually want, maybe i am going at it from a wrong angle. I have a strategy that buys and sells on certain triggers. To improve this strategy i would like to look at the charts where the trigger happens to get a better feeling of what happens how often.

      I tried doing this by calling the code in my original post from within the OnBarUpdate method when the trigger conditions are met. OnBarUpdate ist called on every (historical) bar in my chart, but the screenshot function only produces the right picture for new non-historical bars.
      When i open a chart with an instrument and load three weeks of data, the strategy goes through every bar (i make marks in the chart when the trigger happens) but the screenshot comes out empty (a white image with the charts dimensions). When i keep it running it will produce the correct screenshot on new live bars.

      I would really like to get the screenshots for historical data. I hope i explained my problem well enough, any help is appreciated!

      By the way, i have the same problem with an Indicator i implemented a while ago, but i am pretty sure it did work on historical data at some point in time as well with the same code. Maybe it's some chart configuration?

      Thanks again for your help!

      EDIT: It would be even greater if it would work from the backtesting, but i think there has to be a chart window for it to work, right?
      Last edited by styx2000; 11-16-2013, 05:12 AM.

      Comment


        #4
        I don't believe this is going to work like you're expecting if I understand your description correctly.

        The historical data processing does not build bars in the manner that would allow you to take screen shots when XYZ condition has been met.

        What you would need to do is wait for the data processing to finish, once completed the visual representation of this is built in the chart, and at that time you would need to come up with a way to programmatically scroll the chart to that bar. There is not a supported method for doing so, however you may explore the unsupported ChartControl class via intellisense to see if you can find something that can help. I do not suspect this will be an easy task and we don't have any experience in doing so although it would technically be possible.

        The following thread may be useful for you to find the bar on the canvas:

        MatthewNinjaTrader Product Management

        Comment


          #5
          While I agree with NT_M...

          The only other chance you might have is using.chartcontrol.refresh or something.. but that's a big if.. those aren't exactly being built the same way going forward.

          Comment


            #6
            Another idea would be to use Market Replay to generate the screen shots you're looking for, assuming your current method would consider that 'real-time data"
            MatthewNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by LawrenHom, Today, 10:45 PM
            0 responses
            3 views
            0 likes
            Last Post LawrenHom  
            Started by love2code2trade, Yesterday, 01:45 PM
            4 responses
            28 views
            0 likes
            Last Post love2code2trade  
            Started by funk10101, Today, 09:43 PM
            0 responses
            7 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            37 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Yesterday, 08:51 AM
            8 responses
            44 views
            0 likes
            Last Post bill2023  
            Working...
            X