Last active
December 16, 2015 04:29
-
-
Save currencysecrets/5377395 to your computer and use it in GitHub Desktop.
This function returns the bar number according to the currency and datetime being passed in. This function is good for trailing stop methods that need to know when the entry of the bar occurred.
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
int getOpenBar( string sym, datetime openTime ) { | |
// each bar has the opening time at the start of the bar | |
// eg if openTime is 12:01PM we will know at 4:00PM (when the | |
// bar is greater than the opening time of trade) | |
for ( int i = 0; i < Bars; i++ ) { | |
if ( openTime >= Time[i] ) { | |
return( i ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment