You have to call OrderSelect before calling OrderTicket. Your code should look something like the following.
int ticket = OrderSend(....); // Must save ticket from the order send
if ( OrderSelect (ticket,SELECT_BY_POS,MODE_TRADES) ) {
RecordLongOutcomes();
OrderClose(OrderTicket(),OrderLots(),Bid ,SlipPage,Violet); // We close the order
}

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Ok, I think you can see what I'm trying to do here....
I want to record to the journal when a trade loses....
So I pop this little function in just before the order closes...
RecordLongOutcomes();
OrderClose(OrderTicket(),OrderLots(),Bid ,SlipPage,Violet); // We close the order
return(0);[/PHP]
Trouble is that it's not Printing....
In fact when the tester hit's a stop loss it doesn't care about this code and it just closes....
[PHP]/////////////record outcomes/////////////////
void RecordLongOutcomes()
{
if(Bid<OrderOpenPrice())
{
OrderSelect(OrderTicket(),SELECT_BY_POS,MODE_TRADES);
Print(" Loser Long ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
}
return (0);
}
So How do I get this data to trigger on the close and print to the journal?