SendMail() for strategies - NinjaTrader Programming | futures io social day trading
futures io futures trading


SendMail() for strategies
Updated: Views / Replies:6,556 / 34
Created: by dsraider Attachments:4

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you dont need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 4  
 
Thread Tools Search this Thread
 

SendMail() for strategies

  #1 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

SendMail() for strategies

Hi All,

I'm trying to add SendMail() to my strat for when it enters, moves my stop to breakeven and closes. Since I'm using CalculateOnBarClose = false, I can't use the regular SendMail() code as it produces a zillion emails. Does anyone know of a work around? It's the usual easter egg hunt on the Ninja forum and I think I'm currently moving in reverse. Also, if it matters, I'm using a breakeven, a trail and an exit. I'd like to get an email when the first of those is filled.

Thanks,
Dave

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,570 given, 3,982 received


Just add a flag after each email/event:

 
Code
                            
protected override void Initialize() {
private 
bool _enter_mail false;
private 
bool _be_mail false;
private 
bool _close_mail false;
...
}

protected 
override void OnBarUpdate() {
if (! 
_enter_mail  && _orderfilled) {
_enter_mail=true;
SendMail(...
}

if (! 
_be_mail  && _moved_stop_to_breakeven) {
_be_mail=true;
SendMail(.... 

Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following 3 users say Thank You to sam028 for this post:
 
  #4 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

Sam,

I'm off to work now but wanted to thank you for your quick reply. This looks very promising. Question, though. Do I need to insert this code with each condition or can I just post it anywhere under the respective overrides? For example:

 
Code
if (CrossAbove(EMA(20), EMA(50), 1))
            {
                entryOrder = EnterLong(DefaultQuantity, "2050 Cross");
				
				
			if (! _enter_mail  && _orderfilled) {
                        _enter_mail=true;
                        SendMail(...;
	     }
Do I have that right?

Thanks,
Dave

Reply With Quote
 
  #5 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,570 given, 3,982 received

It looks good.
I use in this example a variable _ordefilled which needs to de defined and correctly initialized, but you have the idea I think: send the email only if the order is really filled. Maybe the good place for this is in OnOrderUpdate(), with something like:

 
Code
                            
if entryOrder.OrderState == OrderState.Filled {
  
_enter_mail=true;
  
SendMail(.. 

Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following user says Thank You to sam028 for this post:
 
  #6 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

Okay, now I'm getting confused. I'm one year older today and closer to senility so please take it easy on me. Do I use both or should I just use the code in your last post and then add something to variables and Initialize()?

Reply With Quote
 
  #7 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,570 given, 3,982 received


dsraider View Post
Okay, now I'm getting confused. I'm one year older today and closer to senility so please take it easy on me. Do I use both or should I just use the code in your last post and then add something to variables and Initialize()?

It's up to you, 2 choices:
- send the email when the order is sent, or
- send the email when he order is filled
So not both, unless you want two emails, one went the order is sent, an other one when it's filled (so you'll need another boolean variable).
I think I have an example, I was doing similar stuff but with sending sms, I'll try to put it in this thread later.

And happy birthday

Success requires no deodorant! (Sun Tzu)
Reply With Quote
 
  #8 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

When the order is filled is probably better. If you have an example, I'd greatly appreciate it as I'm getting a little lost on this one. Oh, and thanks for the birthday wishes. As you can probably imagine, my head currently hurts.

Dave

Reply With Quote
 
  #9 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

Update - I'm making progress but am still having issues.

 
Code
private IOrder 	entryOrder1			= null;

if (CrossAbove(EMA(20), EMA(50), 1))
        {
        entryOrder1 = EnterLong(DefaultQuantity, "60 Cross");
	}

if (entryOrder1 != null && entryOrder1.Token == order.Token)
     	{
	if (entryOrder1.OrderState == OrderState.Filled)
        SendMail("", "username@yahoo.com", "ES Long " + Position.AvgPrice, "");
	}
This does email but I get two instead of one and price is listed as 0. Same for exits.

I'm completely lost on how to use SendMail() with targets and stops. Any help would be greatly appreciated.

Thanks,
Dave

Reply With Quote
 
  #10 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,570 given, 3,982 received


Can you attache the .cs file for the strategy you're working on ?
It will much much easier to see what's wrong.

Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following user says Thank You to sam028 for this post:

Reply



futures io > > > > > SendMail() for strategies

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing a delay after first SendMail execution, possible? raindrop NinjaTrader Programming 13 August 17th, 2011 03:55 PM
Stop Loss/Target & SendMail() dsraider NinjaTrader Programming 4 May 30th, 2010 07:15 AM
Communication between strategies zwentz NinjaTrader Programming 4 May 2nd, 2010 11:15 PM
Question about sendmail in strategies fiki NinjaTrader Programming 3 June 24th, 2009 02:25 AM


All times are GMT -4. The time now is 12:21 AM.

Copyright © 2017 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
Page generated 2017-12-10 in 0.12 seconds with 20 queries on phoenix via your IP 54.90.207.75