NexusFi: Find Your Edge


Home Menu

 





Stop Loss/Target & SendMail()


Discussion in NinjaTrader

Updated
    1. trending_up 3,338 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
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
76 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
37 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
17 thanks
  #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,461 since Jun 2009
Thanks Given: 33,235
Thanks Received: 101,657


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
  #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,461 since Jun 2009
Thanks Given: 33,235
Thanks Received: 101,657


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

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