- 精华
- 0
- 在线时间
- 29 小时
- UID
- 269548
- 积分
- 38
- 帖子
- 21
- 阅读权限
- 10
- 注册时间
- 2018-9-4
- 最后登录
- 2019-11-16
- 精华
- 0
- UID
- 269548
- 积分
- 38
- 帖子
- 21
- 主题
- 11
- 阅读权限
- 10
- 注册时间
- 2018-9-4
- 最后登录
- 2019-11-16
|
Params
Numeric K1(50);
Numeric K2(7);
Numeric nOffSet(0);
Numeric stopLossSet(100);
Vars
NumericSeries a1;
NumericSeries a2;
Numeric MinPoint;
Numeric MyEntryPrice;
Numeric MyExitPrice;
Numeric stopLossPoint;
Numeric offSetDots;
bool cross1;
bool cross2;
Begin
offSetDots = nOffSet * MinMove * PriceScale;
a1=Highest(high[1],K1);
a2=Lowest(low[1],K2);
cross1=CrossOver(high,a1);
cross2=CrossUnder(low,a2);
If(cross1 && MarketPosition<>1)
{
Buy(1,a1+offSetDots);
}
If(cross2 && MarketPosition<>-1)
{
SellShort(1,a2-offSetDots);
}
stopLossPoint = stopLossSet * MinMove * PriceScale;
If(MarketPosition == 1)
{
myEntryPrice = AvgEntryPrice;
If(low <= myEntryPrice - stopLossPoint)
{
myExitPrice = myEntryPrice - stopLossPoint;
If(open < myExitPrice) myExitPrice = open;
Sell(0,myExitPrice);
}
}
else If (MarketPosition == -1)
{
myEntryPrice = AvgEntryPrice;
If(High >= myEntryPrice + stopLossPoint)
{
myExitPrice = myEntryPrice + stopLossPoint;
If(open > myExitPrice) myExitPrice = open;
BuyToCover(0,myExitPrice);
}
}
End
|
|