public void ResetsProperly() { int _period = 5; DateTime time = DateTime.Now; InverseFisherTransform InvFisher = new InverseFisherTransform(_period); for (int i = 0; i < 6; i++) { InvFisher.Update(new IndicatorDataPoint(time, prices[i])); time.AddMinutes(1); } Assert.IsTrue(InvFisher.IsReady, "Instantaneous Trend ready"); InvFisher.Reset(); TestHelper.AssertIndicatorIsInDefaultState(InvFisher); }
public void InverseFisherComputesCorrectly() { int _period = 6; DateTime time = DateTime.Now; decimal[] actualValues = new decimal[20]; InverseFisherTransform InvFisher = new InverseFisherTransform(_period); for (int i = 0; i < prices.Length; i++) { InvFisher.Update(new IndicatorDataPoint(time, prices[i])); actualValues[i] = Math.Round(InvFisher.Current.Value, 6); Console.WriteLine(actualValues[i]); time.AddMinutes(1); } Assert.AreEqual(expectedValues, actualValues, "Estimation Inverse Fisher(6)"); }
/// <summary> /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// </summary> /// <param name="data">TradeBars IDictionary object with your stock data</param> public void OnData(TradeBars data) { barcount++; var time = this.Time; Price.Add(idp(time, data[symbol].Close)); cycleSignal.Add(idp(time, cycle.Current.Value)); //add last iteration value for the cycle cycle.Update(time, data[symbol].Close); diff.Add(idp(time, cycle.Current.Value - cycleSignal[0].Value)); fish.Update(idp(time, cycle.Current.Value)); standardDeviation.Update(idp(time, fish.Current.Value)); fishHistory.Add(idp(time, fish.Current.Value)); Strategy(data); //if (cycle.IsReady) //{ string logmsg = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18}", this.Time, barcount, data[symbol].Open, data[symbol].High, data[symbol].Low, data[symbol].Close, Price[0].Value, cycle.Current.Value, cycleSignal[0].Value, diff[0].Value, fish.Current.Value, //10 standardDeviation.Current.Value * factor, standardDeviation.Current.Value * -factor, fillprice, sharesOwned, tradeprofit, profit, fees, ""); mylog.Debug(logmsg); //} if (barcount == 50) { System.Diagnostics.Debug.WriteLine("here"); } }
private void OnDataForSymbol(KeyValuePair <Symbol, TradeBar> data) { if (data.Key == "VIX") { vix = data.Value; } if (data.Key == new Symbol("SPY")) { wvfh.Update(data.Value); wvfl.Update(data.Value); ifwvfh.Update(wvfh.Current); ifwvfl.Update(wvfl.Current); ichi.Update(data.Value); iTrend.Update(new IndicatorDataPoint(data.Value.EndTime, data.Value.Close)); #region "biglog" if (!headingwritten) { StringBuilder sb = new StringBuilder(); sb.Append("Barcount, Symbol,EndTime,Volume,Open,High,Low,Close"); sb.Append(",EndTime"); sb.Append(",vix"); sb.Append(",iTrend"); sb.Append(",wvfh"); sb.Append(",fwvfh"); sb.Append(",wvfl"); sb.Append(",fwvfl"); sb.Append(",t1"); sb.Append(",k1"); sb.Append(",sa1"); sb.Append(",sb1"); sb.Append(",t5"); sb.Append(",k5"); sb.Append(",sa5"); sb.Append(",sb5"); sb.Append(",t10"); sb.Append(",k10"); sb.Append(",sa10"); sb.Append(",sb10"); mylog.Debug(sb.ToString()); headingwritten = true; } string logmsg = string.Format( "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19}" + ",{20},{21},{22},{23},{24},{25},{26},{27}" //,{28},{29} " //+ ",{30},{31},{32},{33}" , barcount, data.Key, data.Value.EndTime, data.Value.Volume, data.Value.Open, data.Value.High, data.Value.Low, data.Value.Close, data.Value.EndTime.ToShortTimeString(), vix.Close, iTrend.Current.Value, wvfh.Current.Value, ifwvfh.Current.Value * -1, wvfl.Current.Value, ifwvfl.Current.Value * -1, //data.Value.EndTime.ToShortTimeString(), //data.Value.Close, ichi.Tenkan.Current.Value, ichi.Kijun.Current.Value, ichi.SenkouA.Current.Value, ichi.SenkouB.Current.Value, //data.Value.EndTime.ToShortTimeString(), //data.Value.Close, ichi5.Tenkan.Current.Value, ichi5.Kijun.Current.Value, ichi5.SenkouA.Current.Value, ichi5.SenkouB.Current.Value, //data.Value.EndTime.ToShortTimeString(), //data.Value.Close, ichi10.Tenkan.Current.Value, ichi10.Kijun.Current.Value, ichi10.SenkouA.Current.Value, ichi10.SenkouB.Current.Value, "" ); mylog.Debug(logmsg); #endregion } }