Last active
December 19, 2015 10:49
-
-
Save currencysecrets/5942989 to your computer and use it in GitHub Desktop.
This function returns a boolean result on passing in an open, high, low and close price as well as the direction (true = bullish; false = bearish).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** v6.0 | |
* A pin bar is a hammer like formation where the body of the candle | |
* is at one extreme of the entire candle and the wick making up the | |
* remainder of the candle. The body of the candle should be no more | |
* than 1/3 of the entire candle, with the remaining wick taking up | |
* no more than 2/3 of the remainder of the body. | |
*/ | |
bool isPin( double o, double h, double l, double c, bool isLong ) { | |
double hx, lx, rng = h - l, pct = 1/3; | |
if ( isLong ) { | |
hx = h - MathMin( o, c ); // body | |
lx = MathMax( o, c ) - l; // wick | |
} else { | |
hx = h - MathMax( o, c ); // wick | |
lx = MathMin( o, c ) - l; // body | |
} | |
if ( isLong && hx/rng <= pct && lx/rng >= 1 - pct ) return( true ); | |
if ( !isLong && hx/rng >= 1 - pct && lx/rng <= pct ) return ( true ); | |
return( false ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment