這是個很簡單的策略…把開盤價上下各抓一個 range 出來…然後,突破作多、跌破作空…圖中兩條黑橫線就是多點和空點…只要盤勢往上走並突破後…就買進;如果買進後跌至停損點就停損。
在停損之後下一根 k 線的開盤價,當成是新的一天開盤…接著再用這個開盤價算出新的多點和空點…很簡單吧…這麼簡單的東西會有什麼好績效嗎?
想當然爾…沒有多好…不過交易次數倒還滿高的…我的手續費可是來回設二千啊…每次省個八百下來的話…獲利可以提升六十幾萬…應該算是很不錯了吧…而且程式還沒設定停利機制…也許加個停利會更好也說不定…
所以…想法不要太複雜…往簡單的方向走說不定會有更好的成績出來…程式碼就開放給大家玩玩囉。
vars:topen(0),openhigh(0), openlow(0), count(0), stoploss(30), hlrange(80);
if date[0] <> date[1] then begin
topen = 0;
openhigh = 0;
openlow = 0;
count = 0;
end;
if time = 0850.00 then begin
topen = opend(0);
openhigh = topen + hlrange;
openlow = topen - hlrange;
end;
if count = 0 and marketposition = 0 and time < 1330.00 and time > 0850.00 and high > openhigh then begin
buy ("b1") next bar at market;
count = 1;
end;
if count = 0 and marketposition = 0 and time < 1330.00 and time > 0850.00 and low < openlow then begin
sell ("s1") next bar at market;
count = 1;
end;
if marketposition > 0 then
exitlong next bar at entryprice(0)-stoploss stop;
if marketposition < 0 then
exitshort next bar at entryprice(0)+stoploss stop;
if marketposition = 0 and count = 1 and barssinceexit(0) = 1 then begin
topen = open;
openhigh = topen + hlrange;
openlow = topen - hlrange;
count = 0;
end;
if marketposition > 0 and time = 1340.00 then begin
exitlong next bar at market;
end;
if marketposition < 0 and time = 1340.00 then begin
exitshort next bar at market;
end;
DK大大可以將此TS翻成HTS碼嗎?拜託!
回覆刪除j10065敬上
不好意思..最近要搬家會比較忙..你自己先試試吧..不然..找朋友幫個忙先..:p
回覆刪除DK大您好:
回覆刪除自幼拜讀您的Blog,現在的交易環境完全是依照您的教學建立的,先至上最高敬意~~~!
不過小弟資質駑鈍,突破策略有以下缺陷
1.突破進場後當根k無法停損,非要到下根k開盤才會停損...(這樣怎麼風控...)
2.當指數在突破點盤整時,會造成停損的當根k又進場...
已用Marketposition限制每日只做一次
已用Netprofit限制虧損後不進場
小弟程式碼如下
if time <= TimeIn then begin
LastProfit=Netprofit;
Count=0;
end;
condition0 = time>=XXXX and time<=YYYY;
condition1 = NetProfit>=LastProfit and Count=0 and 作多條件;
condition2 = NetProfit>=LastProfit and Count=0 and 作空條件;
if condition0 and condition1 then buy("L") 1 contracts next bar at AAAA stop;
if condition0 and condition2 then sell("S") 1 contracts next bar at BBBB stop;
if marketposition<>0 then Count=1;
if marketposition<>0 then begin
exitlong("stop_L") 1 contracts at **** stop;
exitshort("stop_S") 1 contracts at **** stop;
end;
if time >= YYYY then begin
exitlong("exit_L") 1 contracts this bar at close;
exitshort("exit_S") 1 contracts this bar at close;
end;
敬請不吝指教,感恩感恩~
你說的 1 當根無法停損的情況是有的…解決的方式大概有兩種:
回覆刪除1. 再進場時順便寫下停損條件
if 多單進場條件 then begin
buy .....
exitlong .....
end;
或是簡單一點使用 SetStopLoss 這個內建函式來作停損…這個函數是可以幫你作當根停損出場的。
第 2 點的話…通常我會在進場的條件加上 marketposition = 0 的限制…這樣就不會停損後又馬上進場了。
if marketposition <= 0 and 多單進場條件 then
buy....
end;