- 精华
- 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
|
编好了,在ru0801上好像还可以
- Params
- Numeric shortLength(15);
- Numeric longLength(90);
- Numeric StopPoint(100);
- Numeric ProfitPoint(300);
- Vars
- NumericSeries AvgClose1;
- NumericSeries AvgClose2;
- Numeric lots(1);
- Numeric myExitPrice;
- Begin
- AvgClose1 = AverageFC(Close,shortLength); // 短均线
- AvgClose2 = AverageFC(Close,longLength); // 长均线
-
- If(Time > 0.0910 && Time < 0.1450) // 时间限制
- {
- If(MarketPosition !=1 && CrossOver(AvgClose1,AvgClose2)) // 当前无持仓或有空仓,才可以开多(会自动平空)
- {
- Buy(lots,NextOpen,True); // K线走完才发单
- }
- If(MarketPosition !=-1 && CrossUnder(AvgClose1,AvgClose2))// 当前无持仓或有多仓,才可以开空(会自动平多)
- {
- SellShort(lots,NextOpen,True);// K线走完才发单
- }
- }
-
- // 止损
- If(MarketPosition == 1)
- {
- If(Low < AvgEntryPrice - StopPoint * MinMove*PriceScale)
- {
- myExitPrice = AvgEntryPrice - (StopPoint+1) * MinMove*PriceScale;
- myExitPrice = max(low,myExitPrice);
- Sell(lots,myExitPrice);
- }
- }Else If(MarketPosition == -1)
- {
- If(High > AvgEntryPrice + StopPoint * MinMove*PriceScale)
- {
- myExitPrice = AvgEntryPrice + (StopPoint+1) * MinMove*PriceScale;
- myExitPrice = min(high,myExitPrice);
- BuyToCover(lots,myExitPrice);
- }
- }
-
- // 止赢
- If(MarketPosition == 1)
- {
- If(High > AvgEntryPrice + ProfitPoint * MinMove*PriceScale)
- {
- myExitPrice = AvgEntryPrice + ProfitPoint * MinMove*PriceScale;
- Sell(lots,myExitPrice);
- }
- }Else If(MarketPosition == -1)
- {
- If( Low < AvgEntryPrice - ProfitPoint * MinMove*PriceScale)
- {
- myExitPrice = AvgEntryPrice - ProfitPoint* MinMove*PriceScale;
- BuyToCover(lots,myExitPrice);
- }
- }
-
- If(BarStatus == 2) // 收盘平仓
- {
- If(Time >= 0.1455 && MarketPosition != 0)
- {
- Sell;
- BuyToCover;
- }
- }Else
- {
- SetExitOnClose;
- }
- End
复制代码 |
|