- 精华
- 0
- 在线时间
- 18 小时
- UID
- 233831
- 积分
- 10
- 帖子
- 5
- 阅读权限
- 10
- 注册时间
- 2016-5-5
- 最后登录
- 2016-11-4
- 精华
- 0
- UID
- 233831
- 积分
- 10
- 帖子
- 5
- 主题
- 4
- 阅读权限
- 10
- 注册时间
- 2016-5-5
- 最后登录
- 2016-11-4
|
本帖最后由 ta69440830 于 2016-10-28 23:09 编辑
Params
Numeric lots(1);
Vars
Bool startCondition2(False); // 启动条件,空单用
Bool EntryCondition2(False); // 开仓条件,空单用
Bool ExitCondition2(False); // 平仓条件,空单用
NumericSeries highestValue(0); // 前2个周期的最高价
NumericSeries lowestValue(0); // 前2个周期的最低价
Numeric myEntryPrice2(0); // 开仓价格,空单用
Numeric myExitPrice2(0); // 平仓价格,空单用
Begin
highestValue = max(high[2],high[1]);
lowestValue = min(low[2],low[1]);
If(MarketPosition ==0 ) // 当前空仓
{
if (Close[2]< Open[2] && Close[1] < Open[1] && Close[1] < Close[2])
{
startCondition2 = True;
}
If(startCondition2)
{
EntryCondition2
If( EntryCondition2)
{
sellshort(lots,Open);
}Else // 再看其它价格是否满足
{
EntryCondition2
If(EntryCondition2)
{
myEntryPrice2 = highestValue - (HighestValue - LowestValue ) ;
myEntryPrice2 = IntPart(myEntryPrice2 / (PriceScale()*MinMove)) *(PriceScale()*MinMove); // 对价格进行处理
If(myEntryPrice2 >= low && myEntryPrice2 <= High)
{
sellshort(lots,MyEntryPrice2);
}
}
}
}
}
If(MarketPosition == -1) // 当前空仓
{
ExitCondition2
If(ExitCondition2)
{
myExitPrice2 = highestValue - (HighestValue - LowestValue ) ;
myExitPrice2 = IntPart(myExitPrice2 / (PriceScale()*MinMove)) *(PriceScale()*MinMove); // 对价格进行处理
buytocover(CurrentContracts(),myExitPrice2);
}Else // 获利平仓
{
ExitCondition2 ; // 获利平仓条件满足
If(ExitCondition2)
{
myExitPrice2 = AvgEntryPrice() - (HighestValue - LowestValue );
myExitPrice2 = IntPart(myExitPrice2 / (PriceScale()*MinMove)) *(PriceScale()*MinMove); // 对价格进行处理
If (myExitPrice2 >= low && myEntryPrice2 <= high)
{
buytocover (lots,myExitPrice2);
}Else
{
buytocover (lots,Close);
}
}
}
}
End |
|