Hi Huys,

I'm trying to implement lock profit and stop loss exits. I did
searched the group and did my homework and I came up with the
following code:

double lastEntry = getPositionManager().getAvgFillPrice();
        double currentPrice = getMarketBook().getSnapshot().getPrice
();

        double loss = 0;
        if (getPosition() != 0) {
            loss = (getPosition() > 0) ? (lastEntry - currentPrice) :
(currentPrice - lastEntry);
        }
        double gain = -loss;
        if (loss <= -profitLoss || gain >= profitLoss) {
            setPosition(0);
        }

however, in the log file I can still see losses which are worse than -
profitLoss...

Am I doing something wrong here?
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"JBookTrader" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jbooktrader?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to