|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
| ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
|
Edbegood
|
| Post subject: ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
Post rating: 0
|
Posted: Wed 26 Jun, 2013, 14:31
|
|
User rating: 0
Joined: Mon 19 Dec, 2011, 14:21 Posts: 12 Location: SwitzerlandSwitzerland
|
|
My strategy takes multiple positions and merge them with one StopLoss and one TakeProfit for the new merged position.
When I run the strategy in realtime I always have problems after a few trades because the strategy doesn't merge the positions because of errors in takeProfitPrice or StopLossPrice (TAKE PROFIT Invalid price format - please use increments of 0.1 pip.)
I have tried to change this:
private double getRoundedPrice(double price) { BigDecimal bd = new BigDecimal(price); bd = bd.setScale(instrument.getPipScale() + 1, RoundingMode.HALF_UP); return bd.doubleValue(); }
private double getRoundedPips(double pips) { BigDecimal bd = new BigDecimal(pips); bd = bd.setScale(1, RoundingMode.HALF_UP); return bd.doubleValue(); } with this:
private double roundToPippette(double price, Instrument instrument) { return round(price, instrument.getPipScale() + 1); } private double round(double pips, int decimalPlaces) { return (new BigDecimal(pips)).setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP).doubleValue(); }
with no effect. Can you provide me a HELP ?
PS: When I run the strategy in historical tester i don't have any problems or errors ???
Thank you
| Attachments: |
CCI.java [13.58 KiB]
Downloaded 472 times
|
|
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on
this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control
on their content. Anyone accessing this webpage and downloading or otherwise making use of any document,
data or information found on this webpage shall do it on his/her own risks without any recourse against
Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from
the use and/or reliance on any document, data or information found on this webpage.
|
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
Post rating: 0
|
Posted: Wed 26 Jun, 2013, 15:16
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
So where exactly in your strategy you round the take profit price before calling IEngine.submitOrder?
|
|
|
|
|
 |
|
Edbegood
|
| Post subject: Re: ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
Post rating: 0
|
Posted: Wed 26 Jun, 2013, 16:02
|
|
User rating: 0
Joined: Mon 19 Dec, 2011, 14:21 Posts: 12 Location: SwitzerlandSwitzerland
|
|
Sorry but i have no idea because the strategy has been written by the Dukascopy team. I am not a java programmer and just tried to change some coding that i found in the jforex wiki. This strategy must be changed in a way to round the StopLoss and the TakeProfitPrice after the merging process.
Can you find where the problem lies ?
|
|
|
|
|
 |
|
kurak777
|
| Post subject: Re: ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
Post rating: 2
|
Posted: Wed 26 Jun, 2013, 18:40
|
|
User rating: 7
Joined: Fri 13 Jan, 2012, 20:49 Posts: 94 Location: Poland, Warsaw
|
Hello, Change only one line, no. 151, from: IOrder order = engine.submitOrder(getLabel(instrument), instrument, orderCmd, amount, 0, slippage, stopLossPrice, takeProfitPrice); to: IOrder order = engine.submitOrder(getLabel(instrument), instrument, orderCmd, amount, 0, slippage, getRoundedPrice(stopLossPrice), getRoundedPrice(takeProfitPrice)); It should help. Best regards, Kurak
|
|
|
|
|
 |
|
Edbegood
|
| Post subject: Re: ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
Post rating: 0
|
Posted: Thu 27 Jun, 2013, 07:48
|
|
User rating: 0
Joined: Mon 19 Dec, 2011, 14:21 Posts: 12 Location: SwitzerlandSwitzerland
|
|
Hello kurak777. I appreciate your help but the problem remain ! I think that the problem is after the merging process when the strategy delete all existing orders and place a new order with a new stop loss and a new take profit. I have tried many things but none has worked.
Any idea ?
|
|
|
|
|
 |
|
kurak777
|
| Post subject: Re: ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
Post rating: 1
|
Posted: Thu 27 Jun, 2013, 08:24
|
|
User rating: 7
Joined: Fri 13 Jan, 2012, 20:49 Posts: 94 Location: Poland, Warsaw
|
Hi! I would change also lines 230 and 238: 230 change from: mergedOrder.setStopLossPrice(slPrice); to: mergedOrder.setStopLossPrice(getRoundedPrice(slPrice)); and 238 change from: mergedOrder.setTakeProfitPrice(tpPrice); to: mergedOrder.setTakeProfitPrice(getRoundedPrice(tpPrice)); Best regards, Kurak
|
|
|
|
|
 |
|
Edbegood
|
| Post subject: Re: ORDER REJECTED TAKE PROFIT Invalid price format - please use increments of 0.1 pip. |
Post rating: 0
|
Posted: Thu 27 Jun, 2013, 13:30
|
|
User rating: 0
Joined: Mon 19 Dec, 2011, 14:21 Posts: 12 Location: SwitzerlandSwitzerland
|
|
Hello Kurak,
You are a king ! You have solved my problem. Thank you very very much !
|
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|