//------------------------------------------------------------------------
// 简称: JailBreakSys_L
// 名称: 基于价格区间突破的交易系统
// 类别: 公式应用
// 类型: 内建应用
// 输出:
// 策略说明: 基于通道突破的判断
// 系统要素:
// 1. 计算50根k线最高价的区间
// 2. 计算30根k线最低价的区间
//
// 入场条件:
// 1.价格高于50根K线最高价的区间入场
// 出场条件:
// 1. 当前价格低于30根K线最低价的区间出场
// 2. 当前价格低于入场价一定ATR波动率幅度出场
//
//----------------------------------------------------------------------//
Params
Numeric Length1(50); //长周期区间参数
Numeric Length2(30); //短周期区间参数
Numeric IPS(4); //保护止损波动率参数
Numeric AtrVal(10); //波动率参数
Vars
Series<Numeric> myprice; //临界价格
Series<Numeric> myprice_temp; //临时的临界价格
Series<Numeric> nn; //向前计算的日期
Series<Numeric> temp; //临时数据
Series<Numeric> temp2; //临时数据
Series<Numeric> temp3; //临时数据
Series<Numeric> temp4; //临时数据
Series<Numeric> i; //循环参数
//Numeric myprice;
//Numeric temp;
//Array<Array<Numeric>> myprice;
Series<Numeric> ProtectStopL;
Series<Numeric> ATR;
Series<Numeric> Upperband;
Series<Numeric> Lowerband;
Series<Numeric> Exitlong;
Series<Numeric> Exitshort;
Numeric L2;
Numeric L1;
Numeric Minpoint;
Events
OnBar(ArrayRef<Integer> indexs)
{
//确定临界价格
if (1<=Month && Month<=3)
{
if (IsTradingDay(MakeDate(year-1,12,15)))
{
temp=DateDiff(MakeDate(year-1,12,15),Date);
//myprice=closeD(temp);
}
Else
{
temp=DateDiff(MakeDate(year-1,12,12),Date);
//myprice=closeD(temp);
}
}
//myprice= closeD(temp);
if (4<=Month && Month<=6)
{
if (IsTradingDay(MakeDate(year,3,28)))
{
temp=DateDiff(MakeDate(year,3,28),Date);
//myprice=closeD(temp);
}
Else
{
temp=DateDiff(MakeDate(year,3,25),Date);
//myprice=closeD(temp);
}
}
//myprice= closeD(temp);
if (7<=Month && Month<=9)
{
if (IsTradingDay(MakeDate(year,6,22)))
{
temp=DateDiff(MakeDate(year,6,22),Date);
//myprice=closeD(temp);
}
Else
{
temp=DateDiff(MakeDate(year,6,19),Date);
//myprice=closeD(temp);
}
}
//myprice= closeD(temp);
if (10<=Month && Month<=12)
{
if (IsTradingDay(MakeDate(year,9,27)))
{
temp=DateDiff(MakeDate (year,9,27),Date);
//myprice=closeD(temp);
}
Else
{
temp=DateDiff(MakeDate (year,9,24),Date);
//myprice=closeD(temp);
}
}
temp2=temp-temp[1];
myprice_temp= closeD(temp);
For i=1 To BarCount
{
If (temp2[BarCount-i+1]<=0)
{
temp3=myprice_temp[BarCount-i+1]; //临界价格
}
myprice=temp3;
}
//myprice= closeD(temp);
//Print("临界价格:"+Text(myprice)+"日期:"+Text(Date));
//Print("临界价格:"+Text(myprice)+"天数:"+Text(temp)+"日期:"+Text(temp-temp[1])+"日期:"+Text(Open)+"日期:"+Text(Date));
//系统入场
If(Marketposition <>1 And Open >= myprice And Vol > 0 And myprice<>InvalidNumeric) //价格大于临界价格入场做多
{
temp4=1;
Buy(0, Max(Open, myprice));
//print("11111");
}
If(Marketposition <>-1 And Open <= myprice And Vol > 0 And myprice<>InvalidNumeric) //价格大于临界价格入场做多
{
temp4=100;
SellShort(0, Min(Open, myprice));
//print("11111");
}
Print("临界价格:"+Text(temp4)+"日期:"+Text(Date));
}
//------------------------------------------------------------------------
// 编译版本 GS2014.10.25
// 版权所有 TradeBlazer Software 2003-2025
// 更改声明 TradeBlazer Software保留对TradeBlazer平
// 台每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
for循环可能使用不当,导致策略隐含回溯值太大,导致信号不显示,排查一下自己是不是需要这么大的回溯值,或者使用http://www.tbquant.net/dist/index.html#/?navigate=&cid=1162&position=0这个函数来让信号显示,已在米多客客服系统给您回复了
代码诊断可以看置顶帖投稿