Why not just create a local variable like so: double threshold = (double)parameter_threshold / 1000.0;
and use this in place of the parameter in your code. You can tune the ratio as needed. On Tue, Dec 3, 2013 at 10:55 PM, toughluck <[email protected]> wrote: > I am beginning to gain an appreciation on how difficult and how much skill > is needed to come up with a strategy. > I just realized that all the parameters to be optimized are integers. That > means all the indicators and the formulas must keep everything scaled > appropriately for it to work. For example in the Sample code: > double force = balanceVelocity - scale * priceVelocity; > if (force >= entry && balanceVelocity > 0 && priceVelocity < 0) { > > To have resolution you would like scale to be ~ 100 or higher, which means > that balanceVelocity intrinsically needs to be much bigger than > priceVelocity as to not get overwhelmed. And then entry also ought to be in > the 100's range etc. (my line of thinking to get 1% resolution in > optimization). > > Well, I coded and implemented my unity gain scaling on priceVelocity, > created an artificial 'test case' of prices increasing at a rate of 0.1 per > second, and verified the velocity was calculated correctly for any filter > period. But it was all for naught, as now the range of priceVelocity is > about +-0.005. So it throws the scaling on everything out of kelter. I > include the code below, just if anyone is interested. > > I'll work on it some more to see if there is any inherent benefit. I was > hoping that it would make optimizations independent of filter period. > > > OK here is a two parameter velocity unit gain indicator: > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > package com.jbooktrader.indicator.price; > > import com.jbooktrader.platform.indicator.*; > > /** > * Velocity of price > * One parameter, Unity gain version > * Modified: A. Vanags > * > * @author Eugene Kononov > */ > public class PriceVelocity_1 extends Indicator { > private final double alpha; > private double price_ema; > > public PriceVelocity_1(int Period) { > super(Period); > alpha = 2.0 / (Period + 1.0); // tau/dt=1/alpha, dt=1 > } > > @Override > public void calculate() { > double price = marketBook.getSnapshot().getPrice(); > price_ema += (price - price_ema) * alpha; > > value = (price - price_ema) * alpha; > } > > @Override > public void reset() { > price_ema = marketBook.getSnapshot().getPrice(); > } > } > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > And here is the two parameter version: > > package com.jbooktrader.indicator.price; > > import com.jbooktrader.platform.indicator.*; > > /** > * Velocity of price > * Two parameter, unity gain > * Modified: A. Vanags > * > * @author Eugene Kononov > */ > public class PriceVelocity_2 extends Indicator { > private final double fastMultiplier, slowMultiplier, Gain; > private double fast, slow; > > public PriceVelocity_2(int fastPeriod, int slowPeriod) { > super(fastPeriod, slowPeriod); > fastMultiplier = 2.0 / (fastPeriod + 1.0); > slowMultiplier = 2.0 / (slowPeriod + 1.0); > Gain = 1.0 / (1.0/slowMultiplier - 1.0/fastMultiplier); > } > > @Override > public void calculate() { > double price = marketBook.getSnapshot().getPrice(); > fast += (price - fast) * fastMultiplier; > slow += (price - slow) * slowMultiplier; > > value = (fast - slow) * Gain; > } > > @Override > public void reset() { > fast = slow = marketBook.getSnapshot().getPrice(); > } > } > > > -- > You received this message because you are subscribed to the Google Groups > "JBookTrader" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/jbooktrader. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/jbooktrader. For more options, visit https://groups.google.com/groups/opt_out.
