日内转向加仓交易系统模型TB源码[开拓者公式]
//------------------------------------------------------------------------
// 简称: DayChangeTrenchV1
// 名称: 日内转向加仓交易系统模型TB源码
// 类别: 公式应用
// 类型: 用户应用
//------------------------------------------------------------------------
Params
Bool bInitStatues(false); // 初始化标志,修改初始仓位时需设置为True
Numeric InitMyRealMp(0); // 初始化当前仓位,正数表示多单,负数表示空单
Numeric FirstGrid(30); // 第一笔交易的间距,最小跳动;
Numeric AddGrid(5); // 加仓间距,最小跳动
Numeric TotalGrids(10); // 最大交易次数
Numeric TrailingGrid(30); // 移动止损间距,最小跳动
Numeric EveryLots(1); // 每次开仓手数
Numeric OffSet(1); // 委托价偏差,默认买卖价偏差为1个滑点
Numeric ExitOnCloseMins(14.58); //收盘平仓时间
Vars
Numeric HighAfterLongEntry;
Numeric LowAfterShortEntry;
Numeric MyRealMp(0);
Numeric MinPoint;
Numeric tmpPrice;
Numeric tmpLots;
Begin
MinPoint=Minmove*PriceScale;
MyRealMp=GetGlobalVar(0);
HighAfterLongEntry=GetGlobalVar(1);
LowAfterShortEntry=GetGlobalVar(2);
if (BarStatus==0 And (MyRealMp==InvalidNumeric || bInitStatues))
{
MyRealMp=InitMyRealMp;
}
if (Date<>Date[1])
{
HighAfterLongEntry=High;
LowAfterShortEntry=Low;
MyRealMp=0;
}Else
{
HighAfterLongEntry=Max(HighAfterLongEntry,High);
LowAfterShortEntry=Min(Low,LowAfterShortEntry);
} // www.cxh99.com
If (Time<ExitOnCloseMins/100)
{
If ( MyRealMp>0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint
And(High-Low<TrailingGrid*MinPoint Or(High-Low>=TrailingGrid*MinPoint And close<Open)))
{
tmpPrice=Max(HighAfterLongEntry-(TrailingGrid-OffSet)*MinPoint,Low);
tmpLots=Abs(MyRealMp*EveryLots);
Sell(tmpLots,tmpPrice);
MyRealMp=0;
LowAfterShortEntry=Low;
}Else
If ( MyRealMp<0 And High-LowAfterShortEntry>=TrailingGrid*MinPoint
And(High-Low<TrailingGrid*MinPoint Or(High-Low>=TrailingGrid*MinPoint And close>Open)))
{
tmpPrice=Min(LowAfterShortEntry+(TrailingGrid+OffSet)*MinPoint,High);
tmpLots=Abs(MyRealMp*EveryLots);
BuyToCover(tmpLots,tmpPrice);
MyRealMp=0;
HighAfterLongEntry=0;
}
// 第一笔多单开仓
if (MyRealMp==0 And High-LowAfterShortEntry>=FirstGrid*MinPoint)
{
tmpPrice=Min(LowAfterShortEntry+(FirstGrid+OffSet)*MinPoint,High);
tmpLots=EveryLots;
Buy(tmpLots,tmpPrice);
MyRealMp=1;
HighAfterLongEntry=High;
}Else
// 多单加仓
if (MyRealMp> 0 And MyRealMp <TotalGrids And High-LowAfterShortEntry>=(FirstGrid+MyRealMp*AddGrid)
*MinPoint)
{
tmpPrice=Min(LowAfterShortEntry+(FirstGrid+MyRealMp*AddGrid+OffSet)*MinPoint,High);
tmpLots=EveryLots;
Buy(tmpLots,tmpPrice);
MyRealMp=MyRealMp+1;
}Else
// 第一笔空单开仓
if (MyRealMp==0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint )
{
tmpPrice=Max(HighAfterLongEntry-(FirstGrid-OffSet)*MinPoint,Low);;
tmpLots=EveryLots;
SellShort(tmpLots,tmpPrice);
MyRealMp=-1;
LowAfterShortEntry=Low ;
}Else
// 空单加仓 www.cxh99.com
if (MyRealMp< 0 And -1*MyRealMp <TotalGrids And HighAfterLongEntry-Low>=(FirstGrid+MyRealMp*AddGrid)
*MinPoint)
{
tmpPrice=Max(HighAfterLongEntry-(FirstGrid-Abs(MyRealMp*AddGrid)-OffSet)*MinPoint,High);
tmpLots=EveryLots;
SellShort(tmpLots,tmpPrice);
MyRealMp=MyRealMp-1;
}
}Else
If (Time>ExitOnCloseMins/100)
{
If (MyRealMp>0)
{
tmpLots=Abs(MyRealMp*EveryLots);
tmpPrice=Close;
Sell(tmpLots,tmpPrice);
MyRealMp=0;
}
If(MyRealMp<0)
{
tmpLots=Abs(MyRealMp*EveryLots);
tmpPrice=Close;
BuyToCover(tmpLots,tmpPrice);
MyRealMp=0;
}
}
SetGlobalVar(0,MyRealMp);
SetGlobalVar(1,HighAfterLongEntry);
SetGlobalVar(2,LowAfterShortEntry);
Commentary("MyRealMp="+Text(MyRealMp));
Commentary("HighAfterLongEntry="+Text(HighAfterLongEntry));
Commentary("LowAfterShortEntry="+Text(LowAfterShortEntry));
//SetExitOnClose;
End
//------------------------------------------------------------------------
// 编译版本GS2010.12.08
// 用户版本2012/03/17 16:00
// 版权所有 www.cxh99.com QQ 1145508240
// 更改声明TradeBlazer Software保留对TradeBlazer平台
//每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 1145508240 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容