K線追蹤_1Hour交易策略[開拓者公式]
此模型收益不高,盈虧比還可以,但是,模型包含了,止損,浮動階段回撤止盈。此模型沒有包含資金開倉管理,下一個公開的將包含,加倉、減倉,止盈、止損等內容,等下一篇再細說吧,廢話不多說,源碼如下:
源碼后有模型設置方法,不過,有些圖線可以去掉,自行處理吧
希望轉載引用此文的童鞋們將此文的鏈接一并復制,并記住新浪上有一個叫“金融瘋子”的王童鞋
//------------------------------------------------------------------------
// 簡稱: Sanxian2 金融瘋子 分享
// 名稱: 三線2
// 類別: 公式應用
// 類型: 用戶應用
// 輸出: 代編模型QQ 1145508240
//------------------------------------------------------------------------
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==1&&Date>=DateDay&&Date<=DateDay+5)
{
PlotString("授權","授權時間即將過期",0);
}
If(TODAYBARS==1&&Date>DateDay+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>=EndTime&&MarketPosition<>0)
{
BuyToCover(0,o);
Sell(0,o);
//PlotString("平倉","平倉"+Text(ExitPrice),Low,Yellow);
Return;
}// 代編模型QQ 1145508240
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;
//初始化數據 m.kzuj.com.cn
Basedprice=CloseD(1);
HighDDPrice=HighD(0);
LowDprice=LowD(0);
//繪制第一根線
If(Date!=Date[1])
{
If(Close>Basedprice&&Low>=BasedpriceDown)
{
PlotNumeric("漲版:",Basedprice,Close,Red);
RedK=RedK+1;
GreenK=0;
YellowK=0;
Return;
}
If(Close<=BasedpriceUp)
{
PlotNumeric("跌版:",Close,Basedprice,Green);
GreenK=GreenK+1;
RedK=0;
YellowK=0;
Return;
}
If(Close==Basedprice)
{
UnPlot("漲版:");
UnPlot("跌版:");
}
}
//繪制第二根線
If(Date!=Date[1])
{
times=0;
YellowK=0;
RedK=0;
GreenK=0;
BasedpriceUp=HighDDPrice;
Basedpricedown=LowDprice;
UpLineK=0;
DownLineK=0;
KZhu=0;
KZhu0=1;
}Else
{
times=times[1];
UpLineK=UpLineK[1];
DownLineK=DownLineK[1];
KZhu=KZhu[1];
KZhu0=KZhu0[1];
YellowK=YellowK[1];
RedK=RedK[1];
GreenK=GreenK[1];
}
If(BarStatus>0)
{
//記錄上漲數據
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]<Basedpricedown[1])
{
BasedpriceUp=High[1];
Basedpricedown=Close[1];
DownLineK=DownLineK+1;
GreenK=GreenK+1;
YellowK=0;
RedK=0;
UpLineK=0;
KZhu=1;
PlotNumeric("綠版:",BasedpriceUp,Open[1],Green);
}
}
If(Close[1]>Basedpricedown&&Close[1]<BasedpriceUp[1])
{
BasedpriceUp=BasedpriceUp[1];
Basedpricedown=Basedpricedown[1];
KZhu=0;
PlotNumeric("平版:",Close[1],Open[1],Yellow);
YellowK=YellowK+1;
GreenK=0;
RedK=0;
}
If(KZhu==1)
{
KZhu0=1;
}Else
{
KZhu0=0;
}
If(KZhu0==0&&BarsSToday>1)
{
PlotNumeric("平版:",Close[1],Open[1],Yellow);
GreenK=0;
RedK=0;
}
if(RedK<>0)
{
PlotString("RedK:",Text(RedK),o);
}
if(YellowK<>0)
{
PlotString("YellowK:",Text(YellowK),o);
}
if(GreenK<>0)
{
PlotString("GreenK:",Text(GreenK),o);
}
if(MarketPosition==0&&Time<0.1450)
{
if(RedK>=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.cxh99.com
If(BarsSinceEntry>=1)
{
If(High>HighAfterEntry[1])
{
HighAfterEntry=High;
}else
{
HighAfterEntry=HighAfterEntry[1];
}
If(Low<LowAfterEntry[1])
{
LowAfterEntry=Low;
}else
{
LowAfterEntry=LowAfterEntry[1];
}
}
BuyHighestPosiPro=HighAfterEntry[1]-EntryPrice;
SellHighestPosiPro=EntryPrice-LowAfterEntry[1];
BuyReverseHighestPosiPro=HighAfterEntry[1]-Low;
SellReverseHighestPosiPro=High-LowAfterEntry[1];
If(MarketPosition==1 and BarsSinceLastEntry>1)
{
If(BuyHighestPosiPro>=TakePoint0&&SellHighestPosiPro>=retrdpiont0)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont0);
SellShort(Lots,ZYPrice);
//PlotString("多止贏","多止贏"+Text(ExitPrice),Low,Yellow);
Return;
}// m.kzuj.com.cn
If(BuyHighestPosiPro>=TakePoint1&&SellHighestPosiPro>=retrdpiont1)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont1);
SellShort(Lots,ZYPrice);
//PlotString("多止贏","多止贏"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint2&&SellHighestPosiPro>=retrdpiont2)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont2);
SellShort(Lots,ZYPrice);
//PlotString("多止贏","多止贏"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint3&&SellHighestPosiPro>=retrdpiont3)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont3);
SellShort(Lots,ZYPrice);
//PlotString("多止贏","多止贏"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint4&&SellHighestPosiPro>=retrdpiont4)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont4);
SellShort(Lots,ZYPrice);
//PlotString("多止贏","多止贏"+Text(ExitPrice),Low,Yellow);
Return;
}
If(BuyHighestPosiPro>=TakePoint5&&BuyReverseHighestPosiPro>retrdpiont5)
{
ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont5);
SellShort(Lots,ZYPrice);
//PlotString("多止贏","多止贏"+Text(ExitPrice),Low,Yellow);
Return;
}
}
If(MarketPosition==-1 and BarsSinceLastEntry>1)
{
If(SellHighestPosiPro>=TakePoint0&&SellHighestPosiPro>=retrdpiont0)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont0);
Buy(Lots,ZYPrice);
//PlotString("空止贏","空止贏"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint1&&SellHighestPosiPro>=retrdpiont1)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont1);
Buy(Lots,ZYPrice);
//PlotString("空止贏","空止贏"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint2&&SellHighestPosiPro>=retrdpiont2)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont2);
Buy(Lots,ZYPrice);
//PlotString("空止贏","空止贏"+Text(ExitPrice),High,Yellow);
Return;
} // m.kzuj.com.cn
If(SellHighestPosiPro>=TakePoint3&&SellHighestPosiPro>=retrdpiont3)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont3);
Buy(Lots,ZYPrice);
//PlotString("空止贏","空止贏"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint4&&SellHighestPosiPro>=retrdpiont4)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont4);
Buy(Lots,ZYPrice);
//PlotString("空止贏","空止贏"+Text(ExitPrice),High,Yellow);
Return;
}
If(SellHighestPosiPro>=TakePoint5&&SellReverseHighestPosiPro>retrdpiont5)
{
ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont5);
Buy(Lots,ZYPrice);
//PlotString("空止贏","空止贏"+Text(ExitPrice),High,Yellow);
Return;
}
}
End
//------------------------------------------------------------------------
// 編譯版本 GS2010.12.08
// 用戶版本 2013/01/21 11:43
// 版權所有 baoshan6997 m.kzuj.com.cn
// 更改聲明 TradeBlazer Software保留對TradeBlazer平臺
// 每一版本的TrabeBlazer公式修改和重寫的權利
//------------------------------------------------------------------------
將最后一圖中的前7個都設置為柱線,線寬設置為最粗,OK
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 1145508240 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容