|
大家好,我剛學了multichart沒多久,打算交易MHI, 但有一些問題不能解決,想麻煩大大們幫忙一下。
我想寫一個可以在虧損50點時作出翻單部位的程式。 交易口數為1口,以下是我的程式碼。
1)我的程式碼通過了editors,但是反手部份
reversed sell 跟reversed buy 沒有反應,是不是邏輯不對?
2)我有看過一些貼文,如果要反手就不用
setstoploss ,那不會危險嗎?有其他停損方法嗎?
感謝
if marketposition = 0 and time_s <=163000 and condition8 then begin
if condition4 and condition6 and condition2 then begin
buy("Entrybuy") 1 contract next bar at market;
end else if marketposition > 0 then begin
sellshort("reversed sell") 1 contract next bar at PosTradeEntryPrice(0, currentcontracts-1) - 50 stop;
end;
if condition5 and condition6 and condition2 then begin
Sellshort("Entrysell") 1 contract next bar at market;
end else if marketposition < 0 then begin
buy ("reversed buy") 1 contract next bar at PosTradeEntryPrice(0, currentcontracts-1) + 50 stop;
end;
end;
setstopcontract;
setprofittarget(win);
setstoploss (loss);
setpercenttrailing(percentamount,percentchance);
setexitonclose;
|
|