請教大大 這種停損該如何寫???
本帖最後由 chyou7 於 13-1-1 18:42 編輯請問大大我想要在進場後K線收完 停損設定在進場K棒的高點或低點(不做任何移動,除非先停利) 該怎麼寫 怎麼寫好像都會移動有大大可以幫幫忙嗎?
Parameter: 量(2000)
Variables:多單進場(99999),空單進場(0),多單停損(0),空單停損(99999),多單停利點(99999),空單停利點(0)
if time>=092000 and time<=131000 then
..............略
ifCondition1 and Condition2 and CurrentContracts = 0
多單進場=...xxxxx.... end if
if c>多單進場 then buy("多單進場") at next bar end if
多單進場=99999
ifCondition1 and Condition2 andCurrentContracts = 0
空單進場=.....xxxxx....... end if
if c<空單進場 then sell("空單進場")at next bar end if
空單進場=0
//if CurrentContracts > 0then
// 多單停損=low end if
//if low< 多單停損 then exitlong("多停損") at 多單停損 limit end if
//多單停損=0
//if CurrentContracts < 0 then
// 空單停損=high end if
//if h>空單停損 then exitshort("空停損") at 空單停損 limit end if
//空單停損=99999
停利機制也想用進場K棒+-value2 該怎麼樣寫出來這個固定的K棒高低點??
//if CurrentContracts > 0 then 多單停利點=h+value2 end if
//if high>=多單停利點 then exitlong("多單賺錢") end if
//多單停利點=99999
//if CurrentContracts < 0 then 空單停利點=l-value2 end if
//if low<=空單停利點 then exitshort("空單賺錢")end if
//空單停利點=0
end if
IF TIME>=132500 THEN EXITLONG("多單不留倉") EXITSHORT("空單不留倉") END IF
要用到進場K棒的,直接採用 BarsSinceEntry 是最快的方式了。不過要注意版本不同會有不同的回傳值。
進場當根K棒的高低點記錄:
if BarsSinceEntry( 0 )=0 and CurrentContracts<>0 then begin
Value1= High;
Value2= Low;
end;
if BarsSinceEntry( 0 )=0 and CurrentContracts<>0 then
Value3= High
Value4= Low
end if
if low< Value4 then exitlong("多停損") this barat Value4 stop
end if
if high>Value3 then exitshort("空停損") this barat Value3 stop
end if
阿政大大 我改成這樣 但是訊號似乎是以收盤為停損基準 收盤過停損才停損 不是 高 低穿過就停損這個有救嗎?? (我知道盤後是靜態用THIS BAR 只先看看績效) 我想大概是 THIS barnext bar limitstop 這些在搞鬼.............當沖這些很關鍵...{:4_202:} 當沖輸贏就這幾點 還要"讓"一根K棒 再"讓"嚴苛的成本 寫程式程度又差 難怪會搞不出來好績效的程式............真是氣死輪
頁:
[1]