It actualy works! my profitLoss parametere was not in the right range...
On Jun 1, 4:34 pm, 140th Member <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
