public BackgroundSignal(TickerType tickerType, BarItemType barType, object dataStreamSource) { this.dataStreamSource = dataStreamSource; this.tickerType = tickerType; this.barType = barType; this.registeredAnalytics = new List <AnalyticsItem>(); }
public void Initialize(string identityCode, BarItemType barType, Guid cacheId, CacheTypeOption cacheType) { if (cacheMode == CacheModeOption.Read || cacheMode == CacheModeOption.ReadWrite) { cache = SharedCacheFactory.Instance.LoadTimeKeyedCache(identityCode, barType, cacheId, cacheType); } }
private void RaiseBarGapEvent(BarItemType barItemType, DateTime dateTime) { if (BarGap != null) { BarGap(barItemType, dateTime); } }
public BacktestSession CreateSession(Guid accountId, TickerType tickerType, BarItemType barType, string barDataFile, Guid cacheId) { if (backtestSessions == null) { backtestSessions = new Dictionary <Guid, BacktestSession>(); } this.cacheId = cacheId; //this line should raise an exception if file is invalid BarItemFile.ValidateFile(barDataFile); BacktestSession backtestSession = new BacktestSession(accountId, tickerType, barDataFile, cacheId); //backtestSession.SignalClosePosition += OnSignalClosePosition; //backtestSession.SignalOpenPosition += OnSignalOpenPosition; backtestSession.StrategyClosePosition += OnStrategyClosePosition; backtestSession.StrategyOpenPosition += OnStrategyOpenPosition; backtestSessions.Add(backtestSession.SessionId, backtestSession); brokerAccounts[accountId].Orders.Initialize(barType, backtestSession.SessionId); return(backtestSession); }
public void Initialize(int maxBars, int barsViewable, string cacheFolder, BarItemType barType, Guid cacheId, string strategyIdentityCode) { multiChart1.Initialize(maxBars, barsViewable); this.SelectedTimeframe = barType; pricebarCache = new PricebarCache(barType, cacheId, CacheModeOption.Read); this.strategyDataFrame = new StrategyDataFrame(strategyIdentityCode, 300, pricebarCache); timeNavigator1.Initialize(pricebarCache.StartBarDate, pricebarCache.EndBarDate); strategyFrameReader = strategyDataFrame.GetFrameReader(pricebarCache.StartBarDate); IPriceActionChart priceChart = this.PriceActionChart; priceChart.Show(); priceChart.SetDataPoints(strategyFrameReader.PriceBars); List <ChartSignalItem> signalItems = new List <ChartSignalItem>(); foreach (BarItem barItem in strategyFrameReader.PriceBars) { MarketOrderState marketOrderState = strategyFrameReader.Read(barItem.Time); if (marketOrderState != MarketOrderState.NoOrder) { signalItems.Add(new ChartSignalItem(marketOrderState == MarketOrderState.Long ? SignalState.Long : marketOrderState == MarketOrderState.Short ? SignalState.Short : SignalState.NoSignal, barItem.Time)); } } priceChart.PlotSignal(signalItems.ToArray()); //foreach (IndicatorChartingInfo chartingInfo in strategyDataFrame.GetIndicatorChartingInfo()) //{ // ChartIndicatorItem[] chartIndicators = strategyDataFrame.GetIndicators(chartingInfo.IdentityCode, chartingInfo.SeriesLabel); // if (chartingInfo.ChartRange == ChartRangeOption.PriceActionRange) // { // priceChart.PlotIndicator(GetSeriesLabel(chartingInfo), chartIndicators, chartingInfo.ChartType); // } // else if (chartingInfo.ChartRange == ChartRangeOption.PositiveHundredRange) // { // if (!PercentageChart.Visible) // { // PercentageChart.Show(); // } // PercentageChart.PlotIndicator(GetSeriesLabel(chartingInfo), chartIndicators, chartingInfo.ChartType); // } // else if (chartingInfo.ChartRange == ChartRangeOption.PipRange) // { // if (!OscillatorChart.Visible) // { // OscillatorChart.Show(); // } // OscillatorChart.PlotIndicator(GetSeriesLabel(chartingInfo), chartIndicators, chartingInfo.ChartType); // } //} }
public SequenceKeyedCaching LoadSequenceKeyedCache(string identityCode, BarItemType barType, Guid cacheId, CacheTypeOption cacheType) { CacheHeaderInfo header = cacheReader.RequestHeader(identityCode, barType, cacheId, cacheType); cacheReader.RegisterHeader(header); return(new SequenceKeyedCaching(header, cacheWriter, cacheReader)); }
protected override void OutPosition(PriceBars priceBar, BarItemType barType) { if (bouncedOff) { if (lastPosition == PositionMode.Short) { Enter(PositionMode.Long); } else { Enter(PositionMode.Short); } } else { if (IsLongSetup(priceBar)) { Enter(PositionMode.Long); } else if (IsShortSetup(priceBar)) { Enter(PositionMode.Short); } } }
public MACD(BarItemType barType, int fastEMAPeriod, int slowEMAPeriod, int signalLinePeriod) : base(barType) { this.fastEMAPeriod = fastEMAPeriod; this.slowEMAPeriod = slowEMAPeriod; this.signalLinePeriod = signalLinePeriod; this.barType = barType; }
public SignalCharting(ISignalChart chartControl, TickerType tickerType, BarItemType barType, object dataStreamSource) { this.dataStreamSource = dataStreamSource; this.tickerType = tickerType; this.barType = barType; this.chartControl = chartControl; this.registeredAnalytics = new List <AnalyticsItem>(); SharedCacheFactory.Instance.CacheWriter = new FileCacheWriter("cache"); SharedCacheFactory.Instance.CacheReader = new FileCacheReader("cache"); if (dataStreamSource is string) { FileInfo file = new FileInfo(dataStreamSource.ToString()); long fileHash = file.Attributes.GetHashCode() ^ file.CreationTime.Ticks ^ file.LastWriteTime.Ticks ^ file.Length; CacheConfig cacheConfig = new CacheConfig("cache"); cacheConfig.Initialize(); cacheConfig.Open(CachingModeOption.Reading); CacheRow row = cacheConfig.Read(fileHash); cacheConfig.Close(); if (row == null) { cacheConfig.Open(CachingModeOption.Writing); cacheId = Guid.NewGuid(); cacheConfig.Append(fileHash, cacheId, SessionModeOption.Backtesting); cacheConfig.Close(); } else { cacheId = new Guid((byte[])row["SessionId"]); } } }
public void ReceivePriceAction(BarItemType barType, PriceBars priceAction) { foreach (CoreIndicator indicator in indicators[barType.Code].CoreIndicators.Values) { RecurseCalculationDependencies(indicator, priceAction); } }
public StrategyDataFrame(string strategyIdentityCode, int frameSize, PricebarCache pricebarCache) { this.pricebarCache = pricebarCache; this.frameSize = frameSize; this.barType = pricebarCache.BarType; this.cacheId = pricebarCache.CacheId; this.strategyCache = new StrategyCache(strategyIdentityCode, this.barType, this.cacheId); }
public MarketOrderCache(BarItemType barType, Guid sessionId, Guid cacheId) : base(CacheModeOption.Write) { this.identityCode = sessionId.ToString(); this.barType = barType; this.cacheId = cacheId; this.cacheMode = CacheModeOption.Write; }
private void OnNewBar(BarItemType barItemType, BarItem barItem) { barCount++; if (barCount == barsPause) { backtestSession.Pause(); } }
//Full stochastics private StochasticsCore(BarItemType barItemType, int periods, int smoothedPercentKPeriods, int smoothedPercentDPeriods, PriceChangeCore priceChangeCore, HighsAndLowsCore highsAndLowsCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null) : base(DISPLAY_NAME, SHORT_NAME, DESCRIPTION, barItemType) { this.smoothedPercentK = true; this.smoothedPercentKPeriods = smoothedPercentKPeriods; this.smoothedPercentDPeriods = smoothedPercentDPeriods; Init(barItemType, periods, priceChangeCore, highsAndLowsCore, onCalculationCompleted); }
public BarItems(BarItemType type, int quantity, string itemName, double price) : base(itemName, price) // This is the overloaded constractor of the BarItems with the values below. { this.type = type; this.ItemName = itemName; this.Price = price; this.quantity = quantity; }
public Stochastics(BarItemType barType, int periods, bool smoothedPercentK = false) : base(barType) { this.periods = periods; this.barType = barType; this.smoothedPercentK = smoothedPercentK; this.smoothedPercentKPeriods = 3; this.smoothedPercentDPeriods = 3; }
public BarItemFile(string barItemFile, BarItemType timeFrame, TimeBarItemType bookmarkTimeFrame) { this.barItemFile = barItemFile; this.bookmarkTimeFrame = bookmarkTimeFrame; this.bookmarkFile = Path.Combine(Path.GetDirectoryName(barItemFile), Path.GetFileNameWithoutExtension(barItemFile) + ".bmk"); this.bookMark = new BookmarkFile(bookmarkFile, bookmarkTimeFrame); Initialize(); }
public StrategyCache(object signalInstance, Guid cacheId) : base(CacheModeOption.Write) { this.barType = ((IStrategy)signalInstance).BarType; this.identityCode = ((IStrategy)signalInstance).IdentityCode; this.cacheId = cacheId; this.signalInstance = signalInstance; this.cacheMode = CacheModeOption.Write; }
public BollingerTopsAndBottoms(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); sma = new SMA(barType, 30); Register(sma); }
public EMABreakthrough(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); ema = new EMA(barType, 50); Register(ema); }
public MultiIndicator(string displayName, string shortName, string description, BarItemType barItemType) : base(new DateTimeKeyedMultiIndicator(), 300) { this.displayName = displayName; this.shortName = shortName; this.description = description; this.barItemType = barItemType; dependencies = new Dictionary <string, CalculationDependencyItem>(); }
public StochasticLinesCrossover(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); stoch = new Stochastics(barType, 14, 3, 3); Register(stoch); }
public WhiteSoldiersBlackCrows(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); bb = new BollingerBands(barType, 20); Register(bb); }
public StupidGuySystem(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); macd = new MACD(barType, 35, 45, 30); Register(macd); }
public NewYorkBreakout(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); sma = new SMA(barType, 30); Register(sma); }
public RSIHighLow(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); rsi = new RSI(barType, 14); Register(rsi); }
public H4BollingerBandStrategy(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); bb = new BollingerBands(barType, 20); Register(bb); }
public SwingRSIandMACd(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); sma = new SMA(barType, 30); Register(sma); }
public SimpleSteppingIntoPosition(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); sma = new SMA(barType, 30); Register(sma); }
public TradingOffDailyChart(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); sma = new SMA(barType, 30); Register(sma); }