Dukascopy
 
 
Wiki JStore Search Login

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.

Orders immediately closed
 Post subject: Orders immediately closed Post rating: 0   New post Posted: Mon 08 Jul, 2013, 13:45 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
I'm opening Orders with the following code: (called from the onBar function, 15min )

orderscount++;
engine.submitOrder("test"+orderscount, instrument,
   IEngine.OrderCommand.SELL, 0.1, 0, 0,
   history.getLastTick(instrument).getAsk() - instrument.getPipValue() * 30,
   history.getLastTick(instrument).getAsk() + instrument.getPipValue() * 30);

//or
orderscount++;
engine.submitOrder("test"+orderscount, instrument,
   IEngine.OrderCommand.BUY, 0.1, 0, 0,
   history.getLastTick(instrument).getBid() - instrument.getPipValue() * 30,
   history.getLastTick(instrument).getBid() + instrument.getPipValue() * 30);

but they seem to get closed immediately when tested from jforex.jnlp strategy tester

Image
Image


Attachments:
Untitled2.png [14.66 KiB]
Downloaded 512 times
Untitled.png [21.05 KiB]
Downloaded 510 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.
 
 Post subject: Re: Orders immediately closed Post rating: 0   New post Posted: Mon 08 Jul, 2013, 13:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Have a closer look at the TP/SL prices that you set.


 
The Best Answer  Post subject: Re: Orders immediately closed Post rating: 0   New post Posted: Mon 08 Jul, 2013, 22:00 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
orderscount++;
engine.submitOrder("test"+orderscount, instrument,
   IEngine.OrderCommand.SELL, 0.1, 0, 0,
   history.getLastTick(instrument).getAsk() + instrument.getPipValue() * 30,
   history.getLastTick(instrument).getAsk() + instrument.getPipValue() * 30);
 
//or
orderscount++;
engine.submitOrder("test"+orderscount, instrument,
   IEngine.OrderCommand.BUY, 0.1, 0, 0,
   history.getLastTick(instrument).getBid() + instrument.getPipValue() * 30,
   history.getLastTick(instrument).getBid() + instrument.getPipValue() * 30);

Method of interest [javadoc]
IOrder submitOrder(String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage, double stopLossPrice, double takeProfitPrice)

Parameters of interest:
IEngine.OrderCommand orderCommand
double stopLossPrice
double takeProfitPrice

General Issue:
Long trades (BUY) close out immediately
Short trades (SELL) close out immediately

Observations:
In Long cases that anticipate a price rise, the Stop Loss is placed above the open bid and well into the potential rise zone (Open + SL)
In Short cases that anticipate a price fall, the Take Profit is placed above the open ask and well into the potential rise zone (Open + TP)

Remedies:
In Long cases that anticipate a price rise, consider placing the Stop Loss towards the area below the entry price (the fall zone)
(a stop loss order for a Long position set above the open appears to have already been hit, price fell below the stop loss, on entry into the position)
In Short cases that anticipate a price fall, consider placing the Take Profit towards the area below the entry price (the fall zone)
(a take profit order for a Short position set above the open appears to have already been hit, price fell to or below the take profit, on entry into the position)


 
 Post subject: Re: Orders immediately closed Post rating: 0   New post Posted: Tue 09 Jul, 2013, 01:12 

User rating: 0
Joined: Sat 08 Jun, 2013, 12:05
Posts: 71
Location: FranceFrance
Thanks for your replies, I'm not sure to understand everything @critical, like anticipation.., (not a pure financial guy :) ) I'm simply using 15mins bars and sending orders

I have in the report a:
test6    0.1   SELL   1.34041   1.34045   -4.0   -0.4   2013-06-18 15:45:00   2013-06-18 15:45:00

double sl =history.getLastTick(instrument).getAsk() - instrument.getPipValue() * 30,
           tp = history.getLastTick(instrument).getAsk() + instrument.getPipValue() * 30;
engine.submitOrder("test"+orderscount, instrument,
            IEngine.OrderCommand.SELL, 0.1, 0, 0, sl, tp);
console.getOut().println(df.format(b.getTime())+"  SELL!!!!!"+orderscount+" "+sl+" "+tp);

gives:
2013-06-18 15:30:00  SELL!!!!!6 1.33745 1.3434499999999998

so the tp and sl shouldn't have caused the close, if they did I would have either won or lost the trade with ~30pips

edit: right, works by setting sl tp, differently if this is a buy or sell, thanks


 

Jump to:  

  © 1998-2026 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com