OK, just one more question. Still "on topic" ...
Can I do this by somehow inserting a Plugin in the JForex
platform environment? How could I do that?
I think I am doomed to writing my own API client, just
for this purpose, but just one more try at doing it
within the JForex platform environment.
Any suggestions / ideas are welcome...
I've got server doing trades in lots of currency symbols,
so I want to "auto track" these trades by switching
the charting so that they can be easily viewed without
manually having to switch them to the correct charts.
Thanks,
HyperScalper
So I have a thread which periodically calls this routine in
order to "fix" the Stop Loss side, using IContext.executeTask(...)
of course.
/*
* When an order is initially placed with a StopLoss, it is not
* possible to set the Stop "side". This task replaces the StopPrice
* but applies the proper Stop "side"
*/
final public class ResetStopPriceSideTask implements Callable<Void> {
IEngine _engine = null;
Instrument _instrument = null;
public ResetStopPriceSideTask(IEngine engineArg, Instrument instrumentArg) {
_engine = engineArg;
_instrument = instrumentArg;
}
public Void call() throws Exception {
try {
List<IOrder> orders = _engine.getOrders();
if (orders!=null) {
for (IOrder order: orders) {
if ( !isMyOrder(order)) continue; // skip
// now this is my order
IOrder.State state = order.getState();
if ( !state.equals(IOrder.State.FILLED)) continue; // not filled
double stopLossPrice = order.getStopLossPrice();
if (stopLossPrice==0) continue; // no stop loss set
OfferSide actualStopLossSide = order.getStopLossSide();
OfferSide desiredStopLossSide = getStopLossSide(order.isLong());
if ( !actualStopLossSide.equals(desiredStopLossSide)) {
// replace it at same price with proper "side"
try {
// fix it
order.setStopLossPrice(stopLossPrice, desiredStopLossSide);
log("Fixed stopLoss OfferSide for order label: "+order.getLabel());
}
catch(Exception ee) {
log("order.setStopLossPrice error "+ee.getMessage());
// nothing
}
}
}
}
}
catch(Exception e) {
e.printStackTrace();
throw e;
}
return null;
}
}