NexusFi: Find Your Edge


Home Menu

 





Stop Loss/Target & SendMail()


Discussion in NinjaTrader

Updated
    1. trending_up 3,329 views
    2. thumb_up 0 thanks given
    3. group 0 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
 

Stop Loss/Target & SendMail()

 
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

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("", [email protected], 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 NexusFi?
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Better Renko Gaps
The Elite Circle
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
27 thanks
GFIs1 1 DAX trade per day journal
18 thanks
The Program
18 thanks
 
 
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,397 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537


Why not use the existing thread that you already created?



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
 
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

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

 
 
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,397 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537


dsraider View Post
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

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

 



Last Updated on May 30, 2010


© 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