關于平倉后再次開倉問題
作者:開拓者 TB 來源:cxh99.com 發布時間:2023年05月06日
-
咨詢內容:
雙均線交易系統帶有固定點位止損止盈
有以下幾個問題:
1.比方均線金叉進多,達到止盈目標止盈后形態上仍然是多頭趨勢,如何限制繼續開倉?
2.如果前一次止損,后面再次開倉加一個突破過濾條件?
現在代碼如下:
Params
? ?? ???Numeric length(10);
? ? ? ? ? ? ? ? Numeric length1(20);
? ? ? ? ? ? ? ? Numeric TakeProfitSet(50);
? ?? ???Numeric StopLossSet(30);
? ?? ???Numeric Lots(3);
Vars
? ? ? ? ? ? ? ? NumericSeries AvgValue;
? ?? ???NumericSeries AvgValue1;
? ? ? ? ? ? ? ? Numeric MyEntryPrice;
? ? ? ?? ???Numeric myexitprice;
? ? ? ? ? ? ? ? Numeric Minpoint;
Begin
? ?? ?? ?AvgValue = AverageFC(C,Length);
? ?? ?? ?AvgValue1= AverageFC(C,Length1);
? ?? ???If(MarketPosition <>1 and? ?AvgValue[1]> AvgValue1[1])
? ? ? ? {
? ? ? ???myentryprice=open;
? ? ? ???Buy(LOTS,myentryprice);
? ? ? ???}
? ? ? ???
? ? ? ? If(MarketPosition <>-1? ? and??AvgValue[1]< AvgValue1[1] )
? ? ? ? {
? ? ? ???myentryprice=open;
? ? ? ???SellShort(LOTS,open);
? ? ? ???}? ? ? ?
? ? ? ? /////
? ? ? ? If(MarketPosition==1) // 有多倉的情況
? ? {
? ?? ?? ?if(high>=(myentryprice+TakeProfitSet*MinPoint))
? ? ? ?? ? {
? ? ? ?? ???myexitprice=(myentryprice+TakeProfitSet*MinPoint);
? ? ? ?? ? if(open>myexitprice)myexitprice=open;
? ? ? ?? ? Sell(0,myexitprice);
? ? ? ?? ? }Else if(low<=(myentryprice-StopLossSet*MinPoint))
? ? ? ?? ? {
? ? ? ?? ???myexitprice=(myentryprice-StopLossSet*MinPoint);
? ? ? ? ? ? ? ? if(open<myexitprice)myexitprice=open;
? ? ? ? ? ? ? ? Sell(0,myexitprice);
? ? ? ? ? ? ? ? }
? ? ? ?? ?
? ? ? ???}
? ? ? ?? ?if(MarketPosition==-1) // 有空倉的情況
? ? {
? ?? ???if(low<=(myentryprice-TakeProfitSet*MinPoint))
? ? ? ?? ? {
? ? ? ?? ???myexitprice=(myentryprice-TakeProfitSet*MinPoint);
? ? ? ?? ? if(open<myexitprice)myexitprice=open;
? ? ? ?? ? BuyToCover(0,myexitprice);
? ? ? ?? ? }Else if(High>=(myentryprice+StopLossSet*MinPoint))
? ? ? ?? ? {
? ? ? ?? ???myexitprice=(myentryprice+StopLossSet*MinPoint);
? ? ? ? ? ? ? ? if(open>myexitprice)myexitprice=open;
? ? ? ? ? ? ? ? BuyToCover(0,myexitprice);
? ? ? ? ? ? ? ? }
? ? }
? ? ? ?
? ? ? ???End
?
?來源:CXH99.COM
-
TB技術人員:
最好只在金叉、死叉出現時開倉,過了就不做了。對第二點,如果出現止損,要再等到新出現交叉再開倉。
If(MarketPosition <>1 and??AvgValue[2] <= AvgValue1[2] and??AvgValue[1]> AvgValue1[1])
? ? Buy();
If(MarketPosition <>-1 and??AvgValue[2] >= AvgValue1[2] and AvgValue[1]< AvgValue1[1])
? ? SellShort();
?
-
TB客服:
Yuen_Lee 發表于 2021-8-3 11:44
最好只在金叉、死叉出現時開倉,過了就不做了。對第二點,如果出現止損,要再等到新出現交叉再開倉。
If(Ma ...
謝謝!
?
-
網友回復:
http://www.wjs7878.com/