請教關于hans123加入止損止盈的改寫 [金字塔]
- 咨詢內容:
在開盤30分鐘后準備入場;
上軌=開盤后30分鐘高點;
下軌=開盤后30分鐘低點;
用法:
當價格突破上軌,買入開倉;
當價格跌穿下軌,賣出開倉。
止損:
當買入開倉后;最小價格變動N1個單位 止損。
當賣出開倉后;最小價格變動N2個單位止損。
止盈:
當買入開倉后:最小價格變動N3個單位止盈。
當賣出開倉后:最小價格變動N4個單位止盈。
如果止盈止損都不觸及,收盤平倉。
請各位老師能幫忙寫下代碼。感謝!
- 金字塔客服:
處理中,請稍等
- 用戶回復:
謝謝老師。
- 網友回復:
//N1,N2,N3,N4可以自行定義
//適用周期一分鐘
t1:=time>090000 and time<145500;
t2:=time>=145500;
shanggui:=valuewhen(todaybar<=30,hhv(h,todaybar));
xiagui:=valuewhen(todaybar<=30,llv(l,todaybar));if h>shanggui and t1 then buy(holding=0,1,market);
if l<xiagui and t1 then buyshort(holding=0,1,market);
if c-enterprice>n1*mindiff and holding<0 then sellshort(1,0,market);//止損空頭
if enterprice-c>n2*mindiff and holding>0 then sell(1,0,market);//止損多頭
if c-enterprice>n3*mindiff and holding>0 then sell(1,0,market);//多頭止盈
if enterprice-c>n4*mindiff and holding<0 then sellshort(1,0,market);//空頭止盈
if t2 then BEGIN
sellshort(1,0,market);
sell(1,0,market);
end//收盤平倉 - 網友回復: 謝謝老師,能否稍微改動下 換成適用于5分鐘的K線呢,因為我正常都是按5分鐘操作的。
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 1145508240 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容