立馬學(xué)會進場開關(guān)控制
作者:MC 來源:cxh99.com 發(fā)布時間:2015年01月28日
- 咨詢內(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;
復(fù)制代碼你就會看到圖表上面出現(xiàn)這樣的訊號,獲利出場后下一根馬上再進場,弄得好像出場的動作是做好玩的?這通常就不是做”突破”的人想要的狀況
所以,我們就得對要不要進場的判斷,在除了是否突破關(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;
復(fù)制代碼我想,上圖跟下圖做個比較,你就可以體會這有什么差異了。
開關(guān), 如何
- MC技術(shù)部:
學(xué)習(xí)了,也避免來回被扇