Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
That's what makes it even stranger because I have the following in place:
protected override void OnBarUpdate()
// Check to make sure there is at least one trade in the collection
if (Performance.RealtimeTrades.Count > 0)
{
// Get the last completed real-time trade (at index 0)
Trade lastTrade = Performance.AllTrades[Performance.AllTrades.Count - 1];
if (lastTrade != null)
Print("The last trade profit is " + lastTrade.ProfitPoints);
}
To add to it, Print works perfectly as my output window currently reads "The last trade's profit is 2.5". Eventually, I want to add an "if' statement so if lastTrade >= 0, it will add a "+" to the string but I can't get it working at all.
Check if you haven't missed any curly brackets in your code:
if (Performance.RealtimeTrades.Count > 0)
{
// Get the last completed real-time trade (at index 0)
Trade lastTrade = Performance.AllTrades[Performance.AllTrades.Count - 1];
I'm worried that I might have an issue with what's below as I have both my target and stop emailing me when filled so I will try using if(lastTrade != null) ---> SendMail() in both parts when I get home.
Thanks, Greg. I really appreciate your help with this.
Dave
P.S. As of now, my brackets are okay. I've checked. And checked again. And again
if (stopLossTokens.Contains(order.Token))
{
// Check order for terminal state
if (order.OrderState == OrderState.Filled)
{
// Print out information about the order
Print(order.ToString());
SendMail("", "[email protected]", Instrument.MasterInstrument.Name + " Cross2050 Stop Filled " + order.AvgFillPrice + ": " + lastTrade.ProfitPoints, "");