代码如下:
Params
Numeric dh(40);
Numeric lot(0);
Numeric FastLen(28); // 分钟线
Numeric SlowLen(30); //分钟
Numeric NomLen(20); //日线
Numeric NomL(10); //10日高低点
Numeric Ch(5); //前多少根日线
Numeric Length(100); //多少根分钟线
Numeric ReBar(200);
Vars
Numeric MinPoint(0); // 声明变量MinPoint,一个最小变动单位,也就是一跳。
Numeric MyEntryPrice(0); // 声明变量MyEntryPrice,英文好的,看英文意思都知道的,开仓价格,本例是开仓均价,也可根据需要设置为某次入场的价格。
Series<Numeric> FastMA; // 快速均线
Series<Numeric> SlowMA; // 慢速均线
Numeric NomMA;
Series<Numeric> CCC;
Series<Numeric> ReEntryCount; // 跟踪止损后记录BAR序号
Numeric MyExitPrice; // 声明变量MyExitPrice,平仓价格。
Series<Numeric> ATR;
Series<Numeric> StopPri; //跟踪止损价
Series<Numeric> StopLPri;
Series<Numeric> stopwin;
Series<Numeric> HighValue; //多头进场之后的盈利峰值价
Series<Numeric> AF; //跟踪Acceleration
Series<Numeric> HighestAfterEntry; //声明序列变量HighestAfterEntry,开仓后出现的最高价。
Series<Numeric> LowestAfterEntry; //声明序列变量LowestAfterEntry,开仓后出现的最低价。
Numeric StopPrice(0);
Series<Bool> Condition1(False);
series<Bool> Yun(False);
Numeric StopATR;
Numeric HH;
Numeric HHH; // 最近N根BAR的高点
Numeric LL;
Numeric PP; // 最近N根BAR的低
Numeric DDH;
Numeric Bigbar;
Series<Numeric> PPP;
Series<Numeric> LD;
Series<Numeric> HD;
Series<Bool> Yang; //锤子线阳
Series<Bool> yin;// 吊头线阴
Numeric MyRange; //K线幅度
Events
OnInit()
{
HD=Highest(high[1],dh);
LD=Lowest(Low[1],dh);
Commentary(CCC=+Text(CCC));
Commentary(ReEntryCount=+Text(ReEntryCount));
Commentary(HH=+Text(HH));
Commentary(HD=+Text(HD));
Commentary(Open=+Text(Open));
FastMA = Average(Close, FastLen);
SlowMA = Average(Close,SlowLen);
MyRange = High - Low; //K线幅度
Yang=(open-Low)>=(close-open) and Close>=open;
yin=(high-open)>=(open-close) And open>=Close;
MinPoint = MinMove*PriceScale;//固定的最小跳动价公式。
}
OnBar(ArrayRef<Integer> indexs)
{
If(MarketPosition ==0 And Time >= 0.2100 And Time <0.2101) // 开仓//夜盘开始
{
If(Open>HD)
{Buy(0,Open);}
If( Open<LD)
{SellShort(0,Open);}
}
}
OnBarClose(ArrayRef<Integer> indexs)
{
// K线形态判断的2个条件
//
If(MarketPosition==1 AND VOL>0 And Time >=0.2100) // 有多仓的情况下。
{Sell(0,Close);
}
If(MarketPosition==-1 AND VOL >0 And Time >=0.2100)
{BuyToCover(0,Close);}
}
这段代码无法启动?为什么把dh换成常数就可以?
你为什么会写在oninit里?