• 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

screenshot share

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

  • junkone
    started a topic screenshot share

    screenshot share

    when i share via twitter using indicator, i cannot send screenshots. is there a solution/feature planned for this?

  • NinjaTrader_DaveI
    replied
    Thanks for expanding on that a bit. I'll write up that suggestion now, so we can begin to track user demand for making this change. (SFT-1172)

    Leave a comment:


  • marty087
    replied
    Yes Dave, please write up this request. To clarify, the ability to programatically select the tab (to make visible) belonging to the chart running the indicator. This would be a nice feature for many more applications other that just screenshotting, e.g as an alert style for the trader etc.

    Although i am not an experienced developer, I really thought it should be possible to render the chart to a memory stream even though it is not visible. As you said the information is there, should it not just be a case of re-diverting the rendering to a steam as opposed to the screen?

    If i open each chart up in an individual window your script is able to render the chart image to a memory stream even though it it may be overlapped by another chart/window. So the process here is not taking a screenshot as much as it is copying the render that exists in the window. The only difference here is we want to do this with a tab in a window rather that just a window itself.

    Just thinking out loud now. Hopefully we can get a solution here!

    I look forward to hearing more about this. Cheers.
    -

    Leave a comment:


  • music_p13
    replied
    Would be nice to see which tab is visible / selected and possibly select one that is visible but not selected so that snapshot could be sent once it is selected.
    Thanks

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    Not currently, although that is an interesting idea. I'd be happy to write up a feature request for the ability to determine which tab is visible/selected via NinjaScript, if you'd like.

    Leave a comment:


  • marty087
    replied
    OK, is there a way to programatically select the tab in question?

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    There will not be a way to do this using the methodology I shared below. Taking an image captures what is actually being rendered to the screen, and there is no such rendering occurring in an inactive tab. In an inactive tab, your script will have access to the underlying data used to construct a chart, but no actual rendered objects to capture.

    Leave a comment:


  • marty087
    replied
    Hi Guys,

    Still hoping for an answer on this one. The screenshot comes through of whichever chart tab is selected at the time. How do you get the screen capture of the chart even though it may not be the active tab at the time?

    Leave a comment:


  • marty087
    replied
    Originally posted by NinjaTrader_Dave View Post
    Take a look at the attached script, which may shed some light on how to tweak your code. This sample starts off similarly to your code, but takes a different approach to capturing and saving the actual image.
    I just noticed that if the tab that the chart exists on is not selected, the screenshot comes though of the highlighted chart at that time. How do we get the image of the chart running the indicator rather than the current screen image?

    Cheers.

    Leave a comment:


  • marty087
    replied
    Thanks Dave, This works fine.

    For anyone interested, here is my adapted version which saves to memory stream then attaches to an email and sends.

    I have tested this using Gmail and works fine
    Attached Files

    Leave a comment:


  • junkone
    replied
    Originally posted by NinjaTrader_Dave View Post
    Take a look at the attached script, which may shed some light on how to tweak your code. This sample starts off similarly to your code, but takes a different approach to capturing and saving the actual image.
    you guys are just 1 click away from making this a built in function
    As we expect this to be part of the core product?

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    Take a look at the attached script, which may shed some light on how to tweak your code. This sample starts off similarly to your code, but takes a different approach to capturing and saving the actual image.
    Attached Files
    Last edited by NinjaTrader_DaveI; 01-26-2016, 03:39 PM.

    Leave a comment:


  • marty087
    replied
    This seems like the best thread to highjack

    I am trying to create a screenshot of the chart using the below code but the file is just saving as blank. Can anyone tell me why this is? Is the ChartControl the correc object to be passing? This is the way I did it in NT7 but maybe I need to be passing a window object of some sort or something?

    Code:
    		protected override void OnBarUpdate()
    		{
    		
    			if (CurrentBar < Count -2)return;
    
    			this.Dispatcher.Invoke((Action)(() =>
    		    {
    		        if (!ScreenShotSaved){
    					CreateBitmapFromVisual(ChartControl,"d:\\test2.png");
    					Print("Just DOne");
    					ScreenShotSaved = true;
    				}
    		    }));
    			
    		}
    		
    		
    		public static void CreateBitmapFromVisual(ChartControl target, string fileName)
    	    {
    	        if (target == null || string.IsNullOrEmpty(fileName))
    	        {
    	            return;
    	        }
    
    	        Rect bounds = VisualTreeHelper.GetDescendantBounds(target);
    
    	        RenderTargetBitmap renderTarget = new RenderTargetBitmap((Int32)bounds.Width, (Int32)bounds.Height, 96, 96, PixelFormats.Pbgra32);
    
    	        DrawingVisual visual = new DrawingVisual();
    
    	        using (DrawingContext context = visual.RenderOpen())
    	        {
    	            VisualBrush visualBrush = new VisualBrush(target);
    	            context.DrawRectangle(visualBrush, null, new Rect(new Point(), bounds.Size));
    	        }
    
    	        renderTarget.Render(visual);
    	        PngBitmapEncoder bitmapEncoder = new PngBitmapEncoder();
    	        bitmapEncoder.Frames.Add(BitmapFrame.Create(renderTarget));
    	        using (Stream stm = File.Create(fileName))
    	        {
    	            bitmapEncoder.Save(stm);
    	        }
    	    }

    Leave a comment:


  • junkone
    replied
    Originally posted by NinjaTrader_Dave View Post
    Absolutely. Take a look at the documentation for the Share() method below:

    http://ninjatrader.com/support/helpG...-us/?share.htm

    There is an example of sharing a screenshot to Twitter on that page, which should do the trick for you.
    maybe i did not identify my question correctly. is there any programatic feature to take a screenshot of the chart window as part of indicator? I would need this to use the share feature to twitter?

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    Absolutely. Take a look at the documentation for the Share() method below:

    http://ninjatrader.com/support/helpG...-us/?share.htm

    There is an example of sharing a screenshot to Twitter on that page, which should do the trick for you.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by yqksqhhh, Today, 09:12 PM
0 responses
1 view
0 likes
Last Post yqksqhhh  
Started by CriticalMind, 11-29-2015, 12:39 PM
3 responses
1,321 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by novel168, 06-14-2019, 09:20 PM
1 response
6 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by johnnybegoode, Today, 08:00 PM
3 responses
7 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by digibob, Today, 03:00 PM
1 response
6 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X