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

SendMail Function issue in custom indicator

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

    SendMail Function issue in custom indicator

    Hi, I'm developing a custom indicator. I'm facing an unexpected problem in using SendMail() function of Ninja script. I have already learnt that SendMail() function works after real time state has been achieved. I have to send in email a sort of summary report generated from the historical data. I am using the following simple code:

    else if(State == State.Realtime)
    {
    System.Threading.Thread.Sleep(10000);
    SendMail(EmailAddress, mailsubject, mailbody);
    Print("Email has been sent" + DateTime.Now);
    }​

    Emails are received BUT NOT EVERY TIME
    . Sometimes mail is received and other times it is not. There are no log messages when the email is not received. Print message in the Ninja script output window is received always, it is never missed. I can say that around 5/10 emails are received and rest of the 5 are missed.

    Ninja script experts, please point out if I am making any mistake or advice how can I get email reliably. The limitation is that it is not possible for me to put this piece of code in OnBarUpdate because the report about historical data has to be transmitted in any case whether the real time price data which calls OnBarUpdate is coming in or not.

    Many thanks

    #2
    Hello Mubeen Haider,

    Remove the call to Sleep() as this will prevent scripts from functioning.

    With this removed does the issue still occur?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Many thanks for your attention. I removed the call to Sleep() and tried several times. The problem persisted. Then I did another step, I downloaded and installed the most recent version of ninja trader. After re-start of Ninja Trader, I tested again and the problem still persisted. Please advise if you want me to test or try anything else. I am very hopeful that your expertise will find me a way forward.

      Comment


        #4
        Hello Mubeen Haider,

        I'm wondering if there may be an issue with the SMTP server.

        Are you using gmail as the smtp server?
        If not, do you have a gmail account you can test with?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea, I really appreciate your expertise. Your opinion about SMTP server was accurate. After your comments, I paid attention to SMTP server (I was already using Gmail on transmit side but Yahoo on receive side). I observed that there is some intentional or unintentional filtering phenomenon in SMTP server that if email with same subject is transmitted again and again at a high frequency for example, 2 or 3 emails per minute, such emails are filtered or stopped. I was testing like this by reloading Ninja script again and again. Now I have added timestamp in the mail subject so the subject of every email is different and after that I can receive all emails. So far so good, many thanks for your guidance.

          Comment


            #6
            Originally posted by Mubeen Haider View Post
            Hello Chelsea, I really appreciate your expertise. Your opinion about SMTP server was accurate. After your comments, I paid attention to SMTP server (I was already using Gmail on transmit side but Yahoo on receive side). I observed that there is some intentional or unintentional filtering phenomenon in SMTP server that if email with same subject is transmitted again and again at a high frequency for example, 2 or 3 emails per minute, such emails are filtered or stopped. I was testing like this by reloading Ninja script again and again. Now I have added timestamp in the mail subject so the subject of every email is different and after that I can receive all emails. So far so good, many thanks for your guidance.
            This might be my problem! Dear Lord I hope so! You have NO idea what lengths I have gone through to get my messages delivered!
            At the very least I'm now versed in outlook/google workspace, DKIM, domain names, SPF, DMARK, and many other methods of email security and integrity!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Day_Storay1, Today, 09:06 PM
            0 responses
            5 views
            0 likes
            Last Post Day_Storay1  
            Started by Rudmax, 07-02-2024, 05:40 AM
            59 responses
            1,052 views
            1 like
            Last Post QuantVPS  
            Started by tomtom2000, Today, 12:56 PM
            3 responses
            18 views
            0 likes
            Last Post jabowery  
            Started by stoner, 01-16-2020, 08:07 AM
            20 responses
            514 views
            0 likes
            Last Post IanS00
            by IanS00
             
            Started by jmschmidt357, 09-06-2024, 04:51 PM
            4 responses
            51 views
            0 likes
            Last Post jabowery  
            Working...
            X