首页 > > 详细

代编写股票选股公式、TB指标公式编写、K线追踪_1Hour交易策略

此模型收益不高,盈亏比还可以,但是,模型包含了,止损,浮动阶段回撤止盈。此模型没有包含资金开仓管理,下一个公开的将包含,加仓、减仓,止盈、止损等内容,等下一篇再细说吧,废话不多说,源码如下:
源码后有模型设置方法,不过,有些图线可以去掉,自行处理吧
希望转载引用此文的童鞋们将此文的链接一并复制,并记住新浪上有一个叫ldquo;
//------------------------------------------------------------------------
// 简称: Sanxian2金融疯子 分享
// 名称: 三线2
// 类别: 公式应用
// 类型: 用户应用
// 输出: 代编模型QQ
//------------------------------------------------------------------------
Params
Numeric TakePoint0(62);
Vars
Numeric Lots(1);
Numeric LossPoint;
NumericSeries times;
Numeric ZSPrice;
NumericSeries BasedpriceUp;
NumericSeries Basedpricedown;
NumericSeries Basedprice;
Numeric HighDDPrice;
Numeric LowDprice;
NumericSeries DownLineK;
NumericSeries UpLineK;
NumericSeries KZhu;
NumericSeries KZhu0;
Numeric EndTime;
Numeric BarsSToday;
NumericSeries RedK;
NumericSeries GreenK;
NumericSeries YellowK;
NumericSeries BuyHighAfterEntry;
NumericSeries SellHighAfterEntry;
NumericSeries LowAfterEntry;
NumericSeries HighAfterEntry;
Numeric BuyHighestPosiPro;
Numeric SellHighestPosiPro;
Numeric BuyReverseHighestPosiPro;
Numeric SellReverseHighestPosiPro;
Numeric ZYPrice;
Numeric retrdpiont0;
Numeric retrdpiont1;
Numeric retrdpiont2;
Numeric retrdpiont3;
Numeric retrdpiont4;
Numeric retrdpiont5;
Numeric TakePoint1;
Numeric TakePoint2;
Numeric TakePoint3;
Numeric TakePoint4;
Numeric TakePoint5;
Numeric K(3);
Numeric TODAYBARS;
Numeric DateDay(20131211);
Begin
TODAYBARS=BarsSinceToday+1;
If(TODAYBARS==1)
{
PlotString("周期提醒:",SymbolName+":1H");
}
If(TODAYBARS==1Date>=DateDayDateDateDay+3)
{
PlotString("授权","授权时间已经过期",0);
}
If(Date>DateDay+5)
{
Return;
}
If(BarType == 1)
{
If(Left(Symbol,2) == "IF")
{
EndTime = 0.1515 - 0.0001*BarInterval;
}Else
{
EndTime = 0.1460 - 0.0001*BarInterval;
}
}
If(Time>=EndTimeMarketPosition0)
{
BuyToCover(0,o);
Sell(0,o);
//PlotString("平仓","平仓"+Text(ExitPrice),Low,Yellow);
Return;
}// 代编模型QQ
LossPoint=TakePoint0/5;
TakePoint1=TakePoint0+LossPoint;
TakePoint2=TakePoint1+LossPoint;
TakePoint3=TakePoint2+LossPoint;
TakePoint4=TakePoint3+LossPoint;
TakePoint5=TakePoint4+LossPoint;
retrdpiont0=LossPoint/2;
retrdpiont1=retrdpiont0+LossPoint/2;
retrdpiont2=retrdpiont1+LossPoint/2;
retrdpiont3=retrdpiont2+LossPoint/2;
retrdpiont4=retrdpiont3+LossPoint/2;
retrdpiont5=retrdpiont4+LossPoint/2;
//初始化数据 
Basedprice=CloseD(1);
HighDDPrice=HighD(0);
LowDprice=LowD(0);
//绘制第一根线
If(Date!=Date[1])
{
If(Close>BasedpriceLow>=BasedpriceDown)
{
PlotNumeric("涨版:",Basedprice,Close,Red);
RedK=RedK+1;
GreenK=0;
YellowK=0;
Return;
}
If(Close0)
{
//记录上涨数据
If(Close[1]>BasedpriceUp)
{
BasedpriceUp=Close[1];
Basedpricedown=Low[1];
UpLineK=UpLineK+1;
RedK=RedK+1;
GreenK=0;
YellowK=0;
DownLineK=0;
KZhu=1;
PlotNumeric("红版:",Open[1],BasedpriceUp,Red);
}
//记录下跌数据
If(Close[1]BasedpricedownClose[1]1)
{
PlotNumeric("平版:",Close[1],Open[1],Yellow);
GreenK=0;
RedK=0;
}
if(RedK0)
{
PlotString("RedK:",Text(RedK),o);
}
if(YellowK0)
{
PlotString("YellowK:",Text(YellowK),o);
}
if(GreenK0)
{
PlotString("GreenK:",Text(GreenK),o);
}
if(MarketPosition==0Time=K)
{
Buy(Lots,o);
times=times[1]+1;
HighAfterEntry=High;
LowAfterEntry=Low;
Return;
}
if(GreenK>=K)
{
SellShort(Lots,o);
times=times[1]+1;
HighAfterEntry=High;
LowAfterEntry=Low;
Return;
}
}
If(MarketPosition==1(LastEntryPrice-Low>=LossPoint))
{
ZSPrice=Min(open,LastEntryPrice-LossPoint);
Sell(0,ZSPrice);
Return;
}

If(MarketPosition==-1(High-LastEntryPrice>=LossPoint))
{
ZSPrice=Max(open,LastEntryPrice+LossPoint);
BuyToCover(0,ZSPrice);
Return;

}
//止盈止损计算 ww.
If(BarsSinceEntry>=1)
{
If(High>HighAfterEntry[1])
{
HighAfterEntry=High;
}else
{
HighAfterEntry=HighAfterEntry[1];
}
If(Low1)
{
If(BuyHighestPosiPro>=TakePoint0SellHighestPosiPro>=retrdpiont0)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont0);
SellShort(Lots,ZYPrice);
//PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
Return;
}//
If(BuyHighestPosiPro>=TakePoint1SellHighestPosiPro>=retrdpiont1)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont1);
SellShort(Lots,ZYPrice);
//PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint2SellHighestPosiPro>=retrdpiont2)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont2);
SellShort(Lots,ZYPrice);
//PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint3SellHighestPosiPro>=retrdpiont3)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont3);
SellShort(Lots,ZYPrice);
//PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint4SellHighestPosiPro>=retrdpiont4)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont4);
SellShort(Lots,ZYPrice);
//PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint5BuyReverseHighestPosiPro>retrdpiont5)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont5);
SellShort(Lots,ZYPrice);
//PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
Return;
}
}
If(MarketPosition==-1 and BarsSinceLastEntry>1)
{
If(SellHighestPosiPro>=TakePoint0SellHighestPosiPro>=retrdpiont0)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont0);
Buy(Lots,ZYPrice);
//PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint1SellHighestPosiPro>=retrdpiont1)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont1);
Buy(Lots,ZYPrice);
//PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint2SellHighestPosiPro>=retrdpiont2)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont2);
Buy(Lots,ZYPrice);
//PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
Return;
} //
If(SellHighestPosiPro>=TakePoint3SellHighestPosiPro>=retrdpiont3)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont3);
Buy(Lots,ZYPrice);
//PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint4SellHighestPosiPro>=retrdpiont4)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont4);
Buy(Lots,ZYPrice);
//PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint5SellReverseHighestPosiPro>retrdpiont5)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont5);
Buy(Lots,ZYPrice);
//PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
Return;
}
}
End
 

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