立馬學會進場開關控制 [MC]
- 咨詢內容:
轉載自:阿政的投機生活
這一篇,提一個還算是簡單的范例,解釋如何利用變數來做為進場的"開關",去達成交易策略的部位出場后,有的時候即使仍在突破價外(這會出場馬上再進場),而不要馬上再進場的控制。透過"開關"設計,就可以讓交易策略的設計上更多元變化。
策略描述:以每周周一日K的高低點,作為關鍵價突破追進的策略。但是止損/止盈出場后,必須等到價格再回到突破價以內之后,才做突破再度進場。
通常,如果你只是很簡單的訂出兩個關鍵價,去做突破追進的話,直觀描述出來就會如下這樣。 (止損50點、止盈100點)- var:BB(99999),SS(0);
- var:MP(0),lastWay(0);
- var:toDO(true);
- if dayofweek(D)=1 and sessionlastbar then begin
- BB= highD(0);
- SS= lowD(0);
- end;
- MP= marketposition;
- if MP<=0 then
- buy next bar BB stop;
- if MP>=0 then
- sellshort next bar SS stop;
- if MP<>0 then begin
- setstoploss(50*bigpointvalue);
- setprofittarget(100*bigpointvalue);
- end;
所以,我們就得對要不要進場的判斷,在除了是否突破關鍵價外,加上一個”開關”來做控制:讓出場之后把進場開關關掉,必須等待價格回到突破價以內,才把進場的開關再度打開。
下面程序碼中的 toDO 就是進場開關- var:BB(99999),SS(0);
- var:MP(0),lastWay(0);
- var:toDO(true);
- if dayofweek(D)=1 and sessionlastbar then begin
- BB= highD(0);
- SS= lowD(0);
- end;
- MP= marketposition;
- if MP[1]<>0 and MP=0 then begin
- toDo= false;
- if MP[1]>0 then lastWay=1;
- if MP[1]<0 then lastWay=-1;
- end;
- if C<BB and lastWay>0 then
- toDO= true;
- if C>SS and lastWay<0 then
- toDO= true;
- if MP<=0 and toDO=true then
- buy next bar BB stop;
- if MP>=0 and toDO=true then
- sellshort next bar SS stop;
- if MP<>0 then begin
- setstoploss(50*bigpointvalue);
- setprofittarget(100*bigpointvalue);
- end;
開關, 如何 - var:BB(99999),SS(0);
- MC技術部: 學習了,也避免來回被扇
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 1145508240 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容