glaxo 發表於 15-10-13 21:42

請教如何在均線上或下只會進場一次?

請教一下 如果站上均線買一口 ,獲利20點出場,之後不再進場,等到跌破均線放空一口..if c > 某均線 then buy next bar at market; setprofittarget ( pointvalue*20);
假使獲利20點後出場 但Close還在均線之後,寫成上式的話因此又會繼續買進,請問如何可以在均線上只做一次交易呢

離苦得樂 發表於 15-10-13 23:08

均線的站上或跌破都不能做為進場依據,短線長線都是,
它只是輔助

glaxo 發表於 15-10-13 23:22

if marketposition=0 and c> 某均線 and k1=0 then begin
buy next bar at market;
k1=1;
end;

~~~~~~~~~~~~~~~~~`
這樣寫不知道哪裡錯

easytrader788 發表於 15-10-14 00:38

你原來方式 K1= 1 以後 , 要使用
if Close < Average(Close N)then begin
    sellshort next bar at market ;
    K1 = 0 ;
end ;
如此回到均線上才會作多
----------------------------------------------------

使用Cross 的方式 , 就可避免

if marketposition <> 1 and Close cross over Average(Close, N) then buy next bar at Market ;
if marketposition <> -1 andClose cross under Average(Close,N) then Sellshort next bar at Market ;

blj0511 發表於 15-10-14 00:40

你的邏輯基本上進出場應該都是一多一空,所以可以寫成
if marketposition(1)=-1 and c>某均線 thenbuy next bar at market;
if marketposition(1)=1 and c<某均線 thensellshrot next bar at market;

基本上就一定只會多空各一次

若要更精準控制,還是有其他方法,只是簡單的話可以這樣寫

glaxo 發表於 15-10-14 08:36

blj0511 發表於 15-10-14 00:40 static/image/common/back.gif
你的邏輯基本上進出場應該都是一多一空,所以可以寫成
if marketposition(1)=-1 and c>某均線 thenbuy nex ...

感恩啊~~我先來試試!

glaxo 發表於 15-10-14 11:34

if marketposition(1)=-1 and c>某均線 thenbuy next bar at market;
if marketposition(1)=1 and c<某均線 thensellshrot next bar at market;
~~~~~~~~~~~~~~~~~
上述的寫法是不是沒有起始艙位?

我試著寫

k1=1;
if close > 某均線 then begin
buy next bar at market;
k1=0;
end;

if close < 某均線 and k1=0 then begin
sell next bar at market;
k1=1;
end;

setprofittarget ( pointvalue*dd);

noxzx 發表於 15-10-14 12:07

glaxo 發表於 15-10-14 11:34 static/image/common/back.gif
if marketposition(1)=-1 and c>某均線 thenbuy next bar at market;
if marketposition(1)=1 and c 某均 ...

easytrader788大正解阿!!
使用 Cross 最簡單
穿價時才會執行指令


加上停利範例如下
inputs: Stopprofit(6000);//30點停利
if marketposition <> 1 and Close cross over Average(Close, X) then buy next bar at Market ;//X=均線長度
if marketposition <> -1 andClose cross under Average(Close,X) then Sellshort next bar at Market ;
setprofittarget( Stopprofit );


補充 盤整正負30點內 會被巴到死...

glaxo 發表於 15-10-14 12:50

noxzx 發表於 15-10-14 12:07 static/image/common/back.gif
easytrader788大正解阿!!
使用 Cross 最簡單
穿價時才會執行指令


請問這樣寫繪有起始倉位嗎?

noxzx 發表於 15-10-14 13:25

glaxo 發表於 15-10-14 12:50 static/image/common/back.gif
請問這樣寫繪有起始倉位嗎?

請問G大起始倉位的意思是?

上述程式碼 中文解釋是
持有部位不為多單時 可建立多單
持有部位不為空單時 可建立空單

如果你設定倉位經紀商同步
不管你起始有沒有部位
他都會依照邏輯執行(異步就會依照你的倉位 +1 or -1)

glaxo 發表於 15-10-14 13:36

ㄚㄚ....一語驚醒夢中人....

easytrader788 發表於 15-10-14 21:22

glaxo 發表於 15-10-14 11:34 static/image/common/back.gif
if marketposition(1)=-1 and c>某均線 thenbuy next bar at market;
if marketposition(1)=1 and c 某均 ...

有些情形可以使用如下方式告訴軟體 ,我已經各買賣一次了 {建立起始倉位}

if BarNumber = 1 then begin
Buy this bar at close ;
Sellshort this bar at close ;
end ;



頁: [1]
查看完整版本: 請教如何在均線上或下只會進場一次?