程式碼如下:
if date[1] <> date[0] then begin
buyline = 99999;
sellline = 0;
div = 3;
longstopline = 0;
shortstopline = 99999;
count = 0;
end;
if time = 0846.00 then begin
buyline = ;
sellline = ;
end;
if time > 0846.00 and time < 1300.00 and marketposition = 0 and count = 0 then begin
buy ("b1") next bar at buyline stop;
sell ("s1") next bar at sellline stop;
end;
if marketposition > 0 and longstopline = 0 then
longstopline = entryprice(0)-stoploss;
if marketposition < 0 and shortstopline = 99999 then
shortstopline = entryprice(0)+stoploss;
if marketposition > 0 and high > high[1] and high-stoploss > longstopline then
longstopline = high-stoploss;
if marketposition < 0 and low < low[1] and low+stoploss < shortstopline then
shortstopline = low+stoploss;
if marketposition > 0 then begin
exitlong next bar at longstopline stop;
count = 1;
end;
if marketposition < 0 then begin
exitshort next bar at shortstopline stop;
count = 1;
end;
if marketposition = 0 and count = 1 then begin
buyline = ;
sellline = ;
count = 0;
div = ;
longstopline = 99999;
shortstopline = 0;
end;
SORRY..KEY錯,上面請刪除
回覆刪除新手請教,我是用HTS的
1.請問div的意思
2.在HTS裡count是?
請問有hts版的嗎?
回覆刪除jason: 1. div 是我拿來計算進場點用的..沒什麼意義..
回覆刪除2. count 是個變數..在 hts 裡面一樣可以自己用 var 宣告一個 count
chehps: 您好..目前還沒寫 hts 的版本..
可否請問DK大:
回覆刪除程式最下方
if marketposition = 0 and count = 1 then begin
buyline = ; 跟原先buyline一樣嗎?
sellline = ; 跟原先sellline一樣嗎?
count = 0;
div = ; div應該要設多少,有何用處?
longstopline = 99999;
shortstopline = 0;
end;
昌
回覆刪除停損後的再進場點當然就不一樣了..就看備你進場點怎麼計算了..div 是我拿來算進場點用的..其實沒什麼作用..不要也行
回覆刪除希望 D.K.大有空可以轉成hts版
回覆刪除好像很有用
試著自己轉看看吧..這隻程式要轉到 hts 不難的呢..
回覆刪除D.K.大,你好
回覆刪除這支程式似乎在一種情況下會出錯
就是一口空單直接轉一口多單
由於marketposition沒有歸零
所以停損點沒有變動
會導致後面的判斷有問題
請指教
嗯..直接翻單的情況下是會有問題沒錯...得想想看怎麼解決了..
回覆刪除DK您好,
回覆刪除不知ts有沒有this bar立即停利(損)的語法可用?next bar還是稍嫌慢了些...
cs: 您好..TS 沒有 this bar 的語法可以立即停利、停損的…你要用 next bat at xxx stop 了
回覆刪除