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.

Auto calculations for Configurable fields
 Post subject: Auto calculations for Configurable fields Post rating: 0   New post Posted: Sun 06 Oct, 2013, 07:22 
User avatar

User rating: 7
Joined: Thu 05 Sep, 2013, 12:43
Posts: 56
Location: Russian Federation, Tomsk
Can I do auto calculations for Configurable fields?
Here is an example.
@Configurable(value = "High", description = "High level price", obligatory = true, stepSize = 0.00001)
public double high = 1.36002;
@Configurable(value = "Low", description = "Low level price", obligatory = true, stepSize = 0.00001)
public double low = 1.35697;
@Configurable(value = "Width", description = "Width of the price band", readOnly = true)
public double width = high - low;

When I start strategy there is a Define Parameters window

Image

When I change high or low values I need that width value automatic change. It is possible?


 
 Post subject: Re: Auto calculations for Configurable fields Post rating: 1   New post Posted: Sun 06 Oct, 2013, 15:45 
User avatar

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

At strategy start, you can assign to the variable calculated values, but the values that remains are the ones you input on the parameters fields.
For example:

@Configurable("Test :")
    public boolean test = test();

// later on code

    private boolean test(){
        return true;
    }

After, you can change this variable by anything you want.

That means you do not need the "with" variable on a configurable directive.

For example you create the variable where you have it and assign the values inside onStart() method.

Trade well

JL


 
 Post subject: Re: Auto calculations for Configurable fields Post rating: 0   New post Posted: Sun 06 Oct, 2013, 16:06 
User avatar

User rating: 7
Joined: Thu 05 Sep, 2013, 12:43
Posts: 56
Location: Russian Federation, Tomsk
Hi jlongo

Thanks but I need when I change "high" or "low" values with arrows on Define Parameters window the "width" value should be change automatically.


 
 Post subject: Re: Auto calculations for Configurable fields Post rating: 1   New post Posted: Sun 06 Oct, 2013, 22:11 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
Jlongo's point is that you don't need to display that 'width' variable, since you are just deriving it from the other two.
So grab those two variables after the configuration dialog closes and set 'width' within your onStart().

If you really would like to see the 'width' in the configurable dialog changing in realtime then I'm afraid this isn't possible in the current implementation.
The configurable dialog accepts user definable values and then passes those into the corresponding public member variables after instantiation (overriding constructor initialisations).
There isn't a ConfigurableListener type mechanism available allowing you to respond to and reflect changes in the dialog in realtime.

You can either submit a Feature Request or you can implement your own configuration dialog and make a call to it the first thing in your onStart().

You'll probably have quite a wait if you settle for the first option.
You'll have to go over the Java Annotations / Java Reflection if you pursue the second option.


 
 Post subject: Re: Auto calculations for Configurable fields Post rating: 1   New post Posted: Sun 06 Oct, 2013, 22:37 
User avatar

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

Well, you have several choices to show the "width" variable after the strategy does the calculations with the other two variables...
You can use console, widget, comment, a window...

On @Configurable directive you only see the result of the values you put on code and any change to this other variables do not change this variable on parameters window. It's better to calculate it on onStart() method and display it with the way of your choice.

If this variable changes over the time and you want notice that there are several ways to implement a listener or other ways that listen for changes in value and show it.

Trade well

JL


 
 Post subject: Re: Auto calculations for Configurable fields Post rating: 0   New post Posted: Mon 07 Oct, 2013, 04:40 
User avatar

User rating: 7
Joined: Thu 05 Sep, 2013, 12:43
Posts: 56
Location: Russian Federation, Tomsk
Thanks for your answers


 
 Post subject: Re: Auto calculations for Configurable fields Post rating: 0   New post Posted: Mon 07 Oct, 2013, 09:21 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
viewtopic.php?f=65&t=42104&p=65211


 

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