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.

create a class and use it in the strategy
 Post subject: create a class and use it in the strategy Post rating: 0   New post Posted: Wed 07 Nov, 2012, 23:05 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Dear Support,

I am trying to create a class that is similar to a C/C++ struct. I would like to use this class in my strategy, but I don`t know how to do this. My Java knowledge is limited, so probably I miss some concept, but maybe the strategy class implementation doesn`t allow such things...

This is the class I want to use in the strategy:
package dukascopy.strategies.indicators;
public class myOrder
{
    public String label;
    public double maxLoss;
    public int mergeCount;
}


I tried to use this class in my strategy like this:
public class myStrategy extends myOrder implements IStrategy

But there is an error saying: myOrder cannot be resolved to a type

For the above example I used the strategy editor of the platform. If I use Eclipse, and configure it as described in the wiki (use the JForex SDK, etc...), I can however use and compile that same strategy, and can run it with the TesterMainGUIMode class.

The only difference I can see is the directory layout between the platform and Eclipse. In Eclipse I can see the files (myStrategy.java and myOrder.java) under /src/dukascopy.startegies.indicators/. In the platform both files are in the <User>/Documents/JForex/Strategies/ directory.

As I mentioned, my Java knowledge is limited, so I might miss some basic concept, but please help me out here.


 
The Best Answer  Post subject: Re: create a class and use it in the strategy Post rating: 2   New post Posted: Thu 08 Nov, 2012, 00:07 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi Tcsabina:

Don't know the objective of that class... but you can try something like:

public class myStrategy implements IStrategy {
//strategy code here

myOrder order = new myOrder; //or new myOrder() if you have done a constructor
// Also if you want to use more than one object myOrder you can create a array, list, set, etc

class myOrder {
// your class code here
}

}


Or you can import your class on the strategy you you use a compiled external file.

I hope that helps

Best regards

JL


 
 Post subject: Re: create a class and use it in the strategy Post rating: 0   New post Posted: Thu 08 Nov, 2012, 10:17 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Hi Jlongo,

This is it! thanks...

The purpose of the class is to store some extra information for every order.


 

Jump to:  

  © 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