A Little help coding please???

 

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?

 

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

}

Reason: