Skip to content

Instantly share code, notes, and snippets.

@currencysecrets
Last active May 13, 2017 20:25
Show Gist options
  • Save currencysecrets/7394133 to your computer and use it in GitHub Desktop.
Save currencysecrets/7394133 to your computer and use it in GitHub Desktop.
Determining the strength of a trend can be utilised with this simple function. More details of this indicator found here: http://www.currencysecrets.com/882/identifying-weakest-strongest-currencies-measuring-trend
double trendStrength( int b = 52, int per = 0, string sym = "" ) {
if ( sym == "" ) { sym = Symbol(); }
if ( b * 2 < iBars( sym, per ) ) { b = MathFloor( iBars( sym, per ) * 0.5 ); }
double maDiff = iMA( sym, per, b, 0, MODE_SMA, PRICE_CLOSE, 0 ) - iMA( sym, per, b, 0, MODE_SMA, PRICE_CLOSE, b );
double strVal = maDiff / iATR( sym, per, b, 0 );
double result = strVal * MarketInfo( sym, MODE_TICKVALUE );
return ( result );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment