代码如下
Params
Numeric BH(150);
Numeric dh(40);
Numeric lot(0);
Numeric FastLen(60); // 分钟线
Numeric SlowLen(30); //分钟
Numeric NomLen(20); //日线
Numeric NomL(10); //10日高低点
Numeric Ch(5); //前多少根日线
Numeric Length(100); //多少根分钟线
Numeric signbuy(0);
Numeric signsell(0);
Numeric ReBar(200);
Vars
series<Numeric> MinPoint(0); // 声明变量MinPoint,一个最小变动单位,也就是一跳。
Numeric MyEntryPrice(0); // 声明变量MyEntryPrice,英文好的,看英文意思都知道的,开仓价格,本例是开仓均价,也可根据需要设置为某次入场的价格。
Series<Numeric> FastMA; // 快速均线
Series<Numeric> SlowMA; // 慢速均线
Numeric NomMA;
Series<Numeric> x(0);
Series<Numeric> sig(1);
Series<Numeric> tt;
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;
Series<Numeric> xx(0);
Series<Numeric> xy(0); //跟踪Acceleration
Series<Numeric> HighestAfterEntry; //声明序列变量HighestAfterEntry,开仓后出现的最高价。
Series<Numeric> LowestAfterEntry; //声明序列变量LowestAfterEntry,开仓后出现的最低价。
Numeric StopPrice(0);
Series<Bool> Condition1(False);
series<Bool> Yun(False);
series<bool> condition(true);
series<bool> condition2(true);
Numeric StopATR;
Series<Numeric> HH;
Numeric HHH; // 最近N根BAR的高点
Series<Numeric> LL;
Numeric PP;
Global Numeric h1;
Global Numeric l1; // 最近N根BAR的低
Numeric DDH;
Numeric Bigbar;
Numeric CL;
Series<Numeric> PPP;
Series<Numeric> LD;
Series<Numeric> H1d;
Series<Numeric> H2d;
Series<Numeric> L1d;
Series<Numeric> L2d;
Series<Numeric> op;
Series<Numeric> HD;
Series<Numeric> lld;
Series<Numeric> hhd;
Series<Bool> shang; //锤子线阳
Series<Bool> xia;// 吊头线阴
// Series<Bool> Condition1; // 条件1
// Series<Bool> Condition2; // 条件2
Numeric MyRange; //K线幅度
Events
OnInit()
{ Array<Numeric> timepoint;
timepoint[0] = 0.145950;
SetTriggerBarClose(timepoint);
}
OnBar(ArrayRef<Integer> indexs)
{
if(time==0.0900)
{ h1=high;
l1=low;
}
range[0:0]
{
HD=Highest(high[1],dh);
LD=Lowest(Low[1],dh);
H2d=Highest(high[1],BH);
L2D=Lowest(Low[1],BH);
MinPoint = MinMove*PriceScale;//固定的最小跳动价公式。
HH=max(open,AvgEntryPrice-2*minpoint);
ll=min(open,AvgEntryPrice+2*minpoint);
Commentary("data1.h1d="+Text(data1.h1d));
Commentary("XY="+Text(XY));
Commentary("Highest(high[1],40)="+Text(Highest(high[1],40)));
Commentary("1.03*Lowest(low[1],40)="+Text(1.03*Lowest(low[1],40)));
Commentary("H1="+Text(H1));
FastMA = Average(Close, FastLen);
SlowMA = Average(Close,SlowLen);
PlotNumeric("FastMA",FastMA);
PlotNumeric("SlowMA",SlowMA);
Condition1= Highest(high[1],40)<=1.03*Lowest(low[1],40);
MyRange = High - Low; //K线幅度
}
range[1:1]
{
H1D=Highest(high[1],2);
L1D=Lowest(Low[1],2);
xia=abs(min(open,close)-low)>2*abs(close-open);
shang=abs(high-min(open,close))>2*abs(close-open) ;
}
if(MarketPosition ==0 and ( x==0 or BarsSinceExit>30 ) )
{
If(High>HD and high>h1 and Condition1 and ( xx==0 or BarsSinceExit>60) )
{
{ Buy(0,close);
lld=low[1];
condition = false;
}
}
// 开仓/*/
If(Low<LD and low <l1 and Condition1==True and (xy==0 or BarsSinceExit>60) )
{SellShort(0,Close);
hhd=high[1];
condition = false;
}
//
}
}
OnBarClose(ArrayRef<Integer> indexs)
{
If(BarsSinceEntry>0 And MarketPosition==1 AND VOL >0 and Low <L2d ) // 有多仓的情况下。
{Sell(0,Close);
xx=1;
xy=0;}
If(BarsSinceEntry>30 And MarketPosition==1 AND VOL >0 and Low <FastMA ) // 有多仓的情况下。
{
Sell(0,Close);
}
If(MarketPosition==1 AND VOL >0 And time >= 0.1459 AND TIME <0.1500 ) // 有多仓的情况下。
{Sell(0,Close);
xx=0;
}
If(BarsSinceEntry>0 And MarketPosition==-1 AND VOL >0 and high>H2d ) // 有空仓的情况下。
{BuyToCover(0,Close);
xy=1;}
If(BarsSinceEntry>30 And MarketPosition==-1 AND VOL >0 and Close >FastMA )
{
BuyToCover(0,Close);
}
If( MarketPosition==-1 AND VOL >0 And time >= 0.1459 AND TIME <0.1500)
{BuyToCover(0,Close);
xy=0;}
}
都是用的收盘价格开平,没理由差那么多的?
我加载你的策略没有问题,另外我注意到你的策略没有运行完(看右上角)
运行完了还是老样子哦
哦 好像是点了复权的缘故