Implementing a delay after first SendMail execution, possible? - futures io
futures io



Implementing a delay after first SendMail execution, possible?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Big Mike with 4 posts (2 thanks)
    2. looks_two raindrop with 4 posts (0 thanks)
    3. looks_3 Blackburn with 3 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,240 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 13 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Implementing a delay after first SendMail execution, possible?

(login for full post details)
  #1 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
 
Posts: 18 since Mar 2010
Thanks: 13 given, 1 received

Hi,
I have implmented SendMail in one of the scripts and it works fine but some time it generates too many e-mail messages in a short period of time. I want to limit the number of e-mails that i can get. So i am thinking of a way where after the first email is sent, system would not send an email for next 30 minutes, just like rearm function of 'Alert' command.

I'd appreciate If anyother user of NinjaTrader has any tips about what commands can I use to code such a functionality. Following is my sample script:

{
// Condition set 1
if (EMA(25)[0] > EMA(72)[0])
{
// SendMail(anyone@att.net, "xxx-xxx-xxxx@vtext.com", "Go Long GBP/CHF", "Buy GBP/CHF");
Log("Buy Alert GBP/CHF", LogLevel.Information);
}

Any cues will be helpful.
Thanks.

Started this thread Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(107 thanks from 17 posts)
looks_twoSalao's Journalby Salao
(33 thanks from 8 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(28 thanks from 11 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(14 thanks from 9 posts)
looks_5Maybe a little bit different journalby Malykubo
(9 thanks from 8 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Would You Sell Your System?
73 thanks
The Crude Dude Oil Trading System
44 thanks
Big Mike in Ecuador
41 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
25 thanks
futures io site changelog and issues/problem reporting
24 thanks
 
(login for full post details)
  #3 (permalink)
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received


I don't have NT nor any c# editor available at the moment so I can't check it. Treat this more as a pseudo code (which may require some amendments):

 
Code
                            
//in variables section:
private DateTime lastEmailSent;
 
//OnBarUpdate:
// Condition set 1
if (EMA(25)[0] > EMA(72)[0])
{
   if (
DateTime.Now lastEmailSent.AddMinutes(30))
   {
      
SendMail(anyone@att.net"xxx-xxx-xxxx@vtext.com""Go Long GBP/CHF""Buy GBP/CHF");
      
Log("Buy Alert GBP/CHF"LogLevel.Information);
      
lastEmailSent DateTime.Now;
   }


Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #4 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
 
Posts: 18 since Mar 2010
Thanks: 13 given, 1 received


gregid View Post
I don't have NT nor any c# editor available at the moment so I can't check it. Treat this more as a pseudo code (which may require some amendments):

Thanks for taking your time responding to my message.

I believe Ninja Trader programming instruction set does not recognize the command "lastEmailSent" so I cannot use your solution.

I was thinking of using an integer variable which gets triggered / rearmed 30 minutes after the last 'SendMail' command line is executed. And a 'SendMail' command line is executed only when that integer variable is triggered/rearmed. But I just don't know how to code such instruction. I'd appreciate any help and guidance here.

Raindrop

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 49,980 since Jun 2009
Thanks: 32,450 given, 98,211 received

Raindrop, if you put

 
Code
                            
private DateTime lastEmailSent
in variables like greg said, it should work fine.

Please post your full code if it is still not working.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #6 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
 
Posts: 18 since Mar 2010
Thanks: 13 given, 1 received

Alright, I placed the following line in variables section.

 
Code
                            
private DateTime lastEmailSent
But still I received 3 alerts in 10 minutes of time period.

Following is the rest of the code.

 
Code
                            


      
// Condition set 1
            
if (EMA(25)[0] > EMA(72)[0]
                && (
DateTime.Now lastEmailSent.AddMinutes(30))
                )
               
            {
                
SendMail("anyone@att.net""xxx-xxx-xxxx@vtext.com""Go Long GBP/CHF""Buy GBP/CHF");
                
Log("Buy Alert GBP/CHF"LogLevel.Information);
                
PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\AutoBreakEven.wav");
            } 
Any idea what am i missing here?

Thanks.

Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 49,980 since Jun 2009
Thanks: 32,450 given, 98,211 received


raindrop View Post
Alright, I placed the following line in variables section.

 
Code
                            
private DateTime lastEmailSent
But still I received 3 alerts in 10 minutes of time period.

Following is the rest of the code.

 
Code
                            

      
// Condition set 1
            
if (EMA(25)[0] > EMA(72)[0]
                && (
DateTime.Now lastEmailSent.AddMinutes(30))
                )
               
            {
                
SendMail("anyone@att.net""xxx-xxx-xxxx@vtext.com""Go Long GBP/CHF""Buy GBP/CHF");
                
Log("Buy Alert GBP/CHF"LogLevel.Information);
                
PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\AutoBreakEven.wav");
            } 
Any idea what am i missing here?

Thanks.

I don't see where you updated lastEmailSent when you sent the email. Just add, under Log():

 
Code
                            
lastEmailSent DateTime.Now
Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #8 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
 
Posts: 18 since Mar 2010
Thanks: 13 given, 1 received

I have added the line and now it works perfectly. My thanks to gregid & Big Mike.

You guys are so cool.

Started this thread Reply With Quote
 
(login for full post details)
  #9 (permalink)
 Blackburn 
Malchow (Meckl.)
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Trading: Stocks
 
Posts: 17 since Mar 2011
Thanks: 15 given, 0 received

Hallo Big Mike,

i tested the code in the thread but something is wrong.
I´m sending my *.cs file with the use of control.

where is the error?
Thanks for yor help.

Blackburn from Germany

Attached Files
Register to download File Type: cs KahlerEmailWMA0811.cs (3.8 KB, 7 views)
Reply With Quote
 
(login for full post details)
  #10 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 49,980 since Jun 2009
Thanks: 32,450 given, 98,211 received



Blackburn View Post
but something is wrong.

Hi,

You'll need to be more specific.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #11 (permalink)
 Blackburn 
Malchow (Meckl.)
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Trading: Stocks
 
Posts: 17 since Mar 2011
Thanks: 15 given, 0 received

I can´t receive emails.

I insert:
#region Variables
private DateTime lastEmailSent;
#endregion

and:
protected override void OnBarUpdate()

{
// Condition set 1
if (ToTime(Time[0]) >= 100000 && ToTime(Time[0]) <= 220000
&& WMA(Weighted, 20)[0] > WMA(Weighted, 50)[0]
&& Low[0] > WMA(Weighted, 20)[0]
&& WMA(Weighted, 20)[0] > WMA(Weighted, 20)[4]
&& Close[0] > Swing(5).SwingHigh[0])
{
if (DateTime.Now > lastEmailSent.AddMinutes(30))
{
SendMail("alerts@beerbaum.com", "alerts@beerbaum.com", "Buy LONG position", "Entry @ "+ Close[0] + ".");
lastEmailSent = DateTime.Now;
}
EnterLong(DefaultQuantity, "Long");
}

But I delete the code under "Properties":
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion

Where is the error?
Thanks für your help.

Blackburn

Reply With Quote
 
(login for full post details)
  #12 (permalink)
 MrYou 
NC, USA
 
Experience: None
Platform: None Yet
Trading: Guitar
 
MrYou's Avatar
 
Posts: 403 since Jun 2011
Thanks: 618 given, 196 received

You might try adding a set of parentheses for your first condition:

 
Code
if ((EMA(25)[0] > EMA(72)[0])
                && (DateTime.Now > lastEmailSent.AddMinutes(30))
Just a guess. Not sure if its valid for C#.

Reply With Quote
 
(login for full post details)
  #13 (permalink)
 Blackburn 
Malchow (Meckl.)
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Trading: Stocks
 
Posts: 17 since Mar 2011
Thanks: 15 given, 0 received

thanks for your answer.

how can I put the specific in my case? (The code above)

Blackburn

Reply With Quote
 
(login for full post details)
  #14 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 49,980 since Jun 2009
Thanks: 32,450 given, 98,211 received


Blackburn View Post
I can´t receive emails.

Take out everything except the part that sends the email, do you get it then? If not, your ISP likely blocks port 25 and you'll need to reconfigure NinjaTrader options.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Implementing a delay after first SendMail execution, possible?


Last Updated on August 17, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts