策略选股,设置如下
能看到有一些符合条件的股票并没有被正确的选出来,请问是我哪里设置有问题吗?
代码:
Vars
Numeric i;
Series<Numeric> dmH;
Series<Numeric> dmL;
Series<Numeric> dmH_cnt;
Series<Numeric> dmL_cnt;
Series<Numeric> highest6;
Series<Numeric> highest12;
Events
OnBar(ArrayRef<Integer> indexs)
{
Commentary(crb = + Text(CurrentBar));
Numeric diff = 4;
dmH = IIF(Close[1] > Close[5], 1, 0);
dmL = IIF(Close[1] < Close[5], 1, 0);
If(dmH == 1)
{
dmH_cnt = dmH_cnt +1;
If(dmH_cnt == 10) dmH_cnt = 1;
dmL_cnt = 0;
}
If(dmL == 1)
{
dmL_cnt = dmL_cnt +1;
If(dmL_cnt == 10) dmL_cnt = 1;
dmH_cnt = 0;
}
Commentary(dmH = +Text(dmH));
Commentary(dmL = +Text(dmL));
Commentary(dmH_cnt = +Text(dmH_cnt));
Commentary(dmL_cnt = +Text(dmL_cnt));
If(dmH_cnt ==9)
{
//PlotString(dmH_cnt, Text(dmH_cnt), High*1.01, Magenta);
PlotBool(高9, True, High[1]*1.01,0,1);
}
If(dmL_cnt ==9)
{
PlotBool(低9, False, low[1]*1,0,1);
}
Numeric n1 = NthCon(dmL_cnt == 9);
if (n1 <= 10)
{
PlotString(10周期有低9,*,High*1.01);
SetPickCondition;
}
if (IsAllPickCondition()) Commentary(选中!!!!!!);
}
终于解决了。
加上 range 就可以了。
请老师帮忙给看看,谢谢
重新贴一下代码
Params
Vars
Numeric i;
Series<Numeric> dmH;
Series<Numeric> dmL;
Series<Numeric> dmH_cnt;
Series<Numeric> dmL_cnt;
Series<Numeric> highest6;
Series<Numeric> highest12;
Events
OnBar(ArrayRef<Integer> indexs)
{
Commentary(\"crb = \" + Text(CurrentBar));
Numeric diff = 4;
dmH = IIF(Close[1] > Close[5], 1, 0);
dmL = IIF(Close[1] < Close[5], 1, 0);
If(dmH == 1)
{
dmH_cnt = dmH_cnt +1;
If(dmH_cnt == 10) dmH_cnt = 1;
dmL_cnt = 0;
}
If(dmL == 1)
{
dmL_cnt = dmL_cnt +1;
If(dmL_cnt == 10) dmL_cnt = 1;
dmH_cnt = 0;
}
Commentary(\"dmH = \"+Text(dmH));
Commentary(\"dmL = \"+Text(dmL));
Commentary(\"dmH_cnt = \"+Text(dmH_cnt));
Commentary(\"dmL_cnt = \"+Text(dmL_cnt));
If(dmH_cnt ==9)
{
//PlotString(\"dmH_cnt\", Text(dmH_cnt), High*1.01, Magenta);
PlotBool(\"高9\", True, High[1]*1.01,0,1);
}
If(dmL_cnt ==9)
{
PlotBool(\"低9\", False, low[1]*1,0,1);
}
Numeric n1 = NthCon(dmL_cnt == 9);
if (n1 <= 10)
{
PlotString(\"10周期有低9\",\"*\",High*1.01);
SetPickCondition;
}
if (IsAllPickCondition()) Commentary(\"选中!!!!!!\");
}