NexusFi: Find Your Edge


Home Menu

 





Stop Loss/Target & SendMail()


Discussion in NinjaTrader

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




Closed Thread
 
Search this Thread

Stop Loss/Target & SendMail()

  #1 (permalink)
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?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Quantum physics & Trading dynamics
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
  #3 (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,469 since Jun 2009
Thanks Given: 33,247
Thanks Received: 101,669


Why not use the existing thread that you already created?



Mike



Join the free Markets Chat beta: one platform, all the trade rooms!

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
  #4 (permalink)
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

  #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,469 since Jun 2009
Thanks Given: 33,247
Thanks Received: 101,669


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



Join the free Markets Chat beta: one platform, all the trade rooms!

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

Closed Thread



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