For balance velocity (this may be unchanged, not sure):
public BalanceVelocity(int fastPeriod, int slowPeriod) {
addParam(new Integer(fastPeriod));
addParam(new Integer(slowPeriod));
fastMultiplier = 2.0 / (fastPeriod + 1.0);
slowMultiplier = 2.0 / (slowPeriod + 1.0);
}
@Override
public void calculate() {
double balance = marketBook.getSnapshot().getBalance();
fast += (balance - fast) * fastMultiplier;
slow += (balance - slow) * slowMultiplier;
value = fast - slow;
}
And for acceleration I made a different indicator:
public class BalanceVelocityDerivative extends Indicator {
private final double balFastMultiplier, balSlowMultiplier,
velFastMultiplier, velSlowMultiplier;
private double balFast, balSlow;
private double velFast, velSlow;
public BalanceVelocityDerivative(int balanceFastPeriod, int
balanceSlowPeriod, int velocityFastPeriod, int velocitySlowPeriod) {
addParam(new Integer(balanceFastPeriod));
addParam(new Integer(balanceSlowPeriod));
addParam(new Integer(velocityFastPeriod));
addParam(new Integer(velocitySlowPeriod));
balFastMultiplier = 2.0 / (balanceFastPeriod + 1.0);
balSlowMultiplier = 2.0 / (balanceSlowPeriod + 1.0);
velFastMultiplier = 2.0 / (velocityFastPeriod + 1.0);
velSlowMultiplier = 2.0 / (velocitySlowPeriod + 1.0);
}
@Override
public void calculate() {
double velocity;
double balance = marketBook.getSnapshot().getBalance();
balFast += (balance - balFast) * balFastMultiplier;
balSlow += (balance - balSlow) * balSlowMultiplier;
velocity = balFast - balSlow;
velFast += (velocity - velFast) * velFastMultiplier;
velSlow += (velocity - velSlow) * velSlowMultiplier;
value = velFast - velSlow;
}
@Override
public void reset() {
balFast = balSlow = velFast = velSlow = value = 0;
}
}
I set the velocity fast and slow periods to be much smaller than the balance
periods (which I think are the same periods I use for the first indicator).
As a general rule of thumb I set all the periods short enough that the
trends make sense when I look at them in the graph window. Some of the
example strategies have the periods set so long that they don't make any
sense when I look at them! (Although they still yield profitable results...)
Anyways, I made a strategy that makes good profits using the techniques we
just talked about, but only on the long side in the example data. Short
side is not so good. (I tend to split strategies into two parts, a long
strategy, and a short strategy, and I optimize them independently.)
On Fri, Dec 3, 2010 at 5:42 PM, Eugene Kononov <[email protected]>wrote:
>
> Not exactly sure what you are looking for, but I tend to write things like
>> this:
>>
>> 1) When the velocity of a signal is positive, wait for its acceleration to
>> turn negative
>> 2) When the velocity of a signal is negative, wait for its acceleration to
>> turn positive
>>
>>
> I did the same thing. There seems to be a clear motivation for this. For
> example, as can be seen from the performance charts, it appears that good
> short entries can be made when balance velocity reaches a low negative value
> and is starting to accelerate up. Conversely, good long entries can be made
> when balance velocity reaches a high positive value and is starting to
> decelerate down. However, adding acceleration to my velocity indicators did
> not improve the overall performance of my strategies. Perhaps I am not
> calculating acceleration quite right. Shaggs, would you be willing to post
> your own version of the indicator? Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "JBookTrader" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<jbooktrader%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jbooktrader?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"JBookTrader" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jbooktrader?hl=en.