为什么大于1000的ATR还能实现?简直离谱,,但是在图表打印出来的又是不成立的数值
全代码如下
Params
Numeric x(5);
Numeric BH(5);
Numeric dh(40);
Numeric lot(0);
Numeric FastLen(60); // 分钟线
Numeric SlowLen(60); //分钟
Numeric NomLen(20); //日线
Numeric NomL(10); //10日高低点
Numeric Ch(5); //前多少根日线
Numeric Length(10); //多少根分钟线
Numeric N(5);
Numeric M(20);
Numeric ReBar(200);
Vars
Numeric MinPoint(0); // 声明变量MinPoint,一个最小变动单位,也就是一跳。
Numeric MyEntryPrice(0); // 声明变量MyEntryPrice,英文好的,看英文意思都知道的,开仓价格,本例是开仓均价,也可根据需要设置为某次入场的价格。
Series<Numeric> FastMA; // 快速均线
Series<Numeric> SlowMA; // 慢速均线
Numeric NomMA;
Series<Numeric> BB;
Series<Numeric> SS;
Numeric hd;
Numeric lld;
Numeric h2d;
Numeric l2d;
Numeric sig;
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 J ;
Numeric H; // 最近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;// 吊头线阴
Series<Bool> upying;
Series<Bool> downying;
Series<Bool> DDATR;
// 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)
{
downying=(Min(Open, Close) - Low >= 0.4*(High - Low) ) ;//下影线
upying=(High - Max(Open, Close) >= 0.4*(High - Low) ) ;//上影线
If(MarketPosition ==0 AND TIME >0.0900 and time <0.145) // 开仓/
{ If(close[1]-low[1]>1000*ATR and low<low[1])
{
Buy(0,close);
BB=high[1];
}
If(high[1]-close[1]>1000*ATR and high >high[1])
{
SellShort(0,Close);
SS=low[1];
}
}
}
OnBarClose(ArrayRef<Integer> indexs)
{
/* If(BarsSinceEntry>0 and MarketPosition==1 AND High >=BB ) // 有多仓的情况下。
{Sell(0,Close);
}
If(BarsSinceEntry>0 and MarketPosition==-1 and Low <=SS )
{BuyToCover(0,Close);}*/
If(BarsSinceEntry>N And MarketPosition==1 ) // 有多仓的情况下。
{Sell(0,Close);
}
If(BarsSinceEntry>N and MarketPosition==-1 )
{BuyToCover(0,Close);}
}
你复制的代码无法编译,你看看有什么错了。
我肉眼看你的ATR也没赋值啊,那不是铁出错
第一,代码的格式很乱,杂乱无章,而且还有重复定义,导致编译不能通过的情况。上传代码前请先确认代码语法是否正确,起码自己编译检查一遍再上传,否则我改动修复以后不能确认是否对策略逻辑发生改动导致无法复现问题。
第二,好不容易调整好内容以后,看了半天也没找到你发的代码里,atr在哪里计算。atr如果只定义,却不计算,那就是0,那当然没有控制效果了。至于你图里是怎么显示出atr=2.29的,我也很费解,你发的代码里一句commentary都没有,你确定你上传的代码和你出问题的图是同一件事吗?
第三,当我补上atr的计算公式以后,马上信号就全消失了。
atr到底要怎么用?你遇到的问题似乎跟atr怎么用,关系不大
不好意思 我的源代码里面有HH这个东西,所以删减修改了部分,
以后复制代码可以用代码模式