NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 10-28-2007, 06:27 PM   #1
ninjablanks
Member
 
Join Date: Aug 2007
Posts: 64
Thanks: 0
Thanked 0 times in 0 posts
Default Need email alert to give name of instrument

I run 2 different strategies on about 10 instruments in four different time frames. When I get an email I have to manually scan the instruments to see which one triggered the alert. Is there an easy way to get the strategy to tell me which instrument triggered the alert? Thanks!
ninjablanks is offline  
Reply With Quote
Old 10-28-2007, 06:40 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

In your strategy you could use SendMail().

http://www.ninjatrader-support.com/H...SendMail1.html
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-28-2007, 06:47 PM   #3
ninjablanks
Member
 
Join Date: Aug 2007
Posts: 64
Thanks: 0
Thanked 0 times in 0 posts
Default Using sendmail now

That is what I am using now to send the email but the message states "Long startegy triggered" I would like it to say long strategy triggered on USDJPY in 30 min time frame for example. Is there a way to get NT to "get the name of the instrument and automatically out it in the email. I am not aware of a way to get sendmail to do this. Thanks!
ninjablanks is offline  
Reply With Quote
Old 10-28-2007, 06:55 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Code:
SendMail("support@ninjatrader.com", "customer@winners.com", "Trade Alert", "Long strategy triggered on " + Instrument.MasterInstrument.Name + " in " + Bars.Period.Value + "-" + Bars.Period.Id + " time frame.");
The body of your email would end up as something like this:
"Long strategy triggered on ER2 in 1-Minute time frame."
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-28-2007, 08:08 PM   #5
ninjablanks
Member
 
Join Date: Aug 2007
Posts: 64
Thanks: 0
Thanked 0 times in 0 posts
Default Thanks

Thanks for your help!
ninjablanks is offline  
Reply With Quote
Old 10-28-2007, 08:34 PM   #6
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Default

The NinjaTrader documentation people may already have done this, but if not, I'd like to suggest this as a good example to add to the Help under SendMail.

It would be nice to see this example of Josh's there, in addition to the somewhat less complex example that's already there.

Also, I know its a matter of personal preference, but I like this alternate, but equivalent format that could be added as well:

Code:
SendMail("support@ninjatrader.com", "customer@winners.com", "Trade Alert", String.Format("Long strategy triggered on {0} in {1}-{2} time frame", Instrument.MasterInstrument.Name, Bars.Period.Value, Bars.Period.Id ));
Adding little nuances like this could help people who are trying to get up to speed on C#, if they haven't yet read a manual on it.

When I first started with NinjaScript, some 8 months ago, I was somewhat lost on all the C# and .net ideosyncracies for a while, and it took me maybe a month to run across this one (String.Format instead of Variable.ToString() which really got tiresome after a while.) When I say I was a little lost, this is in spite of many years of programming in various other languages; I cannot imagine what it must be like for someone who has little or no experience when they're trying to pick up all these useful things that can be done in C#, but I suspect that little things like this might help. I think that adding more verbose and well-commented examples to the Help documentation would probably be a great assistance to any novice C# or NinjaScript programmer. I will try to add additional items to the forum to help on this, too, as they occur to me.
KBJ is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Instrument Alert System Rollins Suggestions And Feedback 4 09-23-2007 01:22 PM
Alert() AO76 Strategy Development 5 05-27-2007 09:21 AM
Alert on cross over/under scjohn Market Analyzer 5 05-25-2007 07:21 AM
IB Give Up customers oddball Connecting 10 04-18-2007 06:07 PM
Some Session end times give black white page... nightowl Charting 4 03-07-2007 02:02 AM


All times are GMT -6. The time now is 03:47 AM.