Trading Articles
Article Categories
Article Tools
Stop Loss/Target & SendMail()
Updated May 30, 2010
trending_up
2,829 views
thumb_up
0 thanks given
group
0 followers
forum
4 posts
attach_file
0 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)
Stop Loss/Target & SendMail()
(login for full post details)
#1 (permalink )
New York, NY
Posts: 142 since Dec 2009
Thanks: 41 given,
87
received
Hi All,
I'm trying to get my strat to email me when my stop loss or target gets filled but am not having any luck. I was hoping someone could take a look at my code and tell me what I'm missing. I'm sure it's something small. Since I'm assuming the code is pretty much the same for both, here's what I have for stop loss:
Variables
private bool stopSent = false;
private ArrayList stopLossTokens = new ArrayList();
protected override void OnBarUpdate() <---using this for breakeven /trail
SetStopLoss("Name", CalculationMode.Ticks, 12, false);
protected override void OnOrderUpdate(IOrder order)
if(order.OrderState == OrderState.PendingSubmit)
{
if(order.name == "Name")
stopLossTokens.Add(order.Token);
}
if(stopLossTokens.Contains(order.Token))
{
if(order.OrderState == OrderState.Filled && stopSent == false)
{
SendMail("", username@yahoo.com , Instrument.MasterInstrument.Name + " Name Stop Filled " + order.AvgFillPrice + ": " + lastProfit, "");
stopSent = true;
stopLossTokens.Remove(order.Token);
}
}
Anyone? Bueller?
Thanks,
Dave
P.S. As an alternative, if anyone has a working snippet they'd be willing to share, I'd be extremely grateful.
Can you help answer these questions from other members on futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#3 (permalink )
Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Posts: 49,785 since Jun 2009
Thanks: 32,314 given,
97,581
received
Why not use the existing thread that you already created?
Mike
(login for full post details)
#4 (permalink )
New York, NY
Posts: 142 since Dec 2009
Thanks: 41 given,
87
received
Hey Mike,
Sorry if I caused a problem. The other thread I started was probably a little overcomplicated in hindsight so I thought I'd break it down into smaller parts. Want me to delete this one (though I'm not sure how)?
Thanks,
Dave
(login for full post details)
#5 (permalink )
Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Posts: 49,785 since Jun 2009
Thanks: 32,314 given,
97,581
received
dsraider
Hey Mike,
Sorry if I caused a problem. The other thread I started was probably a little overcomplicated in hindsight so I thought I'd break it down into smaller parts. Want me to delete this one (though I'm not sure how)?
Thanks,
Dave
I will close this thread.
It seems to me it is the same problem as before so should be on the same thread.
You should just post an update to the other thread with whatever new info and ask for more help.
Mike
Last Updated on May 30, 2010
Right now
Ongoing
Right now
March
Register to Attend
Elite only
Coming soon
April