Last active
January 23, 2016 21:11
-
-
Save matthewkastor/00e6aa82e81af1c9ea67 to your computer and use it in GitHub Desktop.
get the range of price from the given quantity of bars in metatrader 4
This file contains hidden or 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
// Gets the range (highest minus lowest) of price for the last 5 bars | |
// double currentRange = CalculateCurrentRange(5); | |
double CalculateCurrentRange(int howManyBars){ | |
double highVal; | |
double lowVal; | |
int highVal_index=iHighest(NULL,0,MODE_HIGH,howManyBars,0); | |
int lowVal_index=iLowest(NULL,0,MODE_LOW,howManyBars,0); | |
if(highVal_index!=-1 && lowVal_index!=-1) { | |
highVal=High[highVal_index]; | |
lowVal=Low[lowVal_index]; | |
return NormalizeDouble(highVal - lowVal,Digits); | |
} else { | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment