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.

PROBLEMS WITH MERGING
 Post subject: PROBLEMS WITH MERGING Post rating: 0   New post Posted: Wed 01 May, 2013, 12:29 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
Hi, A wanted to build a loop to look for several orders on the same instrument and merge them. I tried to use the method mergeOrders

IOrder mergeOrders(String label,
                   Collection<IOrder> orders)
                   throws JFException


but I get the following error:

Quote:
no suitable method found for mergeOrders(java.lang.String,java.util.Collection<com.dukascopy.api.IOrder>)
method com.dukascopy.api.IEngine.mergeOrders(java.lang.String,com.dukascopy.api.IOrder...) is not applicable
(argument type java.util.Collection<com.dukascopy.api.IOrder> does not conform to vararg element type com.dukascopy.api.IOrder)
method com.dukascopy.api.IEngine.mergeOrders(com.dukascopy.api.IOrder...) is not applicable
(argument type java.lang.String does not conform to vararg element type com.dukascopy.api.IOrder)


I attach the code:

public void lookForMerge(IOrder orden) throws JFException
{
  Collection<IOrder> listaMerge = new ArrayList<IOrder>();
       int masOrdenes=0;
       for (IOrder order : engine.getOrders(par))
       {
          if (order.getState()==IOrder.State.FILLED)
           {
               if (!order.equals(orden))
               {
                  order.setStopLossPrice(0);
                  masOrdenes=1;   // there are more orders than the first one...
               }
           }
       }
       if (masOrdenes==1)
       {
           String label = getLabel(orden.getInstrument());
           engine.mergeOrders(label, listaMerge) throws JFException;
       }

Thanks in advance,

Carlos


 
 Post subject: Re: PROBLEMS WITH MERGING Post rating: 0   New post Posted: Thu 02 May, 2013, 07:30 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
remove throws JFException in line 19. For merge examples see:
https://www.dukascopy.com/wiki/#Merge_Positions
In order to avoid such compile-time errors, consider using some IDE, which would automatically advice possible fixes, see:
https://www.dukascopy.com/wiki/#Use_in_Eclipse


 
 Post subject: Re: PROBLEMS WITH MERGING Post rating: 0   New post Posted: Thu 02 May, 2013, 22:21 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
I use NetBeans. I tried before without throws JFException and it didn't work.

Before writing you I also studied the jforex wiki pages about merge orders.

The error says that this method with a collection is not supported. The examples showed use a a different method (Label, order, order, order,...) instead of (label, orderlist)

Thanks


 
 Post subject: Re: PROBLEMS WITH MERGING Post rating: 0   New post Posted: Fri 03 May, 2013, 07:16 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
carlosfx wrote:
I tried before without throws JFException and it didn't work.
What messages did you get then? Please provide a full example strategy which replicates the problem.


 
 Post subject: Re: PROBLEMS WITH MERGING Post rating: 0   New post Posted: Fri 03 May, 2013, 16:39 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
public void rePutStop(IOrder orden) throws JFException // Coloca stop a riesgo=risk (invocado si quitan stop)
{
Collection<IOrder> listaMerge = new ArrayList<IOrder>();
int masOrdenes=0;
for (IOrder order : engine.getOrders(par))
{

if (order.getState()==IOrder.State.FILLED)
{
if (!order.equals(orden))
{
order.setStopLossPrice(0);
masOrdenes=1;

}

}

}
if (masOrdenes==1)
{
String label = getLabel(orden.getInstrument());
engine.mergeOrders(label, listaMerge);
}


// COLOCA EL STOP PARA ESE PAR A RIESGO=RISK
getValue(par);
double distanciaStop=risk*par.getPipValue()/(carga*pipvalue);
if (orden.isLong())
{
// print ("RECOLOCO STOP A RIESGO MÁXIMO DE:"+risk);
orden.setStopLossPrice(roundPip(entry-distanciaStop));
}

else
{
orden.setStopLossPrice(roundPip(entry+distanciaStop));
}
}


 

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