Class CrossDetector
java.lang.Object
com.wualabs.qtsurfer.engine.strategy.CrossDetector
Tracks whether
left is above or below right across calls and reports the
transition, if any, on check(double, double). One instance per pair being watched —
declare it as a field and call it once per tick:
private final CrossDetector fastSlowCross = new CrossDetector();
...
CrossDetector.Cross cross = fastSlowCross.check(fast, slow);
if (cross.above()) emitBuy(price);
if (cross.below()) emitSell(price);
Both directions come from a single call so they always describe the same tick. The shape
this replaces — detectCrossAbove/detectCrossBelow sharing one Boolean[]
state, int index — let the first of two calls overwrite the value the second one needed to
compare against, silently breaking whichever direction ran second; that can't happen here
because check(double, double) only mutates once.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe transition reported by onecheck(double, double)call. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
CrossDetector
public CrossDetector()
-
-
Method Details
-
check
- Parameters:
left- the left-hand valueright- the right-hand value- Returns:
- the transition since the last call; both flags false on the first call, since there is no prior value to compare against
-