Yes, I'd like to implement stop loss (and take profit) functionality. so, I guess everyone is dealing with the same issue that if you lose connection to IB your positions are "naked" - I hope that it is not so common to lose this connection - from you experience - is it common?
On Nov 21, 5:23 am, nonlinear5 <[email protected]> wrote: > > Following question regarding market order - how exactly I can fill an > > order and assign an exit condition - for example if stock price go > > under X sell the stock automatically. > > double price = getMarketBook().getSnapshot().getPrice(); > if (price <= 100) { > setPosition(0); > } > > That's all there is to it, really. A better version would be to > compare the current price with the last entry price, and exit when the > difference is larger than a certain threshold. I assume you are trying > to implement a stop loss. -- 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.
