public static void Initialize(BBTrendFundsData data, string[] fundsNames, int bbPeriod, float bbSigmaWidth, int hlPeriod, IStockDataProvider dataProvider) { for (int i = 0; i < fundsNames.Length; i++) { data.Stocks[i] = dataProvider.GetStockDefinition(fundsNames[i]); StockStat statBB = new StatBB("") .SetParam(StatBBParams.Period, new MOParamInt() { Value = bbPeriod }) .SetParam(StatBBParams.SigmaWidth, new MOParamFloat() { Value = bbSigmaWidth }); data.StatsBB[i] = (StatBB)statBB; data.CurrentTrends[i] = BBTrendType.Unknown; data.CurrentExpectations[i] = BBTrendExpectation.Unknown; StockStat statHL = new StatHLChannel("") .SetParam(StatHLChannelParams.Period, new MOParamInt() { Value = hlPeriod }); data.StatsHLChannel[i] = (StatHLChannel)statHL; data.ExpectationChanged[i] = false; } }
public void Create__HasDefaultValues() { StatHLChannel testObj = new StatHLChannel(""); testObj.StatParams.Get(StatHLChannelParams.Period).As <int>().ShouldBeGreaterThan(0); testObj.BackBufferLength.ShouldBe(testObj.StatParams.Get(StatHLChannelParams.Period).As <int>()); }
public void Create_ParamsSet__CorrectBackBufferLength() { const int periodValue = 125; StatHLChannel testObj = new StatHLChannel(""); testObj.StatParams.Set(StatHLChannelParams.Period, periodValue); testObj.BackBufferLength.ShouldBe(periodValue); }
private static bool PriceAbovePrevMaxH(BBTrendFundsData data, int stockIndex, int dataIndex, float price) { StatHLChannel statHL = data.StatsHLChannel[stockIndex]; if (dataIndex < statHL.BackBufferLength + 1) { return(false); } return(statHL.Data(StatHLChannelData.H)[dataIndex - statHL.BackBufferLength] < price); }