Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 35

Thread: how to code a work around for a missing class

  1. #1
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default how to code a work around for a missing class

    I use a Swiss company called Dukascopy to trade currency pairs using a strategy written in java

    I have access to a strategy written in 2010 which includes the following import line

    'import com.dukascopy api.Properties'

    This class does not exist now in the dukascopy API - nor can Dukascopy support assist me with my question

    The strategy loads up the property file like such:-

    'properties.put("indicator.macd.gemExitSignal", "true")'

    All the put commands are of the form put(string, string)

    Further down the code we have the following line of code:-

    'if(Strategy.properties.containsKey(instrument.nam e() + ".indicator.macd.gemExitsignal")) gemExitSignal = Strategies.properties.getProperty(instrument.name( ) + ".indicator.macd.gemExitSignal", false);'

    In other words we have get commands of the form (string, boolean), (string, double) and (string, int)

    All get commands do not compile on the Dukascopy platform because of the missing import

    Please advise how I may work around this problem

    p.s. I am not that fluent in java programming
    Last edited by BobM; March 5th, 2021 at 07:22 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    Can you give some background about the "Properties"?
    What values are saved in the "Properties"?
    Can all the code that uses the "Properties" be changed to use a new properties class?
    Or leaving the current code as it currently is, write a replacement class for the com.dukascopy.api.Properties class.
    If you have a full replacement for that class, can it be used in your system?

    Is this the same problem: https://coderanch.com/t/739548/java/...ty-GetProperty
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    background:-
    private void loadProperties() throws Exception {
           try {
                  console.getOut().println("Loading properties");
                  //     
                  //Populating the properties file
                  properties.clear();            
                  properties.put("instrument.EURCAD","macd");                             
                  properties.put("instrument.EURCHF","macd");
                  properties.put("instrument.EURGBP","macd");
                  properties.put("instrument.EURJPY","macd");
                  properties.put("instrument.EURUSD","macd");            
                  properties.put("instrument.GBPCHF","macd");
                  properties.put("instrument.GBPUSD","macd");            
                  properties.put("instrument.NZDCHF","macd");            
                  properties.put("instrument.USDCHF","macd");            
                  // Default strategy configuration
                  properties.put("strategy.gebAmount","0.01");
                  properties.put("strategy.gebMaxOrders","1");
                  properties.put("strategy.gebRatGoal","60");
                  properties.put("strategy.gebRatStop","150");
                  properties.put("strategy.gebRatTrailing","0");
                  properties.put("strategy.gebOrderWithLimit","true");
                  properties.put("strategy.gebOrderToRun","false");
                  properties.put("strategy.gebReEnter","true");
                  // Default signaler and macd configuration
                  properties.put("signaler.gesPivotPart","3");
                  properties.put("signaler.gesEnterAtPR","true");
                  properties.put("signaler.gesSupRes","false");
                  properties.put("signaler.gesGoWithMainTrend","false");
                  properties.put("signaler.gesCountPerBreak","0");
                  properties.put("signaler.gesPlayInRange","false");
                  properties.put("signaler.macd.gemFast","12");
                  properties.put("signaler.macd.gemSlow","26");
                  properties.put("signaler.macd.gemSignal","9");
                  properties.put("signaler.macd.gemNumPer","5");
                  properties.put("signaler.macd.gemDivReg","false");
                  properties.put("signaler.macd.gemExitSignal","true");
                  properties.put("signaler.macd.gemExitWithSAR","false");
                  properties.put("signaler.macd.gemContinue","true");
                  //
                  properties.put("USDCHF.signaler.gesRatGoal","100");
                  properties.put("USDCHF.signaler.gesRatStop","100");
                  //
                  properties.put("EURCHF.signaler.gesRatGoal","60");
                  properties.put("EURCHF.signaler.gesRatStop","150");
                  //            
                  properties.put("EURUSD.signaler.gesRatGoal","50");
                  properties.put("EURUSD.signaler.gesRatStop","200");
                  properties.put("EURUSD.signaler.gesPlayInRange","true");
                  //
                  properties.put("EURJPY.signaler.gesPlayInRange","true");
                  //
                  properties.put("USDJPY.signaler.gesRatGoal","60");
                  properties.put("USDJPY.signaler.gesRatStop","150");
                  //
                  properties.put("EURGBP.signaler.gesRatGoal","60");
                  properties.put("EURGBP.signaler.gesRatStop","100");
                  //            
                  properties.put("GBPCHF.signaler.gesPlayInRange","true");
                  //
                  properties.put("NZDCHF.signaler.gesRatGoal","60");  
                  properties.put("NZDCHF.signaler.gesRatStop","150"); 
                  properties.put("NZDCHF.signaler.gesPlayInRange","true");
                  //
                  properties.put("EURCAD.signaler.gesPlayInRange","true");            
                  //
             } catch (Exception e)  {
                    console.getOut().println("NO properties file found");
                    throw e;
             }
       }
    ************************************************** *********
    then in a custom strategy_base class
        public void initialize() {
            try {
                logger.info("Initializing strategy <"+mStgName+"> for <"+instrument.name()+">");
     
                // static properties
                gebAmount           = BM_mod10.properties.getProperty("strategy.gebAmount", 0.01);
                gebMaxOrders        = BM_mod10.properties.getProperty("strategy.gebMaxOrders", 1);                
                gebRatGoal          = BM_mod10.properties.getProperty("strategy.gebRatGoal", 60);
                gebRatStop          = BM_mod10.properties.getProperty("strategy.gebRatStop", 100);
                gebRatTrailing      = BM_mod10.properties.getProperty("strategy.gebRatTrailing", 0);
                gebOrderWithLimit   = BM_mod10.properties.getProperty("strategy.gebOrderWithLimit", true);
                gebOrderToRun       = BM_mod10.properties.getProperty("strategy.gebOrderToRun", false);
                gebReEnter          = BM_mod10.properties.getProperty("strategy.gebReEnter", true);
    ************************************************** ***********************************
    then in a custom strategy_signaler class
        public void initialize() {
            try {
                //Log("Initializing signaler <"+SignalerName+"> for <"+instrument.name()+">");
                //        
                gesPivotPart        = BM_mod10.properties.getProperty("signaler.gesPivotPart", 3);
                gesEnterAtPR        = BM_mod10.properties.getProperty("signaler.gesEnterAtPR", false);
                gesSupRes           = BM_mod10.properties.getProperty("signaler.gesSupRes",true);
                gesGoWithMainTrend  = BM_mod10.properties.getProperty("signaler.gesGoWithMainTrend",false);
                gesCountPerBreak    = BM_mod10.properties.getProperty("signaler.gesCountPerBreak",0);
                gesTrend            = BM_mod10.properties.getProperty("signaler.gesTrend",25);
                gesPlayInRange      = BM_mod10.properties.getProperty("signaler.gesPlayInRange",true);
                //
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesCantidad"))        gesCantidad      = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesCantidad", -1.0);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesPivotPart"))       gesPivotPart     = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesPivotPart", 3);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesEnterAtPR"))       gesEnterAtPR     = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesEnterAtPR", false);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesSupRes"))          gesSupRes        = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesSupRes",true);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesGoWithMainTrend")) gesGoWithMainTrend = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesGoWithMainTrend",false);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesCountPerBreak"))   gesCountPerBreak = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesCountPerBreak",0);        
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesRatTrailing"))     gesRatTrailing   = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesRatTrailing",0);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesRatGoal"))         gesRatGoal       = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesRatGoal", 100);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesRatStop"))         gesRatStop       = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesRatStop", 100);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesTrend"))           gesTrend         = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesTrend",25);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.gesPlayInRange"))     gesPlayInRange   = BM_mod10.properties.getProperty(instrument.name()+".signaler.gesPlayInRange",true);
                //
    ************************************************** ***************
    then in a custom strategy_signaler-macd class
            public Stg_Signaler_MACD (IContext cont) {
                super(cont);
                //
                SignalerName     = "MACD";
                //
                gemFast        = BM_mod10.properties.getProperty("signaler.macd.gemFast", 12);
                gemSlow        = BM_mod10.properties.getProperty("signaler.macd.gemSlow",26);
                gemSignal        = BM_mod10.properties.getProperty("signaler.macd.gemSignal",9);
                gemNumPer        = BM_mod10.properties.getProperty("signaler.macd.gemNumPer",5);
                gemExitSignal    = BM_mod10.properties.getProperty("signaler.macd.gemExitSignal",false);
                gemExitWithSAR    = BM_mod10.properties.getProperty("signaler.macd.gemExitWithSAR",false);        
                gemContinue    = BM_mod10.properties.getProperty("signaler.macd.gemContinue",true);
            }
     
            public void initialize() {
                logger.info("Initializing signaler <"+SignalerName+"> for <"+instrument.name()+">");
                //
                super.initialize();
                //
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.macd.gemFast"))        gemFast        = BM_mod10.properties.getProperty(instrument.name()+".signaler.macd.gemFast", 12);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.macd.gemSlow"))        gemSlow        = BM_mod10.properties.getProperty(instrument.name()+".signaler.macd.gemSlow",26);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.macd.gemSignal"))      gemSignal      = BM_mod10.properties.getProperty(instrument.name()+".signaler.macd.gemSignal",9);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.macd.gemNumPer"))      gemNumPer      = BM_mod10.properties.getProperty(instrument.name()+".signaler.macd.gemNumPer",5);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.macd.gemExitSignal"))  gemExitSignal  = BM_mod10.properties.getProperty(instrument.name()+".signaler.macd.gemExitSignal",false);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.macd.gemExitWithSAR")) gemExitWithSAR = BM_mod10.properties.getProperty(instrument.name()+".signaler.macd.gemExitWithSAR",false);
                if (BM_mod10.properties.containsKey(instrument.name()+".signaler.macd.gemContinue"))    gemContinue    = BM_mod10.properties.getProperty(instrument.name()+".signaler.macd.gemContinue",true);
                //
    ************************************************** *************************
    I believe I need to create a new custom properties class

    and yes - same problem

    Bob M
    Last edited by BobM; March 6th, 2021 at 02:37 PM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    Can you provide a new version of the com.dukascopy.api.Properties class?
    One that is a complete replacement for the missing class?

    I need to create a new properties helper class
    Why do you say "helper"? Why not a new version of the class?


    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    com.dukascopy.api.Properties class existed in Jan 2010 but does NOT exist now

    I have asked Dukascopy.support for details of this class but they could not provide any

    Bpb M

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    If You can list all the places in your code that uses that class, then you could write your own version of the class. If it is like the Properties class in Java SE then it is mostly a Hashmap in a wrapper. There shouldn't be any magical processing of the data. It is just a place to store and retrieve data.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    I have listed all the places that use the get.property command above

    my understanding is that I need code to accomodate getProperty(string, int) getProperty(string, double) and getProperty(string, boolean)
    Last edited by BobM; March 6th, 2021 at 03:46 PM.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    You will need the code for both put... and get... methods and the containsKey method


    You should post the declarations for the variables that receive values from the get... methods.
    I suspect their data type will match the data type of the second arg to the get... methods.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    yes - data types match

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    So everything external about the class is known and you should be able to write your own version of the class.
    Is there an initialization file that the class reads/loads the initial settings from? Somewhere in your code there could be a call to the Properties class to load from that ini file.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    OK
        public void initialize() {
            try {
                logger.info("Initializing strategy <"+mStgName+"> for <"+instrument.name()+">");
     
                // static properties
                gebAmount           = BM_mod10.properties.getProperty("strategy.gebAmount", 0.01);
                gebMaxOrders        = BM_mod10.properties.getProperty("strategy.gebMaxOrders", 1);                
                gebRatGoal          = BM_mod10.properties.getProperty("strategy.gebRatGoal", 60);
                gebRatStop          = BM_mod10.properties.getProperty("strategy.gebRatStop", 100);
                gebRatTrailing      = BM_mod10.properties.getProperty("strategy.gebRatTrailing", 0);
                gebOrderWithLimit   = BM_mod10.properties.getProperty("strategy.gebOrderWithLimit", true);
                gebOrderToRun       = BM_mod10.properties.getProperty("strategy.gebOrderToRun", false);
                gebReEnter          = BM_mod10.properties.getProperty("strategy.gebReEnter", true);

    now replaced by

        public void initialize() {
            try {
                logger.info("Initializing strategy <"+mStgName+"> for <"+instrument.name()+">");
     
                // static properties
                gebAmount           = Double.parseDouble(BM_mod10.properties.getProperty("strategy.gebAmount"));
                gebMaxOrders        = Integer.parseInt(BM_mod10.properties.getProperty("strategy.gebMaxOrders"));                
                gebRatGoal          = Integer.parseInt(BM_mod10.properties.getProperty("strategy.gebRatGoal"));
                gebRatStop          = Integer.parseInt(BM_mod10.properties.getProperty("strategy.gebRatStop"));
                gebRatTrailing      = Integer.parseInt(BM_mod10.properties.getProperty("strategy.gebRatTrailing"));
                gebOrderWithLimit   = Boolean.parseBoolean(BM_mod10.properties.getProperty("strategy.gebOrderWithLimit"));
                gebOrderToRun       = Boolean.parseBoolean(BM_mod10.properties.getProperty("strategy.gebOrderToRun"));
                gebReEnter          = Boolean.parseBoolean(BM_mod10.properties.getProperty("strategy.gebReEnter"));

    and both put and get methods compile OK which just leaves the containsKey method to change

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    I would not change the source code. Leave it like it was. Write a new Properties class to replace the missing one.

    method to change
    I would not change the code that uses a method. I would write in a new class with the method so it worked as expected.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    That's where I struggle with my lack of coding knowledge

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    How did you get in the position of having to make changes to a java program?

    To code a replacement class, start by defining a class in the package (from the import statement):
    com.dukascopy.api.Properties
    Declare skeletons for the put and get methods and the containsKey method.

    Compile the skeleton class. Fix any errors and continue until it compiles without errors. Post the code here with any error messages you need help with.

    Now how do you add your new class to the dukascopy environment so you can see if your new class will allow a successful compile for the programs that use it?

    When the code compiles without errors, then work on putting real code inside the methods.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    How did you get in the position of having to make changes to a java program?

    I became interested in trading automatically on the Dukascopy JForex platform

    I looked at other strategies and slowly learnt how to alter them for my own requirements

    I don't understand why you say:
    "To code a replacement class, start by defining a class in the package (from the import statement):
    com.dukascopy.api.Properties"

    Only Dukascopy has control over their API contents ?

    --- Update ---

    code for populating the properties files - see above

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    Only Dukascopy has control over their API contents ?
    What classes in what packages can you include in your code? Are there any restrictions?

    Can you change the import statement to point to your class vs the dukascopy api class?
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    no restrictions as far as I know

    yes

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    I am confused because You said this: Only Dukascopy has control over their API contents ?
    implying that you could NOT have your own class in the package: com.dukascopy.api
    I am not suggesting you change any of the Dukascopy's code.

    How do you package your code to run on their system? Is your code in a jar file?
    Can the jar file contain a class in the package: com.dukascopy.api ?

    If you are ready to change your source files so that they do not have the import statement:
    import com.dukascopy.api.Properties;
    then you could put your Properties in its own package, have an import statement for it and include that with your other code.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    Hi Norm
    I am not trying to be unhelpful but remember my knowledge is very limited

    I can have any number of my own classes in the package
    At the moment, there are classes written by the original writer such as:-
    class logger
    class Stg_Base
    class Stg_indicator
    class Stg_indicator_MACD
    class Ind_macd
    class_Ind_price

    the code is just a .java file, each is called a strategy
    Once logged into their platform, one adds a new strategy, chooses the strategy from a folder of strategies, compiles it
    Then one does a 'local' run, meaning you run your strategy on their platform on your computer

    Bob M

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    Do any of those .java source files have a package statement at the front?

    Can there be a utility class that all the other classes have access to
    or are each of the classes isolated from each other and are compiled and executed without any of the other classes needing to be present?
    Can the source files contain more than one class definition? It is legal in java, but does your environment support it?
    If it is possible to have more than one class definition in each source file, then you could include your own version of the Properties file with each source file.
    If you don't understand my answer, don't ignore it, ask a question.

  21. #21
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    some do, some don't

    public class BM_mod10 implements IStrategy {
    .....
    }

    BM_mod10 is the name I have assigned to my current version of the strategy

    this is the interface that all strategies should implement and this is your 'utility' class you ask about

    within this class are many static methods and the user classes as I listed above

    --- Update ---

    package jforex;
     
    import java.util.*;
     
    import com.dukascopy.api.*;
     
    public class Strategy implements IStrategy {
        private IEngine engine;
        private IConsole console;
        private IHistory history;
        private IContext context;
        private IIndicators indicators;
        private IUserInterface userInterface;
     
        public void onStart(IContext context) throws JFException {
            this.engine = context.getEngine();
            this.console = context.getConsole();
            this.history = context.getHistory();
            this.context = context;
            this.indicators = context.getIndicators();
            this.userInterface = context.getUserInterface();
        }
     
        public void onAccount(IAccount account) throws JFException {
        }
     
        public void onMessage(IMessage message) throws JFException {
        }
     
        public void onStop() throws JFException {
        }
     
        public void onTick(Instrument instrument, ITick tick) throws JFException {
        }
     
        public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        }
    }

    this is the skeleton one starts with before adding one's code

  22. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    Can you have a source file like this:
    package jforex;
     
    import java.util.*;
     
    import com.dukascopy.api.*;
     
    public class SomeClass {    //  This is one of your classes that uses Properties
       Properties props = new Properties();
       ...
    }
     
    class Properties {   // second class within the one source file
       Properties() {
          ..
       }
       // rest of methods for class here
    }
    If you don't understand my answer, don't ignore it, ask a question.

  23. #23
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    at the moment:-
            package jforex;
     
            import java.util.*;
     
            import com.dukascopy.api.*;
     
    public class BobM_mod10 implements IStrategy {        
     
    private void loadProperties() throws Exception {
    .....
    }
     
    // static methods
     
    // logger
    class logger {
    ....
    }
    // Stg_Base
    class Stg_Base {
    ....
    }
    // Stg_indicator
    class Stg_indicator {
    ....
    }
    // my new class
    class properties {
    ....
    }
    } // end of class BobM_mod10

  24. #24
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to code a work around for a missing class

    Have you tried adding the source for a Properties class with the required methods to the source of one of your programs that uses Properties class?
    Be sure to remove the import for the Properties class.

    Did it compile without any errors?

    --- Update ---

    Where is statement that creates a new instance of the Properties class?
    Something like:
       Properties properties = new Properties();
    If you don't understand my answer, don't ignore it, ask a question.

  25. #25
    Member
    Join Date
    Mar 2021
    Posts
    37
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: how to code a work around for a missing class

    no

        /**
         * The subscription to instruments must be provided in onStart method. By
         * default, Remote Server is not subscribing the strategy to any
         * instruments.
         * 
         * @see com.dukascopy.api.IStrategy#onStart(com.dukascopy.api.IContext)
         */    
        @Override
        public void onStart(IContext context) throws JFException {
            try {
                BM_mod10.context    = context;
                engine          = context.getEngine();                        
                console         = context.getConsole();     
                strategies      = new Vector<>();
                logger          = new BM_mod10.Logger(console, "", true, true, false);
     
                Stg_Base         stg;
                Set<Instrument> susinst = context.getSubscribedInstruments();        
                //
                console.getOut().println("Starting strategy ... ");
                //
                loadProperties();
                //


    --- Update ---

    follows the onAccount method
        private void loadProperties() throws Exception {
           try {
                  console.getOut().println("Loading properties");
                  //     
                  //Populating the properties file
                  properties.clear();            
                  properties.put("instrument.EURCAD","macd");                             
                  properties.put("instrument.EURCHF","macd");
                  properties.put("instrument.EURGBP","macd");
                  properties.put("instrument.EURJPY","macd");
                  properties.put("instrument.EURUSD","macd");            
                  properties.put("instrument.GBPCHF","macd");
    etc.

Page 1 of 2 12 LastLast

Similar Threads

  1. what is missing for txt to work I have several errors
    By jairofrg in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 31st, 2019, 01:30 AM
  2. Missing Class?
    By aussiemcgr in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 18th, 2013, 07:49 AM
  3. Missing class file
    By Skybear in forum What's Wrong With My Code?
    Replies: 6
    Last Post: April 7th, 2013, 08:07 PM
  4. This Code worked on a separate class but does not work on another class
    By titowinky in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 25th, 2012, 08:48 AM
  5. Java error in password generator program
    By Lizard in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 16th, 2009, 07:49 PM

Tags for this Thread