請問我想要當根K線即時停利是否下列寫法,請大大能給予協助,幫我改正一下! 感激不盡!
策略是有2口多單...在賺到30點時先出場一口
策略是有2口空單...在賺到30點時先出場一口
if MarketPosition =2 and high > entryprice(0)+30 then Begin ; Sell("99") 1 contracts This bar at entryprice(0)+30 stop; end ; if MarketPosition =-2 and low < entryprice(0)-30 then Begin ; BuyToCover("88") 1 contracts This bar at entryprice(0)-30 stop; end ;
------ 編譯時產生錯誤: ------ 'This bar' can only be used in close orders. errLine 54, errColumn 28, errLineEnd 54, errColumnEnd 28 編譯錯誤: (函數)
你可以嘗試用setprofittarget跟setstopcontract搭配使用..
就可以簡單達到你要的喔...XD
您是說改成這樣嗎...
if MarketPosition =2 and high > entryprice(0)+30 then Begin ; setstoploss("99") 1 contracts This bar at entryprice(0)+30 stop; end ; if MarketPosition =-2 and low < entryprice(0)-30 then Begin ; setprofittarget("88") 1 contracts This bar at entryprice(0)-30 stop; end ;
結果是
------ 編譯時產生錯誤: ------ syntax error, unexpected 'numeric constant' errLine 54, errColumn 18, errLineEnd 54, errColumnEnd 18
我有看了書上的介紹....這樣可行...但有我有2口單只要出一口要如何寫出來,不好意思我是大外行...請幫我寫好嗎? 感謝您們!
setstopcontract; setstoploss(4000);
setstopcontract; setprofittarget(6000);