- 精华
- 0
- 在线时间
- 6 小时
- UID
- 288050
- 积分
- 14
- 帖子
- 8
- 阅读权限
- 10
- 注册时间
- 2020-1-17
- 最后登录
- 2020-2-12
- 精华
- 0
- UID
- 288050
- 积分
- 14
- 帖子
- 8
- 主题
- 6
- 阅读权限
- 10
- 注册时间
- 2020-1-17
- 最后登录
- 2020-2-12
|
请问,为什么我自己编的公式没有开平仓信号?公式如下
//------------------------------------------------------------------------
// 简称: pogao2
// 名称:
// 类型: 公式应用
// 类型: 用户应用
// 输出: Void
//------------------------------------------------------------------------
Params
Bool IsRollover(False);//是否后复权
Bool IsRolloverRealPrice(False);//是否映射真实价格
Bool IsAutoSwapPosition(False);//是否自动换仓
Bool IgnoreSwapSiganlCalc(False); //是否忽略换仓信号计算
Vars
Bool bVarCondition_buy_3;
Series<Numeric> sVarCondition_buy_3_left(0,2);
Series<Numeric> sVarCondition_buy_3_right(0,2);
Numeric dVarPrice_buy_1;
Numeric dVarPrice_buy_1_volume;
Bool bVarCondition_sell_1;
Bool bVarCondition_sell_2;
Numeric dVarPrice_sell_1;
Numeric dVarPrice_sell_1_volume;
Defs
Bool buy_condition_3()
{
sVarCondition_buy_3_left = Q_Last();
sVarCondition_buy_3_right = HighD(2);
Return sVarCondition_buy_3_left[1] > sVarCondition_buy_3_right[1];
}
Integer round_volume(Numeric volume)
{
Return IntPart(Round(volume / BaseShares(), 0))*BaseShares();
}
Bool time_condition_Buy_1()
{
If(MakeDateTime(Date(),Time()) >= 0 And MakeDateTime(Date(),Time()) <= 20200221.211317)
{
Return True;
}
Return false;
}
Bool sell_condition_1()
{
Return Data[1].StopProfit(1,60);
}
Bool sell_condition_2()
{
Return Data[1].StopLoss(1,20);
}
Bool time_condition_Sell_1()
{
If(MakeDateTime(Date(),Time()) >= 0 And MakeDateTime(Date(),Time()) <= 20200221.211642)
{
Return True;
}
Return false;
}
Events
OnInit()
{
SetInitCapital(100000.000000);
SetConsecEntries(1);
SetCommissionRate(Enum_Rate_ByFillAmount,1.000000);
SetSlippage(Enum_Rate_PointPerHand,1.000000);
If(IsRollover)
{
AddDataFlag(Enum_Data_RolloverBackWard());
}
If(IsRolloverRealPrice)
{
AddDataFlag(Enum_Data_RolloverRealPrice());
}
If(IsAutoSwapPosition)
{
AddDataFlag(Enum_Data_AutoSwapPosition());
}
If(IgnoreSwapSiganlCalc)
{
AddDataFlag(Enum_Data_IgnoreSwapSignalCalc());
}
}
OnBar(ArrayRef<Integer> indexs)
{
bVarCondition_buy_3 = buy_condition_3();
dVarPrice_buy_1 = Close();
dVarPrice_buy_1_volume = round_volume(10.000000);
if(time_condition_Buy_1() And (bVarCondition_buy_3))
{
Buy(dVarPrice_buy_1_volume,dVarPrice_buy_1);
}
bVarCondition_sell_1 = sell_condition_1();
bVarCondition_sell_2 = sell_condition_2();
dVarPrice_sell_1 = Q_AskPrice();
dVarPrice_sell_1_volume = round_volume(10.000000);
if(time_condition_Sell_1() And (bVarCondition_sell_1 or bVarCondition_sell_2))
{
Sell(dVarPrice_sell_1_volume,dVarPrice_sell_1);
}
}
//------------------------------------------------------------------------
// 编译版本: 2020/01/21 212107
// 版权所有 TDF1234
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
|
|