• 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

Daily Screenshot via Mail

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

    Daily Screenshot via Mail

    Hi Guys,

    i like to have one Mail with a Screenshot from my favorite Instruments. I tested it on a minute chart with a code like this:

    if (ToTime(Time[0]) >= ToTime(21, 00, 0)
    && ToTime(Time[1]) <= ToTime(21, 00, 0))
    {
    subject = "Handels-Chart | " + Instrument.FullName + " | " + BarsPeriod;
    message = "Handels-Chart | " + Instrument.FullName + " | " + BarsPeriod;
    SendMailChart(ChartControl, subject, message, EmailAddress, EmailAddress, pServer, Port, pSSL, pUsername, pPassword);
    }

    It works fine on a 5 Minute chart for example, but it doesn´t work on a Daily Chart, becaus e the Bar don´t close at 21:00. Could someone give me a tip?

    sorry for my bad english.....

    Pullbacktrader

    #2
    Hello Pullbacktrader,

    You can add logic to ignore the time if the data series is a daily interval.

    For example:
    Code:
    if (BarsPeriod.Id == PeriodType.Day)
    {
    	// execute code
    }
    Below are links to the help guide on BarsPeriod and BarsPeriods.
    BarsPeriod - http://www.ninjatrader.com/support/h...barsperiod.htm
    BarsPeriods - http://www.ninjatrader.com/support/h...arsperiods.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      I´ve put it in my code, in one Day, i see if it works and give you a feedback! Thanks for your fast response!

      Pullbacktrader

      Comment


        #4
        Hi Chelsea,

        thanks for your Help! I put it in a Chart and it sends me an eMail on the next Day, the Marked open.

        Is ist also possible to send a Mail on a fix Time of the Day? 20:00 h for Example?

        Regards,

        Pullbacktrader

        Comment


          #5
          Hello Pullbacktrader,

          To compare the PC current time instead of the bar time to 20:00 use:

          if (ToTime(DateTime.Now) == 200000)
          {
          // execute code
          }

          Just a heads up, if this code is added to OnBarUpdate and a bar does not end at exactly 20:00:00 then this code will not fire.

          You can add this code to OnMarketData() and it would be more likely to fire, however, a tick would need to come in at exactly 20:00:00 to trigger the code.

          You could allow for a full minute by using ToTime(DateTime.Now) > 200000 && ToTime(DateTime.Now) < 200100. This would mean that the code would trigger for every tick received during this minute. A bool might be able to help with that to only allow it to send once during that minute.

          For any of this to work, there must be incoming data.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hi Chelsea,

            i like to use it on a Daily Chart, and i would like to get a Screenshot via eMail every Day at 20:00. How could i put it on OnMarketData()?

            If i put the Indicator on Calculate on bar close = false, it works, but i get more than one Mail. Could you give me a tip how to solve this, so that i get only one mail?

            thanks so much! ;-)
            Last edited by Pullbacktrader; 02-13-2014, 04:12 AM.

            Comment


              #7
              Hello,

              Putting the code in OnMarketData would function pretty much the same as leaving the code in OnBarUpdate and setting the script to CalculateOnBarClose false.

              OnMarketData fires when a tick is received. When CalculateOnBarClose is false OnBarUpdate fires when a tick is received.


              You could allow for a full minute by using ToTime(DateTime.Now) > 200000 && ToTime(DateTime.Now) < 200100. This would mean that the code would trigger for every tick received during this minute. A bool might be able to help with that to only allow it to send once during that minute.

              For example:
              Code:
              In region Variables:
              private bool emailSent = false;
              
              In OnBarUpdate():
              if (ToTime(DateTime.Now) > 200000 && ToTime(DateTime.Now) < 200100 && emailSent == false)
              {
              SendMail();
              emailSent = true;
              }
              else if (ToTime(DateTime.Now) < 200000 || ToTime(DateTime.Now) > 200100)
              {
              emailSent = false;
              }
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                It works, i´m happy to have this Support from you and your Team. Thank you Chelsea!

                Comment


                  #9
                  Hi. I am keen on using the screenshot code as well but I can't seem to get it to work. I think there may be a problem with the way I am writing it( this part especially - SendMailChart(ChartControl, subject, message, EmailAddress, EmailAddress, pServer, Port, pSSL, pUsername, pPassword).

                  For starters, I have noticed that you have included pSSL which is not in the original code from OregonSun. How did you code for this? Secondly, I am trying to send the email via hotmail so this is how I wrote my code:

                  SendMailChart(ChartControl, subj, message, "****@hotmail.com", "****@hotmail.com", "smtp.live.com", 587, "****@hotmail.com", "Password");

                  It seems correct but it's not working. Could you tell me if this is wrong and if yes, where, or could you alternatively give me the credentials you used in the above code - minus the email address and password, of course? Thanks in advance.

                  Comment


                    #10
                    mbesha,

                    SendMailChart() is not support code with NinjaTrader. Only SendMail() function is supported.

                    Additionally, you will need to ensure that the email is setup on the NinjaTrader side under Tools -> Options -> Misc Tab

                    Input the same values on this side as you are setting them in the code.

                    Additionally, you may want to start testing with just SendMail() first so we know that the mailing function is working before moving onto the screenshot mail function.
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      I have already tested with SendMail() and it works without a hitch. I am also using the same parameters. By the way, is it possible to send an attachment via SendMail()?

                      Comment


                        #12
                        It is not possible to send attachments using the SendMail() function.

                        Can you please send me your Trace files so I can investigate this further?

                        Help -> Mail to Platform Support

                        Put ATTN Cal in the subject reference this thread in the Body.
                        Cal H.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Cal. Thanks for your quick response. As I mentioned, I have no problem using SendMail(). I am just keen on learning how I can take and email a screenshot of a chart and I came across this code but I haven't been successful in using it yet. If you know how to use it successfully, please share with me how you did it because I can't seem to find much information available on how to accomplish my objective. Thanks in advance.

                          Comment


                            #14
                            I don't even know there is a SendMailChart() function @@
                            ninZa
                            NinjaTrader Ecosystem Vendor - Ninza

                            Comment


                              #15
                              Originally posted by mbesha View Post
                              Hi Cal. Thanks for your quick response. As I mentioned, I have no problem using SendMail(). I am just keen on learning how I can take and email a screenshot of a chart and I came across this code but I haven't been successful in using it yet. If you know how to use it successfully, please share with me how you did it because I can't seem to find much information available on how to accomplish my objective. Thanks in advance.
                              I used this code, works a charm for sending screen shots through.
                              http://www.ninjatrader.com/support/f...tid=-1&lpage=1

                              The one thing missing from that code is the ability to add ssl details of the server you are sending from.

                              You will have to add these couple of lines after you defnine your smtp client

                              smtp.EnableSsl = true;
                              smtp.Credentials = new System.Net.NetworkCredential(Username, Password);

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by manugarc, Today, 01:15 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post manugarc  
                              Started by JMont1, Today, 11:42 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post JMont1
                              by JMont1
                               
                              Started by Steve L, Yesterday, 10:04 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Steve L
                              by Steve L
                               
                              Started by marianfed, Yesterday, 09:47 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post marianfed  
                              Started by hir04068, Yesterday, 09:29 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post hir04068  
                              Working...
                              X