PDA

View Full Version : Performance Instance


CashCache
03-10-2008, 04:32 PM
I am trying to check the loss amount once my stoploss is hit, but each time I check the value of the last trade in my OnOrderUpdate() it shows as a positive value and just so happens to be the value of the last winning trade. Here is what I am doing.


OnOrderUpdate(IOrder order)
{
// after verifying this is the order I think it is…
if(order.OrderState == OrderState.Filled)
{
Trade lastTrade = Performance.AllTrades[0];
tradePL += lastTrade.ProfitCurrency * lastTrade.Quantity;
}
}


This is always a positive number, and like I mentioned, it’s the value of the trade prior to the one I am working with. Also, the docs indicate a Performance.LosingTrades collection, but it looks like there is no such collection.

When the OnOrderUpdate() message fires, I would assume the collection would already know about the trade that just caused the OnOrderUpdate() message. Is this correct?
I am just trying to keep a running total of my winners and lossers - both realtime and historic. I've simplified the code above for clarity - much more is happening after the P/L for the trade is calculated.

Thanks,

-Scott

CashCache
03-10-2008, 05:06 PM
I think I see my problem now. I need to use

Performance.AllTrades.LosingTrades[0] to get the last losser.

Thanks,

-Scott

NinjaTrader_Josh
03-10-2008, 09:47 PM
Glad you figured it out.