本文整理汇总了C#中DataSeries.ContainsValue方法的典型用法代码示例。如果您正苦于以下问题:C# DataSeries.ContainsValue方法的具体用法?C# DataSeries.ContainsValue怎么用?C# DataSeries.ContainsValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSeries
的用法示例。
在下文中一共展示了DataSeries.ContainsValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSlope
public static int GetSlope(NinjaTrader.Strategy.Strategy strat, DataSeries series, int index)
{
return !series.ContainsValue(3) ? 0 : (int)((57.295779513082323 * Math.Atan(((series.Get(index) - ((series.Get(index + 1) + series.Get(index + 2)) / 2.0)) / 1.5) / strat.TickSize)) * -1.0);
}
示例2: OnBarUpdate
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(BarsInProgress==6){
DateTime dt=Times[6][0];
TimeSpan ts=dt.TimeOfDay;
//log("*** "+ts+"==="+tw);
if(vv||tw==null||ts.CompareTo(tw)<=0){
vv=false;
tw=ts;
log("==================INIT spreadDataSeriesAsk");
spreadAsks=new Stack<int>();
//spreadDataSeriesAsk = new DataSeries(this);
//spreadDataSeriesBid = new DataSeries(this);
}
}
if(BarsInProgress==3)
t=Times[3][0];
if(active==false){
if (CurrentBars[1] < 1 || CurrentBars[2] < 1)
return;
active=true;
}
/*if(virgin){
int spread_ask=(int)(Closes[3][0]*4)-(int)(Closes[6][0]);
int spread_bid=(int)(Closes[4][0]*4)-(int)(Closes[5][0]);
top=spread_ask+Target;
bottom=spread_bid-Target;
PrintWithTimeStamp(name+" SET RANGE TOP:"+top+", BOTTOM:"+bottom);
log(" SET RANGE TOP:"+top+", BOTTOM:"+bottom);
virgin=false;
}*/
if(BarsInProgress==6){
int spread_ask=(int)(Closes[3][0]*4)-(int)(Closes[6][0]);
// int spread_bid=(int)(Closes[4][0]*4)-(int)(Closes[5][0]);
total++;
//log("ask<"+RuntimeHelpers.GetHashCode(spreadDataSeriesAsk)+">"+spread_ask);
spreadDataSeriesAsk.Set(spread_ask);
spreadAsks.Push(spread_ask);
spreadDataSeriesAsk=new DataSeries(this);
//[]=Stack<int> stackAsks=new Stack<int>();
int[] ar=spreadAsks.ToArray();
for(int i=Math.Min(ar.GetUpperBound(0),mAPeriod+6);i>=0;i--){
spreadDataSeriesAsk.Set(i,ar[i]);
}
if(CurrentBars[6]>mAPeriod){
//if(CurrentBars[6]>mAPeriod){
// sma=SMA(spreadDataSeriesAsk,mAPeriod)[0];
int x=1;
String p="SMA["+sma+"]=";
trade_active=false;
String pp=Times[BarsInProgress]+"VALUES["+BarsInProgress+"]:";
for(int i=0;i<mAPeriod;i++){
if(spreadDataSeriesAsk.ContainsValue(i))
pp+="i="+i+":"+spreadDataSeriesAsk[i]+";";
}
//log(pp+" "+"MAX="+MAX(spreadDataSeriesAsk,6)[1]+";MIN="+MIN(spreadDataSeriesAsk,6)[1]);
sma=SMA(spreadDataSeriesAsk,6)[0];
if(Math.Abs(MAX(spreadDataSeriesAsk,rangePeriod)[1]-MIN(spreadDataSeriesAsk,rangePeriod)[1])<range){
while(x<6){
double d=SMA(spreadDataSeriesAsk,6)[x];
if(d==0.0)
break;
p+=d+";";
/*if(Math.Abs(d-sma)<breakSMA&&Math.Abs(spread_ask-d)>breakSpread){
active=false;
break;
}*/
if(sma<=d+breakSMA||spread_ask<d+breakSpread)
break;
x++;
}
if(x==6){
// log(p);
dir=1;
while (x>0){
if(spread_ask-breakSpread<spreadDataSeriesAsk[x+1])
break;
x--;
}
if(x==0)
trade_active=true;
}
else{
x=1;
p="SMA["+sma+"]=";
while(x<6){
//.........这里部分代码省略.........