public List<Candle> GetHistory(string symbol, TimeFrame timeFrame) { List<Candle> list = new List<Candle>(); try { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(string.Format("http://balancer.netdania.com/StreamingServer/StreamingServer?xml=chart&group={0}&pass={1}&source=netdania_fxa&symbol={2}&fields=101|102|103|104|&time=dd MMM yyyy HH:mm:ss&max=200&scale={3}&tzone=GMT", (object)this._username, (object)this._password, (object)symbol, (object)TimeFrameConverter.ToMinutes(timeFrame))); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(httpWebRequest.GetResponse().GetResponseStream()); XmlNodeList xmlNodeList = xmlDocument.SelectNodes("//point"); if (xmlNodeList != null) { foreach (XmlLinkedNode xmlLinkedNode in xmlNodeList) { if (xmlLinkedNode.Attributes != null) list.Add(new Candle(double.Parse(xmlLinkedNode.Attributes["f101"].Value, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture), double.Parse(xmlLinkedNode.Attributes["f102"].Value, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture), double.Parse(xmlLinkedNode.Attributes["f103"].Value, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture), double.Parse(xmlLinkedNode.Attributes["f104"].Value, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture), DateTime.Parse(xmlLinkedNode.InnerText, (IFormatProvider)CultureInfo.InvariantCulture))); } } } catch (Exception ex) { if (!this._isInvalidLogin) { if (ex.Message.ToLower().Contains("forbidden")) this.ShowInvalidAccountDataMessage(); } } return list; }
public Project(ResearchSet rs = ResearchSet.Theme1, int pc = 1, TimeFrame tf = TimeFrame.Long) { ResearchSet = rs; ParticipantsCount = pc; TimeFrame = tf; }
public PriceDataService(Instrument instrument, TimeFrame timeframe, DateTime startDate, DateTime endDate) { _instrument = instrument; _timeframe = timeframe; _startDate = startDate; _endDate = endDate; }
public StatsFilter(Guid? deck, StatsRegion region, GameMode mode, TimeFrame time) { Deck = deck; Region = region; Mode = mode; TimeFrame = time; }
public ResearchTeam(string myTheme, string myOrganization, int myNumber, TimeFrame myDuration, Paper[] myPaper) { theme = myTheme; organization = myOrganization; number = myNumber; duration = myDuration; paper = myPaper; }
public ExpertScript(string filename, string pair, TimeFrame timeFrame) : base(pair, timeFrame) { this.filename = filename; Log.info("filename=" + filename + ", pair=" + pair + ", timeFrame=" + ExpertFactory.timeFrameMap[timeFrame]); m_engine = Python.CreateEngine(); m_scope = m_engine.CreateScope(); }
public override void timeUpdate(TimeFrame timeFrame) { //if (timeFrame != TimeFrame.m5) // return; double last = getLast(timeFrame, PriceComponent.BidClose); //log.debug("timeUpdate() Last=" + last); // note m15 timeframe for EMA double ema = getEMA(TimeFrame.m15, PriceComponent.BidClose, emaPeriods); //log.debug("timeUpdate() EMA=" + ema); // note m15 timeframe for RSI double rsi = getRSI(TimeFrame.m15, PriceComponent.BidClose, rsiPeriods); //log.debug("timeUpdate() RSI=" + rsi); double[] stoch = getStoch(timeFrame, PriceComponent.BidClose, stochPeriods); double k = stoch[0]; double d = stoch[1]; //log.debug("timeUpdate() SSD, K=" + k + ", D=" + d); double diMinus = getMinusDI(timeFrame, adxPeriods); double diPlus = getPlusDI(timeFrame, adxPeriods); double adx = getADX(TimeFrame.m1, PriceComponent.BidHigh, PriceComponent.BidLow, PriceComponent.BidClose, adxPeriods); double lastBid = getLast(timeFrame, PriceComponent.BidClose); double lastAsk = getLast(timeFrame, PriceComponent.AskClose); if (!InPosition && ema > 0) { if (rsi != 0.0 && rsi > RSIThresholdOverBought // in m15 overbought context && last > ema // in m15 time && adx != 0.0 && adx > ADXThreshold // trending at m1 && diMinus > diPlus // trending is a pullback at m1 && k > d // reverse of pullback signal at m1 ) // in bull context, reverse ends in bounce { string entry = "BUY"; Factory.Display.appendLine(String.Format("Open, {0}, {1}, price={2}", entry, Pair, lastAsk)); enterPosition(entry, amount, lastAsk, stopPips, limitPips); } else if (rsi != 0.0 && rsi < RSIThresholdOverSold && last < ema && adx != 0.0 && adx > ADXThreshold && diMinus < diPlus && k < d // reverse signal ) // in bear context, reverse ends in bounce { string entry = "SELL"; Factory.Display.appendLine(String.Format("Open, {0}, {1}, price={2}", entry, Pair, lastBid)); enterPosition(entry, amount, lastBid, stopPips, limitPips); } } }
/// <summary>Creates a new <see cref="ActualChargeStep"/> instance based on an existing charge step.</summary> public ActualChargeStep(ChargeStep step) : base(step.MaximumEnergy) { StepNumber = step.StepNumber; EnergyFrame = new EnergyFrame(step.EnergyFrame.From, step.EnergyFrame.From); TimeFrame = new TimeFrame(step.TimeFrame.From, step.TimeFrame.From); MaxCurrent = step.MaxCurrent; Priority = step.Priority; Strategy = step.Strategy; State = step.State; }
public TimeFrameEditor(TimeFrame timeFrame) : this() { if (timeFrame == null) throw new ArgumentNullException(nameof(timeFrame)); DateTimePicker.Value = timeFrame.Start; NumericUpDownHours.Value = (int)timeFrame.Duration.TotalHours; NumericUpDownMinutes.Value = timeFrame.Duration.Seconds; }
public DataView(TimeFrame timeframe, IDataController controller) { Timeframe = timeframe; _controller = controller; _dataItems = new List<IDataItem>(); _movingAverageCollections = new Dictionary<int, List<double>>(); //_trendItems = new List<ITrendItem>(); _trendItems = new List<int>(); }
public ResourceInstanceReservation (int resourceInstanceID, IResource resource, IActivitySchedule activitySchedule, TimeFrame scheduledStart, TimeFrame scheduledFinish) { ResourceInstanceID = resourceInstanceID; Resource = resource; ActivitySchedule = activitySchedule; ScheduledStart = scheduledStart; ScheduledFinish = scheduledFinish; }
private TimeFrame[] DeserializeIntervals(XmlReader reader) { var timesCount = reader.ReadElementContentAsInt(nameof(AttendedTimesCount), string.Empty); var timesArray = new TimeFrame[timesCount]; var timeFrameSerializer = new XmlSerializer(typeof(TimeFrame)); for (int i = 0; i < timesArray.Length; i++) { var interval = (TimeFrame)timeFrameSerializer.Deserialize(reader); timesArray[i] = interval; } return timesArray; }
public ExpertScript(string filename, string pair, TimeFrame timeFrame, bool debug) : base(pair, timeFrame) { this.filename = filename; Log.info("debug=" + debug + ", filename=" + filename + ", pair=" + pair + ", timeFrame=" + ExpertFactory.timeFrameMap[timeFrame]); var options = new Dictionary<string, object>(); options["Debug"] = debug ? ScriptingRuntimeHelpers.True : ScriptingRuntimeHelpers.False; m_engine = Python.CreateEngine(options); m_scope = m_engine.CreateScope(); }
private MergedBusinessDay(DateTime date, string[] documents, TimeFrame[][] attendedTimes) { if (documents == null) throw new ArgumentNullException(nameof(documents)); if (attendedTimes == null) throw new ArgumentNullException(nameof(attendedTimes)); if (documents.Length != attendedTimes.GetLength(0)) throw new ArgumentException($"The dimensions of {nameof(documents)} and {nameof(attendedTimes)} don't match."); this.documents = documents; this.attendedTimes = attendedTimes; Date = date.Date; }
protected override void Initialize() { if (TimeFrame <= TimeFrame.Hour) PivotTimeFrame = TimeFrame.Daily; else if (TimeFrame < TimeFrame.Daily) { PivotTimeFrame = TimeFrame.Weekly; } else PivotTimeFrame = TimeFrame.Monthly; Enum.TryParse(PivotColor, out pivotColor); Enum.TryParse(SupportColor, out supportColor); Enum.TryParse(ResistanceColor, out resistanceColor); }
public CashFlow(HtmlNodeCollection htmlNodeCollection, TimeFrame timeFrame) { this.TimeFrame = timeFrame; this.htmlNodeCollection = htmlNodeCollection; if (this.TimeFrame == TimeFrame.annual) { ParseCashFlowAnnual(); // TODO: Remove this function, it was only created for debugging code. //DumpCashFlowValuesDatabase(); } else { } }
public static int Duration(TimeFrame timeframe) { switch (timeframe) { case TimeFrame.M01 : return 1; case TimeFrame.M05 : return 5; case TimeFrame.M15 : return 15; case TimeFrame.M30 : return 30; case TimeFrame.H01 : return 60; case TimeFrame.D01 : return 24 * 60; case TimeFrame.Week: return 7 * 24 * 60; case TimeFrame.Month: return 30 * 24 * 60; case TimeFrame.NotSet: default : throw new ArgumentOutOfRangeException(); } }
private void SaveBusinessDay(BusinessDayIdentifier identifier) { if (identifier == null) throw new ArgumentNullException(nameof(identifier)); // Fetches the identifiers of all BusinessDayMk2 created for the same as the one we are going to create var sameDay = BusinessDayRepository.Identifiers.Where(i => i.DateTime.Date.Equals(identifier.DateTime.Date)).ToList(); // Creates and stores the BusinessDayMk2 var attendedTime = new TimeFrame(identifier.DateTime, new TimeSpan(0, 40, 0)); var people = AttendanceView.GetCollection(); var attendances = people.Select(p => new AttendanceMk2(p.Identifier, new TimeFrame[] { attendedTime })); var businessDay = new BusinessDayMk2(identifier, attendances); BusinessDayRepository.Save(businessDay); // Removed all other businessdays created for the same date foreach (var date in sameDay) BusinessDayRepository.Delete(date); }
// EUR/USD, "m1", public void getHistory(string pair, TimeFrame timeframe, int bars) { O2GRequestFactory requestFactory = null; if (debugRead) return; responseListener = new HistoryResponseListener(mSession, display); try { mSession.subscribeResponse(responseListener); requestFactory = mSession.getRequestFactory(); O2GTimeframeCollection timeframes = requestFactory.Timeframes; O2GTimeframe tfo = timeframes[ExpertFactory.timeFrameMap[timeframe]]; O2GRequest request = requestFactory.createMarketDataSnapshotRequestInstrument(pair, tfo, bars); requestFactory.fillMarketDataSnapshotRequestTime(request, requestFactory.ZERODATE, requestFactory.ZERODATE, false); CtrlTimer.getInstance().startTimer("HistoryRequest"); mSession.sendRequest(request); responseListener.manualEvent.WaitOne(); if (!responseListener.Error) { //log.debug("You have successfully retrieved history for " + pair ); //log.debug("OrderID=" + responseListener.OrderId); } else log.debug("Your request failed to retrieve data for " + pair ); } catch (Exception e) { log.debug("getHistory(), exception: "+ e.Message ); if (requestFactory != null) log.debug("last error = " + requestFactory.getLastError()); else log.debug("requestFactory is null"); throw new Exception("Problem with getHistory()"); } finally { mSession.unsubscribeResponse(responseListener); } }
public static DateTime Start(TimeFrame timeframe, DateTime firstSession) { DateTime start; switch (timeframe) { case TimeFrame.M01: case TimeFrame.M05: case TimeFrame.M15: case TimeFrame.M30: case TimeFrame.H01: { start = firstSession.AddMinutes(-(firstSession.Minute % Duration(timeframe))); start = start.AddSeconds(-start.Second); start = start.AddMilliseconds(-start.Millisecond); } break; case TimeFrame.D01: { start = firstSession.Subtract(firstSession.TimeOfDay); } break; case TimeFrame.Week: { start = firstSession.AddDays(- (6 + (int)firstSession.DayOfWeek) % 7); start = start.Subtract(start.TimeOfDay); } break; case TimeFrame.Month: { start = firstSession.AddDays(-firstSession.Day + 1); start = start.Subtract(start.TimeOfDay); } break; case TimeFrame.NotSet: default: throw new ArgumentOutOfRangeException(); } return start; }
public override void timeUpdate(TimeFrame timeFrame) { //if (timeFrame != TimeFrame.m15) // return; double lastBid = getLast(timeFrame, PriceComponent.BidClose); double lastAsk = getLast(timeFrame, PriceComponent.AskClose); double ema = getEMA(timeFrame, PriceComponent.BidClose, emaPeriods); double[] macdArray = getMACD(timeFrame, PriceComponent.BidClose, macdShort, macdLong, macdSignal); double macd = macdArray[0]; double signal = macdArray[1]; if (!InPosition && ema > 0) { if (macd < signal && macdPrev > signalPrev && macd > 0 && signal > 0 && lastBid < ema) { string entry = "SELL"; Factory.Display.appendLine(String.Format("Open, {0}, {1}, price={2}", entry, Pair, lastBid)); enterPosition(entry, amount, lastBid, stopPips, false, limitPips); } else if (macd > signal && macdPrev < signalPrev && macd < 0 && signal < 0 && lastAsk > ema) { string entry = "BUY"; Factory.Display.appendLine(String.Format("Open, {0}, {1}, price={2}", entry, Pair, lastAsk)); enterPosition(entry, amount, lastAsk, stopPips, false, limitPips); } } macdPrev = macd; signalPrev = signal; }
public static string GetEnumAsString(TimeFrame a) { switch (a) { case TimeFrame.Unknown: return "Unknown"; break; case TimeFrame.Today: return "Today"; break; case TimeFrame.Tomorrow: return "Tomorrow"; break; case TimeFrame.Later: return "Later"; break; case TimeFrame.Overdue: return "Overdue"; break; } return "unknown"; }
/// <summary> /// Gets the number of days in the time frame specified based on the date /// </summary> /// <param name="Date">Date</param> /// <param name="TimeFrame">Time frame to calculate the number of days from</param> /// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param> /// <returns>The number of days in the time frame</returns> public static int DaysIn(this DateTime Date, TimeFrame TimeFrame, CultureInfo Culture = null) { Culture = Culture.Check(CultureInfo.CurrentCulture); if (TimeFrame == TimeFrame.Day) return 1; if (TimeFrame == TimeFrame.Week) return 7; if (TimeFrame == TimeFrame.Month) return Culture.Calendar.GetDaysInMonth(Date.Year, Date.Month); if (TimeFrame == TimeFrame.Quarter) return Date.EndOf(TimeFrame.Quarter, Culture).DayOfYear - Date.BeginningOf(TimeFrame.Quarter, Culture).DayOfYear; return Culture.Calendar.GetDaysInYear(Date.Year); }
/// <summary> /// Synchronized version of the <see cref="GetCandlesAsync"/> method /// </summary> /// <returns></returns> public CallResult <BitfinexCandle[]> GetCandles(TimeFrame timeFrame, string symbol, int?limit = null, DateTime?startTime = null, DateTime?endTime = null, Sorting?sorting = null) => GetCandlesAsync(timeFrame, symbol, limit, startTime, endTime, sorting).Result;
public IndicatorMarketSeries(TimeFrame timeFrame, string symbolName, Algo algo) : this(timeFrame, symbolName, new IndicatorTimeSeries(), algo) { }
public GameFilter(Guid?deck, Region region, GameMode mode, TimeFrame time, GameFormat format, PlayerClass pClass, PlayerClass oClass, int rankLo, int rankHi) : this(deck, region, mode, time, format, pClass, oClass) { Rank = new Tuple <int, int>(rankLo, rankHi); }
/// <summary> /// Synchronized version of the <see cref="GetLastCandleAsync"/> method /// </summary> /// <returns></returns> public CallResult <BitfinexCandle> GetLastCandle(TimeFrame timeFrame, string symbol) => GetLastCandleAsync(timeFrame, symbol).Result;
public bool IsWithin(TimeFrame frame) { return(this <= frame.end && this >= frame.start); }
public MainPageViewModel() { ChartTimeFrame = Enum.GetValues(typeof(TimeFrame)).Cast <TimeFrame>().ToList(); SelectedChartTimeFrame = TimeFrame.Month3; }
public static void ShowPopup(this INotifications notifications, TimeFrame timeFrame, Symbol symbol, string type, string triggeredBy, double price) { ShowPopup(notifications, timeFrame, symbol, type, triggeredBy, price, string.Empty); }
/// <summary> /// Gets the number of days left in the time frame specified based on the date /// </summary> /// <param name="Date">Date</param> /// <param name="TimeFrame">Time frame to calculate the number of days left</param> /// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param> /// <param name="StartOfQuarter1">Start of the first quarter</param> /// <returns>The number of days left in the time frame</returns> public static int DaysLeftIn(this DateTime Date, TimeFrame TimeFrame, DateTime StartOfQuarter1, CultureInfo Culture = null) { if (TimeFrame != TimeFrame.Quarter) return Date.DaysLeftIn(TimeFrame, Culture); Culture = Culture.Check(CultureInfo.CurrentCulture); return Date.DaysIn(TimeFrame.Quarter, StartOfQuarter1, Culture) - (Date.DayOfYear - StartOfQuarter1.DayOfYear); }
public static void ShowPopup(this INotifications notifications, TimeFrame timeFrame, Symbol symbol, string type) { ShowPopup(notifications, timeFrame, symbol, type, string.Empty); }
public static void ShowPopup(this INotifications notifications, TimeFrame timeFrame, Symbol symbol, string type, string triggeredBy) { ShowPopup(notifications, timeFrame, symbol, type, triggeredBy, symbol.Bid); }
public IList <Coin> HydrateCoinsWithPrices(TimeFrame timeFrame) { return(new List <Coin>()); }
public TimeFrameMenuItem(TimeFrame tf) : base(tf.Name) { _tf = tf; }
private int _getTimeFrameCandleInMinutes(TimeFrame MyCandle) { if (MyCandle == TimeFrame.Daily) { return(60 * 24); } if (MyCandle == TimeFrame.Day2) { return(60 * 24 * 2); } if (MyCandle == TimeFrame.Day3) { return(60 * 24 * 3); } if (MyCandle == TimeFrame.Hour) { return(60); } if (MyCandle == TimeFrame.Hour12) { return(60 * 12); } if (MyCandle == TimeFrame.Hour2) { return(60 * 2); } if (MyCandle == TimeFrame.Hour3) { return(60 * 3); } if (MyCandle == TimeFrame.Hour4) { return(60 * 4); } if (MyCandle == TimeFrame.Hour6) { return(60 * 6); } if (MyCandle == TimeFrame.Hour8) { return(60 * 8); } if (MyCandle == TimeFrame.Minute) { return(1); } if (MyCandle == TimeFrame.Minute10) { return(10); } if (MyCandle == TimeFrame.Minute15) { return(15); } if (MyCandle == TimeFrame.Minute2) { return(2); } if (MyCandle == TimeFrame.Minute20) { return(20); } if (MyCandle == TimeFrame.Minute3) { return(3); } if (MyCandle == TimeFrame.Minute30) { return(30); } if (MyCandle == TimeFrame.Minute4) { return(4); } if (MyCandle == TimeFrame.Minute45) { return(45); } if (MyCandle == TimeFrame.Minute5) { return(5); } if (MyCandle == TimeFrame.Minute6) { return(6); } if (MyCandle == TimeFrame.Minute7) { return(7); } if (MyCandle == TimeFrame.Minute8) { return(8); } if (MyCandle == TimeFrame.Minute9) { return(9); } if (MyCandle == TimeFrame.Monthly) { return(60 * 24 * 30); } if (MyCandle == TimeFrame.Weekly) { return(60 * 24 * 7); } return(0); }
protected override void OnStart() { _botName = ToString(); _instanceLabel = string.Format("{0}-{1}-{2}-{3}-{4}", _botName, _botVersion, Symbol.Code, TimeFrame.ToString(), GlobalTimeFrame.ToString()); tendency = Indicators.GetIndicator <CandlestickTendencyII>(GlobalTimeFrame, MinimumGlobalCandleSize); _macd = Indicators.MacdHistogram(LongCycle, ShortCycle, Period); _emaFast = Indicators.ExponentialMovingAverage(Price, FastPeriods); _adx = Indicators.GetIndicator <ADXR>(Source, interval); _cci = Indicators.GetIndicator <CCI>(CCI_period); _heiken = Indicators.GetIndicator <HeikenAshi2>(1); _emasignal = Indicators.GetIndicator <ExponentialSignal>(20); }
/// <summary> /// End of a specific time frame /// </summary> /// <param name="Date">Date to base off of</param> /// <param name="TimeFrame">Time frame to use</param> /// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param> /// <param name="StartOfQuarter1">Start of the first quarter</param> /// <returns>The end of a specific time frame (TimeFrame.Day is the only one that sets the time to 12:59:59 PM, all else are the beginning of the day)</returns> public static DateTime EndOf(this DateTime Date, TimeFrame TimeFrame, DateTime StartOfQuarter1, CultureInfo Culture = null) { if (TimeFrame != TimeFrame.Quarter) return Date.EndOf(TimeFrame, Culture); Culture = Culture.Check(CultureInfo.CurrentCulture); if (Date.Between(StartOfQuarter1, StartOfQuarter1.AddMonths(3).AddDays(-1).EndOf(TimeFrame.Day, Culture))) return StartOfQuarter1.AddMonths(3).AddDays(-1).Date; else if (Date.Between(StartOfQuarter1.AddMonths(3), StartOfQuarter1.AddMonths(6).AddDays(-1).EndOf(TimeFrame.Day, Culture))) return StartOfQuarter1.AddMonths(6).AddDays(-1).Date; else if (Date.Between(StartOfQuarter1.AddMonths(6), StartOfQuarter1.AddMonths(9).AddDays(-1).EndOf(TimeFrame.Day, Culture))) return StartOfQuarter1.AddMonths(9).AddDays(-1).Date; return StartOfQuarter1.AddYears(1).AddDays(-1).Date; }
public bool IsAfter(TimeFrame frame) { return(this > frame.end); }
public static string GetSeriesKey(this string symbol, TimeFrame timeFrame) { return(symbol + Delimiter.ToString() + timeFrame.Name); }
/// <summary> /// Subscribes to candle updates for a symbol. Requires socket to be connected /// </summary> /// <param name="symbol">The symbol to subscribe to</param> /// <param name="interval">The interval of the candles</param> /// <param name="handler">The handler for the data</param> /// <returns>A stream id with which can be unsubscribed</returns> public async Task <CallResult <int> > SubscribeToCandles(string symbol, TimeFrame interval, Action <BitfinexCandle[]> handler) { log.Write(LogVerbosity.Debug, "Subscribing to candle updates for " + symbol); return(await SubscribeAndWait(new CandleSubscriptionRequest(symbol, JsonConvert.SerializeObject(interval, new TimeFrameConverter(false)), handler)).ConfigureAwait(false)); }
/// <summary> /// Selects the games played during a specific timeframe /// (Stolen from Epix'37 twitch chat plugin) /// </summary> public static Func<GameStats, bool> TimeFrameFilter(TimeFrame timeFrame) { switch (timeFrame) { case TimeFrame.today: return game => game.StartTime.Date == DateTime.Today; case TimeFrame.week: return game => game.StartTime > DateTime.Today.AddDays(-7); case TimeFrame.season: return game => game.StartTime.Date.Year == DateTime.Today.Year && game.StartTime.Date.Month == DateTime.Today.Month; case TimeFrame.total: return game => true; default: return game => false; } }
/// <summary> /// Convert a TimeFrame into TimeRange with a Start and End /// </summary> /// <param name="time">A TimeFrame</param> /// <param name="now">An optional string representing the current date/time (default: DateTime.Now)</param> /// <returns></returns> public static TimeRange ConvertTimeFrameToRange(TimeFrame time, string now = null) { DateTime current; try { current = DateTime.Parse(now); } catch (Exception) { // Exception means null or failed to parse, ok to use default current = DateTime.Now; } var startTime = new DateTime(current.Year, current.Month, current.Day, 0, 0, 0); var endTime = current; switch (time) { case TimeFrame.YESTERDAY: startTime -= new TimeSpan(1, 0, 0, 0); endTime = new DateTime(current.Year, current.Month, current.Day, 23, 59, 59) - new TimeSpan(1, 0, 0, 0); break; case TimeFrame.LAST_24_HOURS: startTime = current - new TimeSpan(1, 0, 0, 0); endTime = current; break; case TimeFrame.THIS_WEEK: startTime -= new TimeSpan(((int)(current.DayOfWeek) - 1), 0, 0, 0); endTime = current; break; case TimeFrame.PREVIOUS_WEEK: startTime -= new TimeSpan(7 + ((int)(current.DayOfWeek) - 1), 0, 0, 0); endTime = startTime + new TimeSpan(6, 23, 59, 59); break; case TimeFrame.LAST_7_DAYS: startTime = current - new TimeSpan(7, 0, 0, 0); endTime = current; break; case TimeFrame.THIS_MONTH: startTime -= new TimeSpan(current.Day - 1, 0, 0, 0); endTime = current; break; case TimeFrame.PREVIOUS_MONTH: var prevMonth = current.AddMonths(-1); var daysInMonth = DateTime.DaysInMonth(prevMonth.Year, prevMonth.Month); startTime -= new TimeSpan(current.Day - 1 + daysInMonth, 0, 0, 0); endTime = startTime + new TimeSpan(daysInMonth - 1, 23, 59, 59); break; case TimeFrame.THIS_YEAR: startTime -= new TimeSpan(current.DayOfYear - 1, 0, 0, 0); endTime = current; break; case TimeFrame.PREVIOUS_YEAR: startTime = new DateTime(current.Year - 1, 1, 1, 0, 0, 0); endTime = new DateTime(current.Year - 1, 12, 31, 23, 59, 59); break; case TimeFrame.ALL: endTime = current; startTime = DateTime.MinValue; break; case TimeFrame.TODAY: default: // use defaults break; } return(new TimeRange(startTime, endTime)); }
public BitfinexApiResult <BitfinexCandle> GetLastCandle(TimeFrame timeFrame, string symbol, int?limit = null, DateTime?startTime = null, DateTime?endTime = null, Sorting?sorting = null) => GetLastCandleAsync(timeFrame, symbol, limit, startTime, endTime, sorting).Result;
public PriceSeries GetPriceData(string dataset, TimeFrame timeFrame) { return(GetPriceData(string.Format("{0}_{1}", dataset, timeFrame))); }
/// <summary> /// instrument history query /// запрос истории по инструменту /// </summary> public List <Candle> GetCandleHistory(string nameSec, TimeFrame tf) { return(((InteractiveBrokersServerRealization)ServerRealization).GetCandleHistory(nameSec, tf)); }
/// <summary> /// Get the last candle for a symbol /// </summary> /// <param name="timeFrame">The timeframe of the candle</param> /// <param name="symbol">The symbol to get the candle for</param> /// <returns>The last candle for the symbol</returns> public async Task <CallResult <BitfinexCandle> > GetLastCandleAsync(TimeFrame timeFrame, string symbol) { var endpoint = FillPathParameter(LastCandleEndpoint, JsonConvert.SerializeObject(timeFrame, new TimeFrameConverter(false)), symbol); return(await ExecuteRequest <BitfinexCandle>(GetUrl(endpoint, ApiVersion2))); }
/// <summary> /// request instrument history /// запрос истории по инструменту /// </summary> public List <Candle> GetCandleHistory(string nameSec, TimeFrame tf) { SecurityIb contractIb = _secIB.Find( contract => contract.Symbol + "_" + contract.SecType + "_" + contract.Exchange == nameSec); if (contractIb == null) { return(null);; } DateTime timeEnd = DateTime.Now.ToUniversalTime(); DateTime timeStart = timeEnd.AddMinutes(60); string barSize = "1 min"; int mergeCount = 0; if (tf == TimeFrame.Sec1) { barSize = "1 sec"; timeStart = timeEnd.AddMinutes(10); } else if (tf == TimeFrame.Sec5) { barSize = "5 secs"; } else if (tf == TimeFrame.Sec15) { barSize = "15 secs"; } else if (tf == TimeFrame.Sec30) { barSize = "30 secs"; } else if (tf == TimeFrame.Min1) { timeStart = timeEnd.AddHours(5); barSize = "1 min"; } else if (tf == TimeFrame.Min5) { timeStart = timeEnd.AddHours(25); barSize = "5 mins"; } else if (tf == TimeFrame.Min15) { timeStart = timeEnd.AddHours(75); barSize = "15 mins"; } else if (tf == TimeFrame.Min30) { timeStart = timeEnd.AddHours(150); barSize = "30 mins"; } else if (tf == TimeFrame.Hour1) { timeStart = timeEnd.AddHours(1300); barSize = "1 hour"; } else if (tf == TimeFrame.Hour2) { timeStart = timeEnd.AddHours(2100); barSize = "1 hour"; mergeCount = 2; } else if (tf == TimeFrame.Hour4) { timeStart = timeEnd.AddHours(4200); barSize = "1 hour"; mergeCount = 4; } else if (tf == TimeFrame.Day) { barSize = "1 day"; timeStart = timeEnd.AddDays(701); } else { return(null); } CandlesRequestResult = null; _client.GetCandles(contractIb, timeEnd, timeStart, barSize, "TRADES"); DateTime startSleep = DateTime.Now; while (true) { Thread.Sleep(1000); if (startSleep.AddSeconds(30) < DateTime.Now) { break; } if (CandlesRequestResult != null) { break; } } if (CandlesRequestResult != null && CandlesRequestResult.CandlesArray.Count != 0) { if (mergeCount != 0) { List <Candle> newCandles = Merge(CandlesRequestResult.CandlesArray, mergeCount); CandlesRequestResult.CandlesArray = newCandles; return(StraichCandles(CandlesRequestResult)); } return(StraichCandles(CandlesRequestResult)); } _client.GetCandles(contractIb, timeEnd, timeStart, barSize, "MIDPOINT"); startSleep = DateTime.Now; while (true) { Thread.Sleep(1000); if (startSleep.AddSeconds(30) < DateTime.Now) { break; } if (CandlesRequestResult != null) { break; } } if (CandlesRequestResult != null && CandlesRequestResult.CandlesArray.Count != 0) { if (mergeCount != 0) { List <Candle> newCandles = Merge(CandlesRequestResult.CandlesArray, mergeCount); CandlesRequestResult.CandlesArray = newCandles; return(StraichCandles(CandlesRequestResult)); } return(StraichCandles(CandlesRequestResult)); } return(null); }
public IndicatorView(TimeFrame timeFrame, Indicator indicator, FunctionViewInfo[] functionsView) { _indicator = indicator; _functions = functionsView; _timeFrame = timeFrame; }
protected override void OnStart() { ADXRSeries = MarketData.GetSeries(TimeFrame.Hour4); _botName = ToString(); _instanceLabel = string.Format("{0}-{1}-{2}-{3}-{4}", _botName, _botVersion, Symbol.Code, TimeFrame.ToString(), GlobalTimeFrame.ToString()); tendency = Indicators.GetIndicator <CandlestickTendencyII>(GlobalTimeFrame, MinimumGlobalCandleSize); tendency2 = Indicators.GetIndicator <CandlestickTendencyII_2>(GlobalTimeFrame2, MinimumGlobalCandleSize2); //_emaFast = Indicators.ExponentialMovingAverage(Price, FastPeriods); _adx = Indicators.GetIndicator <ADXRSignal>(Source, interval); _heiken = Indicators.GetIndicator <HeikenAshi2>(1); _kama = Indicators.GetIndicator <KAMASignal>(Source, Fast, Slow, Period); Fisher = Indicators.GetIndicator <FisherSignal>(Len); //COG = Indicators.GetIndicator<CenterOfGravityOscillator>(Length); pipsATR = Indicators.GetIndicator <PipsATRIndicator>(TimeFrame, AtrPeriod, AtrMaType); _onBalanceVolume = Indicators.OnBalanceVolume(Source); minPipsATR = pipsATR.Result.Minimum(pipsATR.Result.Count); maxPipsATR = pipsATR.Result.Maximum(pipsATR.Result.Count); }
/// <summary> /// Beginning of a specific time frame /// </summary> /// <param name="Date">Date to base off of</param> /// <param name="TimeFrame">Time frame to use</param> /// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param> /// <returns>The beginning of a specific time frame</returns> public static DateTime BeginningOf(this DateTime Date, TimeFrame TimeFrame, CultureInfo Culture = null) { Culture = Culture.Check(CultureInfo.CurrentCulture); if (TimeFrame == TimeFrame.Day) return Date.Date; if (TimeFrame == TimeFrame.Week) return Date.AddDays(Culture.DateTimeFormat.FirstDayOfWeek - Date.DayOfWeek).Date; if (TimeFrame == TimeFrame.Month) return new DateTime(Date.Year, Date.Month, 1); if (TimeFrame == TimeFrame.Quarter) return Date.BeginningOf(TimeFrame.Quarter, Date.BeginningOf(TimeFrame.Year, Culture), Culture); return new DateTime(Date.Year, 1, 1); }
public bool IsBefore(TimeFrame frame) { return(this < frame.start); }
/// <summary> /// Gets the number of days left in the time frame specified based on the date /// </summary> /// <param name="Date">Date</param> /// <param name="TimeFrame">Time frame to calculate the number of days left</param> /// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param> /// <returns>The number of days left in the time frame</returns> public static int DaysLeftIn(this DateTime Date, TimeFrame TimeFrame, CultureInfo Culture = null) { Culture = Culture.Check(CultureInfo.CurrentCulture); if (TimeFrame == TimeFrame.Day) return 1; if (TimeFrame == TimeFrame.Week) return 7 - ((int)Date.DayOfWeek + 1); if (TimeFrame == TimeFrame.Month) return Date.DaysIn(TimeFrame.Month, Culture) - Date.Day; if (TimeFrame == TimeFrame.Quarter) return Date.DaysIn(TimeFrame.Quarter, Culture) - (Date.DayOfYear - Date.BeginningOf(TimeFrame.Quarter, Culture).DayOfYear); return Date.DaysIn(TimeFrame.Year, Culture) - Date.DayOfYear; }
/// <inheritdoc/> public Task UnSubscribeRealtimeData(ActivePair pair, TimeFrame tf) => WsClient?.UnsubscribeCandlesAsync(pair, tf);
/// <summary> /// End of a specific time frame /// </summary> /// <param name="Date">Date to base off of</param> /// <param name="TimeFrame">Time frame to use</param> /// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param> /// <returns>The end of a specific time frame (TimeFrame.Day is the only one that sets the time to 12:59:59 PM, all else are the beginning of the day)</returns> public static DateTime EndOf(this DateTime Date, TimeFrame TimeFrame, CultureInfo Culture = null) { Culture = Culture.Check(CultureInfo.CurrentCulture); if (TimeFrame == TimeFrame.Day) return new DateTime(Date.Year, Date.Month, Date.Day, 23, 59, 59); if (TimeFrame == TimeFrame.Week) return Date.BeginningOf(TimeFrame.Week, Culture).AddDays(6); if (TimeFrame == TimeFrame.Month) return Date.AddMonths(1).BeginningOf(TimeFrame.Month, Culture).AddDays(-1).Date; if (TimeFrame == TimeFrame.Quarter) return Date.EndOf(TimeFrame.Quarter, Date.BeginningOf(TimeFrame.Year, Culture), Culture); return new DateTime(Date.Year, 12, 31); }
public ResearchTeam(string InvestigationTheme, string Organisation, int RegistrationNumber, TimeFrame InvestigationDuration) { ResearchDuration = InvestigationDuration; Theme = InvestigationTheme; _RegistrationNumber = RegistrationNumber; _Organisation = Organisation; }
public ResearchTeam(string researchTopic, string organizationTitle, int registrationNumber, TimeFrame researchDuration) { _researchTopic = researchTopic; _organizationTitle = organizationTitle; _registrationNumber = registrationNumber; _researchDuration = researchDuration; }
public override void Calculate(int index) { var Idx_Lon_Start = MarketSeries.OpenTime.GetIndexByTime(TheStart); var Idx_Lon_End = Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours); var Idx_pre_session = Idx_Lon_Start - index_Projection(TimeFrame.ToString(), Pre_Session); //+------------------------------------------------ //Code to Draw The Sessions Every Day //There should be a Look-Back Period to Limit the drawing and Calculations--> Done ! //Should be Tested while the market is Open //+----------- Look Back Period -----------+ if (MarketSeries.OpenTime[index] < TheStart.AddDays(-Look_Back)) { return; } //+----------- Look Back Period -----------+ double Lowest = 50000; double Highest = 0; double BoxHeight = 0; if (MarketSeries.OpenTime[index].Hour == TheStart.Hour && MarketSeries.OpenTime[index].Minute < TheStart.AddMinutes(1).Minute) { Lowest = 50000; Highest = 0; BoxHeight = 0; var diff = index_Projection(TimeFrame.ToString(), Pre_Session); for (int i = Idx_Lon_Start - diff; i <= Idx_Lon_Start; i++) { if (MarketSeries.High[i] > Highest) { Highest = MarketSeries.High[i]; } if (MarketSeries.Low[i] < Lowest) { Lowest = MarketSeries.Low[i]; } } BoxHeight = (Highest - Lowest); var TP1_Buy = (TP1 * Symbol.PipSize) + Highest + (Buffer_Pips * Symbol.PipSize); var TP2_Buy = (TP2 * Symbol.PipSize) + Highest + (Buffer_Pips * Symbol.PipSize); var TP3_Buy = (TP3 * Symbol.PipSize) + Highest + (Buffer_Pips * Symbol.PipSize); var TP1_Sell = Lowest - (Buffer_Pips * Symbol.PipSize) - (TP1 * Symbol.PipSize); var TP2_Sell = Lowest - (Buffer_Pips * Symbol.PipSize) - (TP2 * Symbol.PipSize); var TP3_Sell = Lowest - (Buffer_Pips * Symbol.PipSize) - (TP3 * Symbol.PipSize); if (Lowest == 50000) { return; } ChartObjects.DrawText("Highest" + index, theDot, Idx_Lon_Start, Highest, VerticalAlignment.Center, HorizontalAlignment.Center, Colors.DarkTurquoise); ChartObjects.DrawText("Lowest" + index, theDot, Idx_Lon_Start, Lowest, VerticalAlignment.Center, HorizontalAlignment.Center, Colors.DarkTurquoise); DrawRectangle("London_Session" + index, Idx_Lon_Start, Lowest, Idx_Lon_End - Idx_Lon_Start, (Highest - Lowest), Colors.DodgerBlue, 1, LineStyle.LinesDots); DrawRectangle("Pre_Session Bounds" + index, Idx_pre_session, Lowest, Idx_Lon_Start - Idx_pre_session, Math.Abs(BoxHeight), Colors.Yellow, 1, LineStyle.DotsRare); //Print(index_Projection(TimeFrame.ToString())); //+--------- Draw Buy & Sell Breakout level ------------------------+ ChartObjects.DrawLine("Buy_Level" + index, Idx_Lon_Start, Highest + (Buffer_Pips * Symbol.PipSize), Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), Highest + (Buffer_Pips * Symbol.PipSize), Colors.LimeGreen, 1, LineStyle.DotsRare); ChartObjects.DrawText("Buy" + index, "Buy Level", index + 2, Highest + (Buffer_Pips * Symbol.PipSize), VerticalAlignment.Top, HorizontalAlignment.Right, Colors.LimeGreen); ChartObjects.DrawLine("Sell_Level" + index, Idx_Lon_Start, Lowest - (Buffer_Pips * Symbol.PipSize), Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), Lowest - (Buffer_Pips * Symbol.PipSize), Colors.Crimson, 1, LineStyle.DotsRare); ChartObjects.DrawText("Sell" + index, "Sell Level", index + 2, Lowest - (Buffer_Pips * Symbol.PipSize), VerticalAlignment.Top, HorizontalAlignment.Right, Colors.Red); if (PL_Levels > 0) { //+--------- Draw TP 1 level ------------------------+ ChartObjects.DrawLine("TP1 BUY" + index, Idx_Lon_Start, TP1_Buy, Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), TP1_Buy, Colors.Green, 1, LineStyle.Lines); ChartObjects.DrawText("TP1_Level_buy" + index, "bTP1", Idx_Lon_Start, TP1_Buy, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Green); //+--------- Draw SL 1 level ------------------------+ ChartObjects.DrawLine("TP1 Sell" + index, Idx_Lon_Start, TP1_Sell, Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), TP1_Sell, Colors.DarkOrange, 1, LineStyle.Lines); ChartObjects.DrawText("TP1_Level_Sell" + index, "sTP1", Idx_Lon_Start, TP1_Sell, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.DarkOrange); } if (PL_Levels > 1) { //+--------- Draw TP 2 level ------------------------+ ChartObjects.DrawLine("TP2 BUY" + index, Idx_Lon_Start, TP2_Buy, Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), TP2_Buy, Colors.Green, 1, LineStyle.Lines); ChartObjects.DrawText("TP2_Level_buy" + index, "bTP2", Idx_Lon_Start, TP2_Buy, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Green); //+--------- Draw SL 2 level ------------------------+ ChartObjects.DrawLine("TP2 Sell" + index, Idx_Lon_Start, TP2_Sell, Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), TP2_Sell, Colors.DarkOrange, 1, LineStyle.Lines); ChartObjects.DrawText("TP2_Level_Sell" + index, "sTP2", Idx_Lon_Start, TP2_Sell, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.DarkOrange); } if (PL_Levels > 2) { //+--------- Draw TP 3 level ------------------------+ ChartObjects.DrawLine("TP3 BUY" + index, Idx_Lon_Start, TP3_Buy, Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), TP3_Buy, Colors.Green, 1, LineStyle.Lines); ChartObjects.DrawText("TP3_Level_buy" + index, "bTP3", Idx_Lon_Start, TP3_Buy, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Green); //+--------- Draw SL 3 level ------------------------+ ChartObjects.DrawLine("TP3 Sell" + index, Idx_Lon_Start, TP3_Sell, Idx_Lon_Start + index_Projection(TimeFrame.ToString(), Session_Hours), TP3_Sell, Colors.DarkOrange, 1, LineStyle.Lines); ChartObjects.DrawText("TP3_Level_Sell" + index, "sTP3", Idx_Lon_Start, TP3_Sell, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.DarkOrange); } } }
public static void ShowPopup(this INotifications notifications, TimeFrame timeFrame, Symbol symbol, string type, string triggeredBy, double price, string comment, DateTimeOffset time) { ShowPopup(notifications, timeFrame.ToString(), symbol.Name.ToString(), type, triggeredBy, price, comment, DateTimeOffset.Now); }
int TimeframeToInt(TimeFrame tf) { if (tf == TimeFrame.Minute) return 1; else if (tf == TimeFrame.Minute2) return 2; else if (tf == TimeFrame.Minute3) return 3; else if (tf == TimeFrame.Minute4) return 4; else if (tf == TimeFrame.Minute5) return 5; else if (tf == TimeFrame.Minute10) return 10; else if (tf == TimeFrame.Minute15) return 15; else if (tf == TimeFrame.Minute30) return 30; else if (tf == TimeFrame.Hour) return 60; else if (tf == TimeFrame.Hour4) return 240; else if (tf == TimeFrame.Daily) return 1440; else if (tf == TimeFrame.Weekly) return 10080; else if (tf == TimeFrame.Monthly) return 43200; return 1; }