- 精华
- 0
- 在线时间
- 125 小时
- UID
- 112394
- 积分
- 85
- 帖子
- 39
- 阅读权限
- 30
- 注册时间
- 2012-9-7
- 最后登录
- 2018-5-24
- 精华
- 0
- UID
- 112394
- 积分
- 85
- 帖子
- 39
- 主题
- 14
- 阅读权限
- 30
- 注册时间
- 2012-9-7
- 最后登录
- 2018-5-24
|
我自己有个人工手动的交易系统,但需要盯盘,有时上班被领导叫走,想借助TB实现某些反转点位的反手交易。这里解释一下,其实我是可以在文华软件中设置止损点,但我是需要等一根K线走完后根据收盘价位是否突破某些关键高低点位和均线的位置来判断。
有没有朋友能帮我看看以下的代码?如何用TB读取到我的现有持仓?十分感谢。
以下是针对RU,5分钟级别。
//------------------------------------------------------------------------
// 简称: RU_PP
// 名称: 5min_MA240_RU
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
Numeric Length1(10);
Numeric Length2(20);
Numeric Length3(30);
Numeric Length4(60);
Numeric Length5(120);
Numeric Length6(240);
Numeric Lots(1);
Numeric num_MinPoint(0);//控制冲击成本的大小
Numeric PreHighValue(13350);
Numeric PreLowValue(13170);
Vars
NumericSeries MA240;
Numeric MyPrice;
Numeric MinPoint; //类似于offset,1跳
Begin
If(!CallAuctionFilter())Return; //集合竞价过滤函数
PlotNumeric("MA1",AverageFC(Close,Length1));
PlotNumeric("MA2",AverageFC(Close,Length2));
PlotNumeric("MA3",AverageFC(Close,Length3));
PlotNumeric("MA4",AverageFC(Close,Length4));
PlotNumeric("MA5",AverageFC(Close,Length5));
PlotNumeric("MA6",AverageFC(Close,Length6));
PlotNumeric("PreHighValue",PreHighValue);
PlotNumeric("PreLowValue",PreLowValue);
MA240 = AverageFC(Close, Length6);
MinPoint=MinMove*PriceScale;
MarketPosition=-1;
//持有多单,在收盘价向下突破前低点且低于MA240时,反手做空
If(MarketPosition<>-1 && Close[1]<PreLowValue && Close[1]<MA240)
{
MyPrice = Open-num_MinPoint*MinPoint;
SellShort(Lots,MyPrice);
}
//持有空单,在收盘价向上突破前高点且高于MA240时,反手做多
If(MarketPosition<>1 && Close[1]>PreHighValue && Close[1]>MA240)
{
MyPrice = Open+num_MinPoint*MinPoint;
Buy(Lots,MyPrice);
}
End |
|