Beispiel #1
0
        public void AppendBarItem(DateTime time, double open, double close, double high, double low)
        {
            long lastPosition = this.Position;

            object[] items = new object[] { time.Ticks, open, close, high, low };

            this.Append(items);

            if (BookmarkNotification != null)
            {
                if (lastPosition == 0)
                {
                    BookmarkNotification(time, lastPosition);
                }

                if (nextRollingDate == DateTime.MinValue)
                {
                    nextRollingDate = TimeframeHelper.NextRolling(time, bookmarkBarItemType);
                }

                if (time >= nextRollingDate)
                {
                    BookmarkNotification(time, lastPosition);
                    nextRollingDate = TimeframeHelper.NextRolling(time, bookmarkBarItemType);
                }
            }
        }
Beispiel #2
0
        public bool WithinNextRange(DateTime dateTime)
        {
            DateTime nextLowerRange = this.upperRange;
            DateTime nextUpperRange = TimeframeHelper.NextRolling(this.upperRange, this.timeBarItemType);

            return(dateTime >= nextLowerRange && dateTime < nextUpperRange);
        }
Beispiel #3
0
 public void Restart(DateTime startTime)
 {
     this.lowerRange  = TimeframeHelper.LastRolling(startTime.AddTicks(-1), this.timeBarItemType);
     this.upperRange  = TimeframeHelper.NextRolling(this.lowerRange, this.timeBarItemType);
     this.currentTime = startTime;
     this.ticks       = 0;
 }
Beispiel #4
0
        // </summary>
        // <param name="timeframe">Timeframe to do scanning on</param>
        // <param name="startDateString">Lower bound date in format yyyyMMddHHmmss</param>
        // <param name="endDateString">Upper bound date in format yyyyMMddHHmmss</param>
        // <returns>List of Engulfings</returns>
        public List <FXModes.MqlRates> RatesByDates(string symbol, string timeframe, string startDateString, string endDateString)
        {
            RetryConnecting();
            var startDate = DateTime.ParseExact(startDateString, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
            var endDate   = DateTime.ParseExact(endDateString, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);

            if ((endDate - startDate).TotalMinutes <= TimeframeHelper.GetMinutesFromForTimeframe(timeframe))
            {
                return(new List <FXModes.MqlRates>());
            }
            if ((mtApi5Client.TimeCurrent() - startDate).TotalMinutes <= TimeframeHelper.GetMinutesFromForTimeframe(timeframe))
            {
                return(new List <FXModes.MqlRates>());
            }

            ENUM_TIMEFRAMES enumTimeframe = (ENUM_TIMEFRAMES)Enum.Parse(typeof(ENUM_TIMEFRAMES), timeframe);
            int             size          = (int)((endDate - startDate).TotalMinutes / (TimeframeHelper.GetMinutesFromForTimeframe(timeframe)));
            var             candles       = new MqlRates[size];

            mtApi5Client.CopyRates(symbol, enumTimeframe, startDate, endDate, out candles);
            //This is done so that time is not ignored from xml
            var newCandles = new List <FXModes.MqlRates>();

            foreach (var m in candles)
            {
                newCandles.Add(new FXModes.MqlRates
                {
                    time        = m.time,
                    close       = m.close,
                    high        = m.high,
                    low         = m.low,
                    mt_time     = m.mt_time,
                    open        = m.open,
                    real_volume = m.real_volume,
                    spread      = m.spread,
                    tick_volume = m.tick_volume
                });
            }
            return(newCandles);
        }
Beispiel #5
0
 public void SetNextRange()
 {
     this.lowerRange = this.upperRange;
     this.upperRange = TimeframeHelper.NextRolling(this.lowerRange, this.timeBarItemType);;
 }