Dukascopy
 
 
Wiki JStore Search Login

Closing order problem during the contest
 Post subject: Closing order problem during the contest Post rating: 0   New post Posted: Mon 07 Jan, 2013, 15:08 
User avatar

User rating: 0
Joined: Fri 30 Nov, 2012, 15:12
Posts: 2
Location: France, Dijon
Someone can tell me why my orders don't close in the strategy contest whereas i ran and tested my strategy or several days without problems.
Why my strategy don't close orders when i upload it for the contest ? I don't understand !!!!

Thank you.

I uploaded the file.
Here is an extract of a critical part of my code

if (cciq>100 && ccih>100 && ccic>100 && engine.getOrder("abuy") == null)
{engine.submitOrder("abuy", instrument, OrderCommand.BUY, 100);
w=300;}

if (cciq<-100 && ccih<-100 && ccic<-100 && engine.getOrder("asell") == null)
{engine.submitOrder("asell", instrument, OrderCommand.SELL, 100);
w=400;}

if(engine.getOrder("abuy") != null && ccic<-100)
{engine.getOrder("abuy").close();
engine.getOrder("abuy").waitForUpdate(IOrder.State.CLOSED);
}

if(engine.getOrder("asell") != null && ccic>100)
{engine.getOrder("asell").close();
engine.getOrder("asell").waitForUpdate(IOrder.State.CLOSED);
}


Attachments:
dragondeuxmilletreize.java [8.83 KiB]
Downloaded 376 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: Closing order problem during the contest Post rating: 0   New post Posted: Tue 08 Jan, 2013, 17:55 
User avatar

User rating: 3
Joined: Mon 05 Mar, 2012, 11:15
Posts: 24
Location: Indonesia, Jakarta
   
for (IndDataAndFeed indDataAndFeed : calculatableIndicators) {
       double value = indDataAndFeed.getCurrentValue();
       i = i + 1;

       if (i == 1) {
      macdd = value;
       }
       if (i == 2) {
      rsim = value;
       }
       if (i == 3) {
      rsih = value;
       }
       if (i == 4) {
      cciq = value;
      print("cci 15 minutes =%s", cciq);
       }
       if (i == 5) {
      ccih = value;
      print("cci 1 heure =%s", ccih);
       }
       if (i == 6) {
      ccic = value;
      print("cci 5 minutes =%s", ccic);
       }

       if (cciq > 100 && ccih > 100 && ccic > 100
          && engine.getOrder("abuy") == null) {
      engine.submitOrder("abuy", instrument, OrderCommand.BUY, 100);
      w = 300;
       }

       if (cciq < -100 && ccih < -100 && ccic < -100
          && engine.getOrder("asell") == null) {
      engine.submitOrder("asell", instrument, OrderCommand.SELL, 100);
      w = 400;
       }

       if (engine.getOrder("abuy") != null && ccic < -100) {
      engine.getOrder("abuy").close();
      engine.getOrder("abuy").waitForUpdate(IOrder.State.CLOSED);
       }

       if (engine.getOrder("asell") != null && ccic > 100) {
      engine.getOrder("asell").close();
      engine.getOrder("asell").waitForUpdate(IOrder.State.CLOSED);
       }

   }


I see your coding is quite not right.
1. you have engine.xxx() inside loop block, It should be outside.
2. you need to verify if there is opened positition BEFORE submitting your order.
Ie: If (ccic < -100) you want close long position but you already opened short position.
From your code it's look like there is possibilities to submit multiple order --problematic--.
3. use unique label is better than "abuy" or "asell"

It works on demo or backtesting because there's no constrain on a number of opened position.
On contest you can only have one opened position.


 

Jump to:  

cron
  © 1998-2025 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