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

Screenshot sent via Text Message

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

    Screenshot sent via Text Message

    Am I even close on this? I'm simply trying to take a screenshot when a condition is met and then using the Share function to send via email/Text message.
    Any help would be appreciated.
    Thanks.
    Attached Files

    #2
    Hello woodyfox,

    Thank you for your post.

    It looks like you had copied some of the syntax from the following sample: https://ninjatrader.com/support/foru...re?postcount=7

    However it looks like you didn't copy all of the sample so what you have provided is currently not valid. You would need the remainder of the code from that sample first before doing anything else. You are missing the syntax in OnStateChange which finds the window.

    I believe currently you should be getting an error when running this in the output window as the chart object should be null. Once this is corrected, the code should be able to move to the next step.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse for the quick response. Yes I been trying to piece together other peeps ideas. So the code attached sends a instant screenshot to email. Easy enough to change conditions when this happens, but would it be hard to change the SendMailChart() feature of the code to send via text message instead of regular email?
      Attached Files

      Comment


        #4
        Hello,

        Thank you for your reply.

        For an SMS you can configure that in the options menu as a share type: https://ninjatrader.com/support/help...ghlightsub=sms

        This still uses the same Share syntax, you just need to specify the correct share service name for the SMS share service.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Jesse, I inserted the SMS share service. The indicator does send a text, but with a link to your email. There is no screenshot to text message?
          Any help on the matter would be appreciated.
          Thanks,

          Comment


            #6
            Hello woodyfox,

            Thank you for your reply.

            I rechecked the file you provided and can't find where you are using a share service, I see you are using the smtp service directly. You can use the syntax in the following page to send a message using a defined share service: https://ninjatrader.com/support/help...lightsub=share

            In place of the smtp syntax you used you could use the following line, replacing "Twitter" with the name of your share service and replace the path with the path of your image.

            Code:
            Share("Twitter", "Check out this setup!", @"C:\MyImages\chart03.PNG");
            I look forward to being of further assistance.

            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,
              Sorry I did not provide an updated file with my change. The file is now attached. The code does send a text message to my phone, but the text does not include the image?
              Attached Files

              Comment


                #8
                Hello woodyfox,

                It looks like this is the same file that is using SmtpClient, did you have a different file you meant to upload?

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse, You have me a little confused now. LOL... The file I uploaded in post #7 is sending a text message out, but not attaching the screen image to the text. I simple am trying to find out how to have the image show up in my text message. I changed the "send to" to the SMS share service you suggested in post #4.
                  Any help is appreciated.
                  Thanks.

                  Comment


                    #10
                    Hello woodyfox,

                    Thank you for your reply.

                    Perhaps there is some misunderstanding or something has been mis uploaded here, the code in post 7 does not use the NT8 Share adapter, it uses the C# SmtpClient:

                    Code:
                    MailMessage theMail = new MailMessage(From, To, Subject, Body);
                    System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(stream, "image.png");
                    theMail.Attachments.Add(attachment);
                    
                    SmtpClient smtp = new SmtpClient(Host, Port);
                    smtp.EnableSsl = true;
                    smtp.Credentials = new System.Net.NetworkCredential(Username, Password);
                    string token = Instrument.MasterInstrument.Name + ToDay(Time[0]) + " " + ToTime(Time[0]) + CurrentBar.ToString();
                    
                    Print("Sending Mail!");
                    smtp.SendAsync(theMail, token);
                    This is not the Share() method which NinjaScript uses to send emails/sms from a defined share service, is this the code you are referring to or did you have another script which uses Share()?

                    While I can't say what is happening with the SmtpClient code, we can work with Share():


                    You should only need to use the following line of code once you save the image:

                    Code:
                    Share("Twitter", "Check out this setup!", @"C:\MyImages\chart03.PNG");
                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Ok, So here is a working code to save and image. Where would be the proper place to enter the Share("Text message via email", "Test Image", @"C:\Documents\........");
                      Thanks for all you help!
                      Attached Files

                      Comment


                        #12
                        Hello woodyfox,

                        It looks like you placed the Share syntax before the screenshot so it would try to share this before you take the screenshot. You would need to move the share syntax to where you previously had the SMTP syntax, or where you currently have the following:
                        Code:
                        Print("Screenshot saved to " + Core.Globals.UserDataDir);
                        I look forward to being of further assistance.
                        JesseNinjaTrader Customer Service

                        Comment


                          #13
                          I had this right a dozen or so times. The problem was in the file location. There is a SPACE between NinjaTrader and 8....... "C:\Users\wfoxb\Documents\NinjaTrader 8". Both codes are working fine now. I inserted a save file function in the first Chart to Email.
                          Thanks for all you help.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by jpapa, Today, 07:22 AM
                          1 response
                          4 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by kevinenergy, 02-17-2023, 12:42 PM
                          116 responses
                          2,757 views
                          1 like
                          Last Post kevinenergy  
                          Started by franatas, 12-04-2023, 03:43 AM
                          7 responses
                          106 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by Jltarrau, Today, 05:57 AM
                          3 responses
                          8 views
                          0 likes
                          Last Post Jltarrau  
                          Started by f.saeidi, Today, 05:56 AM
                          2 responses
                          8 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Working...
                          X