- 精华
- 0
- 在线时间
- 40 小时
- UID
- 170538
- 积分
- 51
- 帖子
- 14
- 阅读权限
- 30
- 注册时间
- 2013-8-22
- 最后登录
- 2020-4-24
- 精华
- 0
- UID
- 170538
- 积分
- 51
- 帖子
- 14
- 主题
- 3
- 阅读权限
- 30
- 注册时间
- 2013-8-22
- 最后登录
- 2020-4-24
|
//------------------------------------------------------------------------
// 简称: MYBOll
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
Numeric Length(20);
Numeric Offset(2);
Numeric ATRLength(20);
Numeric RiskRatio(1);
numeric width(0.1);
numeric width2(0.5);
Vars
NumericSeries UpLine; //上轨
NumericSeries DownLine; //下轨
NumericSeries MidLine; //中间线
Numeric Band;
numeric with;
Numeric MinPoint; // 最小变动单位
NumericSeries AvgTR; // ATR
Numeric N; // N 值
Numeric TotalEquity; // 按最新收盘价计算出的总资产
Numeric TurtleUnits;
NumericSeries preEntryPrice(0);
numeric myEntryPrice;
Begin
MidLine = AverageFC(Close,Length);
Band = StandardDev(Close,Length,2);
UpLine = MidLine + Offset * Band;
DownLine = MidLine - Offset * Band;
with=(upline-DownLine)/MidLine;
PlotNumeric("UpLine",UpLine);
PlotNumeric("DownLine",DownLine);
PlotNumeric("MidLine",MidLine);
MinPoint = MinMove*PriceScale;
AvgTR = XAverage(TrueRange,ATRLength);
If(!CallAuctionFilter()) Return;
If(MarketPosition == 0)
If(with<width && MidLine[2]<MidLine[1] && high[1]>upline[1])//如果布林线宽小于0.05并且布林轨道中线向上,并且最高价上穿布林上轨;
myEntryPrice = min(high,upline + MinPoint);
myEntryPrice = IIF(myEntryPrice < Open, Open,myEntryPrice); // 大跳空的时候用开盘价代替
Buy(1,myEntryPrice);
If(with<width && MidLine[2]>MidLine[1] && Low[1]<DownLine[1])
myEntryPrice = max(low,DownLine - MinPoint);
myEntryPrice = IIF(myEntryPrice > Open, Open,myEntryPrice); // 大跳空的时候用开盘价代替
SellShort(1,myEntryPrice);
If(marketposition!=0)
If(with>width2)
Sell(0,open- MinPoint);
BuyToCover(0,open+minpoint);
End
|
|