//-------------------------------------- protected override void Initialize() { _marketDepth = MarketData.GetMarketDepth(Symbol); _marketDepth.Updated += MarketDepthUpdated; foreach (var entry in _marketDepth.BidEntries) { PreviousBidList.Add(new Previouslist { Preis = entry.Price, Volumen = entry.Volume }); } foreach (var entry in _marketDepth.AskEntries) { PreviousAskList.Add(new Previouslist { Preis = entry.Price, Volumen = entry.Volume }); } FilterM = Filter * 1000000; var Table = new StringBuilder(); Table.AppendLine("Bid\tTime\tMillion\t\tAsk\tTime\tMillion"); Table.AppendLine("(Buys)\tago\tUnits\t\t(Sells)\tago\tUnits"); Table.AppendLine("----------------------------------------------------------------------------------"); ChartObjects.DrawText("Header", Table.ToString(), StaticPosition.TopLeft, (Colors)Enum.Parse(typeof(Colors), TextColor, true)); Timer.Start(UpdateFrequency); }
protected override void Initialize() { old_index = MarketSeries.Close.Count - 1; Symbol_PointSize = Symbol.PointSize; _MarketDepth = MarketData.GetMarketDepth(Symbol); _MarketDepth.Updated += OnUpdated; }
protected override void Initialize() { //Global Init for (var s = 0; s < array_value_index; s++) { aVolume[s] = 0; } today_bid = Symbol.Bid; old_askbid_middle = ((Symbol.Ask + Symbol.Bid) / 2); _marketDepth = MarketData.GetMarketDepth(Symbol); index = MarketSeries.Close.Count - 1; old_day = MarketSeries.OpenTime[index].DayOfYear; start_time = MarketSeries.OpenTime[index].Year * MarketSeries.OpenTime[index].Day * MarketSeries.OpenTime[index].Hour * MarketSeries.OpenTime[index].Millisecond; //Cycle _marketDepth.Updated += Calc_And_Show_Chart; }
/// <summary> /// CALLED WHEN THE ROBOT FIRST STARTS, IT IS ONLY CALLED ONCE. /// </summary> protected override void OnStart() { // CONSTRUCT THE INDICATORS _rsi = Indicators.RelativeStrengthIndex(RSISource, RSIPeriod); _smaHIGH = Indicators.SimpleMovingAverage(HighSMASource, HighSMAPeriod); _smaLOW = Indicators.SimpleMovingAverage(LowSMASource, LowSMAPeriod); _mom = Indicators.MomentumOscillator(MOMSource, MOMPeriod); _atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Simple); _md = MarketData.GetMarketDepth(Symbol); _rvi = Indicators.GetIndicator <RelativeVigorIndex>(RVIPeriod, MovingAverageType.Simple); tm = new TradeManager(this); }
protected override void Initialize() { if (Price == 0) { MarketData.GetMarketDepth(Symbol).Updated += AnimateWarning; } if (BidOrAsk == 1) { spotPriceWasAbove = Symbol.Bid > Price; } else { spotPriceWasAbove = Symbol.Ask > Price; } if (NotificationWasPlayed()) { triggered = true; } }
protected override void OnTick() { var sa = new System.Collections.Generic.List <string>(); var barTime = MarketSeries.OpenTime.LastValue; var timestr = barTime.ToString("yyyy-MM-dd HH:mm:ss.fff"); MarketDepth mkdepth = MarketData.GetMarketDepth(Symbol.Code); var volAdjAsk = vol_weighted_price(mkdepth.AskEntries); var volAdjBid = vol_weighted_price(mkdepth.BidEntries); var volAdjSpread = volAdjAsk - volAdjBid; var volCntAsk = vol_weighted_cnt(mkdepth.AskEntries) / 100000.0; var volCntBid = vol_weighted_cnt(mkdepth.BidEntries) / 100000.0; var vonCntBuyVsSell = volCntAsk - volCntBid; if ((volAdjAsk == 0.0) && (volAdjBid == 0.0)) { return; } sa.Add(timestr); sa.Add(Symbol.Ask.ToString("F6")); sa.Add(Symbol.Bid.ToString("F6")); sa.Add(Symbol.Spread.ToString("F6")); sa.Add(mkdepth.AskEntries.Count.ToString("F2")); sa.Add(mkdepth.BidEntries.Count.ToString("F2")); sa.Add(volAdjAsk.ToString("F6")); sa.Add(volAdjBid.ToString("F6")); sa.Add(volAdjSpread.ToString("F6")); sa.Add(volCntAsk.ToString("F2")); sa.Add(volCntBid.ToString("F2")); sa.Add(vonCntBuyVsSell.ToString("F2")); var sout = string.Join(",", sa); //System.IO.File.AppendAllText(fiName, sout); fwriter.WriteLine(sout); fwriter.Flush(); }
// MOST RELEVANT ELEMENTS/CLASSES ========================== public void Elements() { //Symbol var symbol = Symbol; Print("Prices of {0}: Ask {1}, Bid {2}", symbol.Name, symbol.Ask, symbol.Bid); Print("Volume: Step {0}, Min {1}, Max {2}", symbol.VolumeInUnitsStep, symbol.VolumeInUnitsMin, symbol.VolumeInUnitsMax); //Timeframe var currentTimeFrame = TimeFrame; var someTimeFrame = TimeFrame.Daily; //MarketData var mktDepth = MarketData.GetMarketDepth(symbol.Name); var mktSeries = MarketData.GetSeries(symbol.Name, currentTimeFrame); Print("Last Close: {0}", mktSeries.Close.LastValue); Print("Last Open: {0}", mktSeries.Open.LastValue); Print("Last High: {0}", mktSeries.High.LastValue); Print("Last Low: {0}", mktSeries.Low.LastValue); //Technical Indicators var rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14); var bollinger = Indicators.BollingerBands(MarketSeries.Close, 20, 2, MovingAverageType.Simple); //Execution //var executeMarketO = ExecuteMarketOrder(TradeType.Buy, symbol.Name, symbol.VolumeInUnitsMin); //var executeMarketO = PlaceLimitOrder(TradeType.Buy, symbol.Name, symbol.VolumeInUnitsMin, 1.3500); //Position var positions = Positions; foreach (var position in Positions) { Print("Position {0} of {1}: Pips: {2}, NetProfit: {3}, Label: {4}", position.Id, position.EntryTime, position.Pips, position.NetProfit, position.Label); } }
protected override void Initialize() { _MarketDepth = MarketData.GetMarketDepth(Symbol); _MarketDepth.Updated += OnUpdated; }
protected override void Initialize() { GBPUSD = MarketData.GetMarketDepth(Symbol); GBPUSD.Updated += OnGbpUsdUpdated; }
//-------------------------------------- protected override void Initialize() { _marketDepth = MarketData.GetMarketDepth(Symbol); _marketDepth.Updated += MarketDepthUpdated; BidVolume = CreateDataSeries(); AskVolume = CreateDataSeries(); zigzag = Indicators.GetIndicator <ZigZag>(Depth, Deviation, BackStep); foreach (var entry in _marketDepth.BidEntries) { PreviousBidList.Add(new Previouslist { Preis = entry.Price, Volumen = entry.Volume }); } foreach (var entry in _marketDepth.AskEntries) { PreviousAskList.Add(new Previouslist { Preis = entry.Price, Volumen = entry.Volume }); } LowFilterM = LowFilter * 1000000; HighFilterM = HighFilter * 1000000; fname = string.Format("{0}{1}{2}{3}", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "\\", FileName == "" ? Symbol.Code : FileName, ".csv"); if (ReadFromFile && System.IO.File.Exists(fname) == true) { using (StreamReader Fstream = new StreamReader(fname)) { string line; while ((line = Fstream.ReadLine()) != null) { try { string[] words = line.Split(Delimiters); double vol = Convert.ToDouble(words[1]); if (vol >= HighFilterM || vol < LowFilterM) { continue; } int bago = BarsAgo(Convert.ToDateTime(words[0])); if (bago == -1) { continue; } int bidx = MarketSeries.Close.Count - 1 - bago; if (double.IsNaN(AskVolume[bidx])) { AskVolume[bidx] = 0; } if (double.IsNaN(BidVolume[bidx])) { BidVolume[bidx] = 0; } switch (words[2]) { case "A": AskVolume[bidx] += (vol / 1000000); break; case "B": BidVolume[bidx] -= (vol / 1000000); break; } } catch { continue; } } } } if (WriteToFile) { if (System.IO.File.Exists(fname) == false) { System.IO.File.WriteAllText(fname, ""); } Timer.Start(WriteInterval); } }
protected override void OnStart() { MarketData.GetMarketDepth(Symbol).Updated += MarketDepth_Updated; }