首页 > > 详细

代写股票选股公式、TB交易策略调试、日内转向加仓交易系统模型TB源码

//------------------------------------------------------------------------
// 简称: DayChangeTrenchV1
// 名称: 日内转向加仓交易系统模型TB源码
// 类别: 公式应用
// 类型: 用户应用
//------------------------------------------------------------------------
Params
BoolbInitStatues(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 (DateDate[1])
{
HighAfterLongEntry=High;
LowAfterShortEntry=Low;
MyRealMp=0;
}Else
{
HighAfterLongEntry=Max(HighAfterLongEntry,High);
LowAfterShortEntry=Min(Low,LowAfterShortEntry);
} //
If (Time0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint
And(High-Low=TrailingGrid*MinPoint And close=TrailingGrid*MinPoint
And(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 =(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
// 空单加仓
if (MyRealMp=(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

联系我们 - QQ: 88652583
© 2014 www.93stock.com
代写选股公式网!
声明:警惕假冒分子冒充本站提供证券咨询服务,选股公式网为非证券咨询机构,本站不提供有关股评、投资分析报告、股市预测,证券咨询等服务。本站仅提供股票、期货、黄金、外汇的软件技术交流与分享。本站文章为互联网文章,其仅供参考,并不构成投资建议。