- 精华
- 0
- 在线时间
- 87 小时
- UID
- 100877
- 积分
- 180
- 帖子
- 66
- 阅读权限
- 40
- 注册时间
- 2012-2-27
- 最后登录
- 2020-3-26
- 精华
- 0
- UID
- 100877
- 积分
- 180
- 帖子
- 66
- 主题
- 14
- 阅读权限
- 40
- 注册时间
- 2012-2-27
- 最后登录
- 2020-3-26
|
沪胶指数3月7日,五分钟线,没到止损价就止损了,
Params
Numeric Length(14);
Numeric SlowLength(3);
Numeric SmoothLength(3);
Numeric Length1(20);
Numeric Offset(2);
Vars
NumericSeries HighestValue;
NumericSeries LowestValue;
NumericSeries KValue;
Numeric SumHLValue;
Numeric SumCLValue;
Numeric DValue;
NumericSeries UpLine; //上轨
NumericSeries DownLine; //下轨
NumericSeries MidLine; //中间线
Numeric Band;
Numeric StartTime(09.00);
Numeric EndTime1(14.40);
Numeric EndTime(14.55);
Numeric MinPoint; // 一个最小变动单位,也就是一跳
Numeric MyEntryPrice; // 开仓价格,本例是开仓均价,也可根据需要设置为某次入场的价格
Numeric TakeProfitSet(10000); // 止赢设置
Numeric StopLossSet(50); // 止损设置
Numeric MyExitPrice; // 平仓价格
Begin
MinPoint = MinMove*PriceScale;
MyEntryPrice = AvgEntryPrice;
HighestValue = HighestFC(High, Length);
LowestValue = LowestFC(Low, Length);
SumHLValue = SummationFC(HighestValue-LowestValue,SlowLength);
SumCLValue = SummationFC(Close - LowestValue,SlowLength);
If(SumHLValue <> 0)
{
KValue = SumCLValue/SumHLValue*100;
}Else
{
KValue = 0;
}
DValue = AverageFC(KValue,SmoothLength);
//开仓
If(time>=StartTime/100 && time<EndTime1/100 )
{
If(CrossOver(KValue,20))//||CrossOver(DValue,20))
{
Buy(1,Close);
}
If(CrossUnder(KValue,80))//||CrossUnder(DValue,80))
{
SellShort(1,Close);
}
}
//止损
If(MarketPosition==1) // 有多仓的情况
{
If(High >= MyEntryPrice + TakeProfitSet*MinPoint) // 止赢条件表达式
{
MyExitPrice = MyEntryPrice + TakeProfitSet*MinPoint;
If(Open > MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
Sell(0,MyExitPrice);
}else if(Low <= MyEntryPrice - StopLossSet*MinPoint)// 止损条件表达式
{
MyExitPrice = MyEntryPrice - StopLossSet*MinPoint;
If(Open < MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
Sell(0,MyExitPrice);
}
}else if(MarketPosition==-1) // 有空仓的情况
{
If(Low <= MyEntryPrice - TakeProfitSet*MinPoint) // 止赢条件表达式
{
MyExitPrice = MyEntryPrice - TakeProfitSet*MinPoint;
If(Open < MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
BuyToCover(0,MyExitPrice);
}else if(High >= MyEntryPrice + StopLossSet*MinPoint)// 止损条件表达式
{
MyExitPrice = MyEntryPrice + StopLossSet*MinPoint;
If(Open > MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
BuyToCover(0,MyExitPrice);
}
}
//收盘平仓
If(Time>=EndTime/100)
{
sell(0,Close);
BuyToCover(0,close);
}
End
|
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
|