本文整理汇总了C#中BarInterval类的典型用法代码示例。如果您正苦于以下问题:C# BarInterval类的具体用法?C# BarInterval怎么用?C# BarInterval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BarInterval类属于命名空间,在下文中一共展示了BarInterval类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBarList
public Image DrawBarList(BarListImpl bl, BarInterval bi,Color up, Color down)
{
bl.DefaultInterval = bi;
Bitmap sl = new Bitmap(w, h);
Graphics g = Graphics.FromImage(sl);
high = Calc.HH(bl);
low = Calc.LL(bl);
decimal range = high - low;
int pixperdollar = range != 0 ? (int)(h / range) : 0;
int pixperbar = bl.Count != 0 ? (int)(w / (decimal)bl.Count) : 0;
for (int i = 0; i< bl.Count; i++)
{
Bar b = bl[i,bi];
Pen p = new Pen(b.Close>=b.Open ? up : down);
g.DrawLine(p, i * pixperbar, h-(int)((b.Low - low) * pixperdollar), i * pixperbar, h-(int)((b.High - low) * pixperdollar));
}
return sl;
}
示例2: BarListImpl
/// <summary>
/// creates a barlist with array of custom intervals
/// </summary>
/// <param name="symbol"></param>
/// <param name="intervals"></param>
public BarListImpl(string symbol, int[] intervals, BarInterval[] types)
{ // set symbol
_sym = symbol;
// set intervals requested
_availint = intervals;
// size length of interval data to # of requested intervals
_intdata = new IntervalData[intervals.Length];
// create interval data object for each interval
for (int i = 0; i < intervals.Length; i++)
{
try
{
// save index to this data for the interval
_intdataidx.Add(intervals[i], i);
}
// if key was already present, already had this interval
catch (Exception) { continue; }
// set default interval to first one
if (i == 0)
_defaultint = intervals[0];
// create data object appropriate for type of interval
switch (types[i])
{
case BarInterval.CustomTicks:
_intdata[i] = new TickIntervalData(intervals[i]);
break;
case BarInterval.CustomVol:
_intdata[i] = new VolIntervalData(intervals[i]);
break;
default:
_intdata[i] = new TimeIntervalData(intervals[i]);
break;
}
// subscribe to bar events
_intdata[i].NewBar += new SymBarIntervalDelegate(BarListImpl_NewBar);
}
}
示例3: FromTIK
/// <summary>
/// create barlist from a tik file using given intervals/types
/// </summary>
/// <param name="filename"></param>
/// <param name="uselast"></param>
/// <param name="usebid"></param>
/// <param name="intervals"></param>
/// <param name="types"></param>
/// <returns></returns>
public static BarList FromTIK(string filename, bool uselast, bool usebid, int[] intervals, BarInterval[] types)
{
_uselast = uselast;
_usebid = usebid;
SecurityImpl s = SecurityImpl.FromTIK(filename);
s.HistSource.gotTick += new TickDelegate(HistSource_gotTick);
_fromepf = new BarListImpl(s.Symbol,intervals,types);
while (s.HistSource.NextTick()) ;
return _fromepf;
}
示例4: BarsBackFromDate
public static int BarsBackFromDate(BarInterval interval, int startdate, int enddate) { return BarsBackFromDate(interval, Util.ToDateTime(startdate, 0), Util.ToDateTime(enddate,Util.ToTLTime())); }
示例5: Has
/// <summary>
/// returns true if barslist has at least minimum # of bars for specified interval
/// </summary>
/// <param name="minBars"></param>
/// <param name="interval"></param>
/// <returns></returns>
public bool Has(int minBars, BarInterval interval)
{
return minBars<=CountInterval(interval);
}
示例6: Bollinger
public Bollinger(decimal sds, BarInterval bi, int lookback)
{ this.sds = sds;
this.bi = bi;
this.lookback = lookback;
isbarcons = true;
}
示例7: BarListImpl
/// <summary>
/// creates a barlist with requested interval. symbol will be defined by first tick received
/// </summary>
/// <param name="interval"></param>
public BarListImpl(BarInterval interval)
: this(string.Empty, new BarInterval[] { interval })
{
}
示例8: CountInterval
/// <summary>
/// gets count of bars in specified interval
/// </summary>
/// <param name="interval"></param>
/// <returns></returns>
public int CountInterval(BarInterval interval)
{
return _intdata[_intdataidx[(int)interval]].Count();
}
示例9: LastInterval
/// <summary>
/// gets the last bar in specified interval
/// </summary>
/// <param name="interval"></param>
/// <returns></returns>
public int LastInterval(BarInterval interval)
{
return _intdata[_intdataidx[(int)interval]].Last();
}
示例10: GetNearestIntraBar
public static int GetNearestIntraBar(BarList bl, int time, BarInterval bint,DebugDelegate debug)
{
try
{
long barid = TimeIntervalData.getbarid(time, bl.RecentBar.Bardate, (int)bint);
BarListImpl bli = (BarListImpl)bl;
TimeIntervalData tid = (TimeIntervalData)bli._intdata[bli._intdataidx[(int)bint]];
for (int i = 0; i < tid.Count(); i++)
if (tid.ids[i] == barid)
return i;
}
catch (Exception ex)
{
if (debug != null)
debug("error getting nearest bar from: " + bl.Symbol + " at: " + time + " for: " + bint + " error: " + ex.Message + ex.StackTrace);
}
return -1;
}
示例11: High
public decimal[] High(BarInterval interval)
{
return _intdata[_intdataidx[(int)interval]].high().ToArray();
}
示例12: BarImpl
public BarImpl(BarInterval tu)
{
units = (int)tu;
}
示例13: GetNearestIntraBar
/// <summary>
/// find the bar # that matches a given time
/// </summary>
/// <param name="bl"></param>
/// <param name="time"></param>
/// <param name="bint"></param>
/// <returns></returns>
public static int GetNearestIntraBar(BarList bl, int time, BarInterval bint)
{
long barid = TimeIntervalData.getbarid(time, bl.RecentBar.Bardate, (int)bint);
BarListImpl bli = (BarListImpl)bl;
TimeIntervalData tid = (TimeIntervalData)bli._intdata[bli._intdataidx[(int)bint]];
for (int i = 0; i < tid.Count(); i++)
if (tid.ids[i] == barid)
return i;
return -1;
}
示例14: Low
public decimal[] Low(BarInterval interval)
{
return _intdata[_intdataidx[(int)interval]].low().ToArray();
}
示例15: Open
public decimal[] Open(BarInterval interval)
{
return _intdata[_intdataidx[(int)interval]].open().ToArray();
}