- 精华
- 20
- 在线时间
- 2981 小时
- UID
- 4
- 积分
- 22709
- 帖子
- 4802
- 阅读权限
- 255
- 注册时间
- 2007-7-20
- 最后登录
- 2024-1-15
- 精华
- 20
- UID
- 4
- 积分
- 22709
- 帖子
- 4802
- 主题
- 64
- 阅读权限
- 255
- 注册时间
- 2007-7-20
- 最后登录
- 2024-1-15
|
你的upline,dnline计算有问题。
完整代码如下:- Params
- Numeric offset(10);
- Numeric stoplossSet(5);
- Vars
- Numeric MyEntryPrice;
- NumericSeries upline;
- NumericSeries downline;
- Bool Condition1;
- Bool Condition2;
- BoolSeries bShortStoped;
- BoolSeries bLongStoped;
- Begin
- if(CurrentBar == 0 || Date != Date[1])
- {
- bShortStoped = False ;
- bLongStoped = False ;
- upline = Close[1] + offset;
- downline = Close[1] - offset;
- } Else
- {
- Condition1 =( MarketPosition == 0 && High> upline && bShortStoped == False && Time < 0.151000);
- Condition2 = (MarketPosition == 0 && Low< downline && bLongStoped == False && Time < 0.151000);
-
- Commentary("Condition1="+IIFString(Condition1,"True","False"));
- Commentary("Condition2="+IIFString(Condition2,"True","False"));
- PlotNumeric ("upline",upline) ;
- PlotNumeric ("dowmline",downline) ;
- }
-
- if (Condition1)
- {
- MyEntryPrice=Min(open,upline-0.2);
- SellShort(1,MyEntryPrice);
- }
-
- if (Condition2)
- {
- MyEntryPrice = Max(open,downline+0.2);
- Buy(1,MyEntryPrice);
- }
-
-
- If(MarketPosition==1 && Low <= AvgEntryPrice - StopLossSet && BarsSinceEntry>0)
- {
- Sell(1,Min(Open,AvgEntryPrice - StopLossSet));
- bLongStoped = True;
- }
- if(MarketPosition==-1 && High >= AvgEntryPrice + StopLossSet && BarsSinceEntry>0)
- {
- BuyToCover(1,Max(AvgEntryPrice + StopLossSet,open));
- bShortStoped = True;
- }
-
- if(Time >= 0.1513)
- {
- BuyToCover(1,Open);
- Sell(1,Open);
- }
- End
复制代码 |
|