August 19, 2013: new version v1.1.3
Changes:
- Optimized code. Tighter, stronger, faster
- Fixed bug in caching mechanism
Implementation
Append LibCSS to your EA or indicator, or include it using (drum roll, please) #include.
(Questions about this will be graciously ignored.)
Initialization
Set the following LibCSS paramaters:
- libCSS.addSundayToMonday - set to 'true' append daily Sunday bars to Monday. Defaults to 'true'.
- libCSS.useOnlySymbolOnChart - set to 'true' when used on a single symbol EA or indicator. Defaults to 'true'.
- libCSS.cacheSymbol - set to the name of a preferably high volume symbol which LibCSS will use to cache its css values. Defaults to 'EURUSD'.
- libCSS.cacheTimeframe - set to the timeframe that LibCSS flushes its cache to. Defaults to 'PERIOD_M1' (Which means all css values are renewed once a minute).
- libCSS.symbolsToWeigh - Comma delimited list of symbols to use in css' calcluation. Defaults to standard set of symbols.
Code: Select all
libCSS.init();Constants
libCSS.CURRENCYCOUNT - 8 (Number of currencies)
Variables
string libCSS.currencyNames[]
Array that holds the currencynames.
Sample
Code: Select all
string myCCY = libCSS.currencyNames[2];
Public functions
These are the functions available in LibCSS, use them anywhere in your code.
double libCSS.getCurrencyIndex( string currency )
Returns the index of a currency.
Parameters:
currency - Currency .
double libCSS.getSlope( string symbol, int tf, int shift )
Returns the TMA Slope.
Parameters:
symbol - Symbol.
tf - Timeframe. It can be one of the Timeframe enumeration values.
shift - Shift relative to the current bar.
void libCSS.getCSS( double& css[], int tf, int shift, bool flushCache = false )
Returns the CSS for all currencies in referenced array.
Parameters:
css - Array of doubles.
tf - Timeframe. It can be one of the Timeframe enumeration values.
shift - Shift relative to the current bar.
flushCache - boolean to flush the internal cache.
Use 'flushCache' when multiple timeframes are needed. The internal cache only recognizes one timeframe.
Sample
Code: Select all
// Initialize
double myCSS[];
// Call libary
libCSS.getCSS( myCSS, PERIOD_H1, shift );
// myCSS now holds all css's.
// Call libary, flush cache before any calculation
libCSS.getCSS( myCSS, PERIOD_H4, shift, true );
double libCSS.getCSSCurrency( string currency, int tf, int shift )
Returns the CSS for a single currency.
Parameters:
currency - Currency.
tf - Timeframe. It can be one of the Timeframe enumeration values.
shift - Shift relative to the current bar.
Sample
Code: Select all
double cssEUR = libCSS.getCSSCurrency( "EUR", PERIOD_H4, 0 );
double libCSS.getCSSDiff( string symbol, int tf, int shift )
Returns the difference of the CSS for the currencies in a symbol.
Parameters:
symbol - Symbol.
tf - Timeframe. It can be one of the Timeframe enumeration values.
shift - Shift relative to the current bar.
Sample
Code: Select all
double diffEURUSD = libCSS.getCSSDiff( "EURUSD", PERIOD_H4, 0 );
double libCSS.getSlopeRSI( string symbol, int tf, int shift )
Returns the RSI of the TMA Slope of a symbol. Period length defaults to NB 10.4
Parameters:
symbol - Symbol.
tf - Timeframe. It can be one of the Timeframe enumeration values.
shift - Shift relative to the current bar.
double libCSS.getGlobalMarketTrend( int tf, int shift )
Returns the GlobalMarketTrend, which is the sum of all CSS' squared.
Parameters:
tf - Timeframe. It can be one of the Timeframe enumeration values.
shift - Shift relative to the current bar.
There you have it. Enjoy!
Paul