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.
|