NexusFi: Find Your Edge


Home Menu

 





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 5,325 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 13 posts
    2. attach_file 1 attachments




 
Search this Thread

Implementing a delay after first SendMail execution, possible?

  #1 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
Posts: 18 since Mar 2010
Thanks Given: 13
Thanks Received: 1

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([email protected], "[email protected]", "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

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Are there any eval firms that allow you to sink to your …
Traders Hideout
Futures True Range Report
The Elite Circle
 
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


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"[email protected]""Go Long GBP/CHF""Buy GBP/CHF");
      
Log("Buy Alert GBP/CHF"LogLevel.Information);
      
lastEmailSent DateTime.Now;
   }


Reply With Quote
Thanked by:
  #4 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
Posts: 18 since Mar 2010
Thanks Given: 13
Thanks Received: 1


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
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541

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 the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
Posts: 18 since Mar 2010
Thanks Given: 13
Thanks Received: 1

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("[email protected]""[email protected]""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
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541


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("[email protected]""[email protected]""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 the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #8 (permalink)
 raindrop 
USA
 
Experience: Beginner
Platform: NinjaTrader 6.5
Posts: 18 since Mar 2010
Thanks Given: 13
Thanks Received: 1

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
  #9 (permalink)
 Blackburn 
Malchow (Meckl.)
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Trading: Stocks
Posts: 17 since Mar 2011
Thanks Given: 15
Thanks Received: 0

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
Elite Membership required to download: KahlerEmailWMA0811.cs
Reply With Quote
  #10 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541



Blackburn View Post
but something is wrong.

Hi,

You'll need to be more specific.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on August 17, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts