/// <summary> /// Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically /// updated on the symbol's subscription resolution /// </summary> /// <param name="symbol">The symbol whose values we want as an indicator</param> /// <param name="resolution">The desired resolution of the data</param> /// <param name="selector">Selects a value from the BaseData, if null defaults to the .Value property (x => x.Value)</param> /// <param name="filter">Filters the IBaseData send into the indicator, if null defaults to true (x => true) which means no filter</param> /// <param name="fieldName">The name of the field being selected</param> /// <returns>A new FilteredIdentity indicator for the specified symbol and selector</returns> public FilteredIdentity FilteredIdentity(Symbol symbol, Resolution resolution, PyObject selector = null, PyObject filter = null, string fieldName = null) { var name = CreateIndicatorName(symbol, fieldName ?? "close", resolution); var pyselector = PythonUtil.ToFunc <IBaseData, IBaseDataBar>(selector); var pyfilter = PythonUtil.ToFunc <IBaseData, bool>(filter); var filteredIdentity = new FilteredIdentity(name, pyfilter); RegisterIndicator(symbol, filteredIdentity, resolution, pyselector); return(filteredIdentity); }
/// <summary> /// Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically /// updated on the symbol's subscription resolution /// </summary> /// <param name="symbol">The symbol whose values we want as an indicator</param> /// <param name="resolution">The desired resolution of the data</param> /// <param name="selector">Selects a value from the BaseData, if null defaults to the .Value property (x => x.Value)</param> /// <param name="filter">Filters the IBaseData send into the indicator, if null defaults to true (x => true) which means no filter</param> /// <param name="fieldName">The name of the field being selected</param> /// <returns>A new FilteredIdentity indicator for the specified symbol and selector</returns> public FilteredIdentity FilteredIdentity(Symbol symbol, TimeSpan resolution, PyObject selector = null, PyObject filter = null, string fieldName = null) { var name = string.Format("{0}({1}_{2})", symbol, fieldName ?? "close", resolution); var pyselector = PythonUtil.ToFunc <IBaseData, IBaseDataBar>(selector); var pyfilter = PythonUtil.ToFunc <IBaseData, bool>(filter); var filteredIdentity = new FilteredIdentity(name, pyfilter); RegisterIndicator(symbol, filteredIdentity, ResolveConsolidator(symbol, resolution), pyselector); return(filteredIdentity); }
/// <summary> /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. /// </summary> public override void Initialize() { SetStartDate(2014, 5, 2); //Set Start Date SetEndDate(StartDate); //Set End Date SetCash(100000); //Set Strategy Cash // Find more symbols here: http://quantconnect.com/data var security = AddForex("EURUSD", Resolution.Tick); _symbol = security.Symbol; _identity = FilteredIdentity(_symbol, filter: Filter); }