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