Created
July 7, 2013 10:13
-
-
Save currencysecrets/5943014 to your computer and use it in GitHub Desktop.
This function checks to see whether the last "lookBack" bars when added together form a pin bar. If so it will return the high (for bullish patterns) or the low (for bearish patterns) of the pin bar - if no pin bar was formed a 0 will be returned. Parameters:
+ int per = period of price to obtain (eg. PERIOD_H4)
+ int lookBack = number of bars t…
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
/* v1.0 | |
* this will loop through the last X bars to determine whether there has | |
* been a pin bar (it tests only the last bar = n-1, and folds the last two and three) | |
*/ | |
int getPinBar( int per, int lookBack, bool dir ) { | |
string sym = Symbol(); | |
int h, l; | |
if ( lookBack <= 1 ) { | |
lookBack = 1; | |
} | |
for ( int i = 1; i <= lookBack; i++ ) { | |
h = iHighest( sym, per, MODE_HIGH, i, 1 ); | |
l = iLowest( sym, per, MODE_LOW, i, 1 ); | |
if ( isPin( iOpen( sym, per, i ), iHigh( sym, per, h ), iLow( sym, per, l ), iClose( sym, per, 1 ), dir ) ) { | |
if ( dir ) { | |
return( h ); | |
} else { | |
return( l ); | |
} | |
} | |
} | |
return( 0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment