小弟我有依照版主前所分享的方式用大單大師做的自動下單設定
小弟是把版主之前分享的程式碼內新加此篇的程 ...
frantz 發表於 11-1-17 08:34 PM 小弟找到原因了@@
原來以下代碼:
- if (LastValue(C)>8000) AND (if_in_OK=0)
複製代碼
需要在增加()才行,如下:
- if ((LastValue(C)>8000) AND (if_in_OK=0))
複製代碼
不過還是需要在請版主測試看看是否有問題@@
以下是結合版大所分享的代碼進行結合的
- OMComAPI = CreateStaticObject("OMSignAPI.OMCOMAPI");
- OMComAPI.IniDllAndPosition("MXF", 0);
- up=Cross(MA(C,20),MA(C,50));
- down=Cross(MA(C,50),MA(C,20));
- Buy = up;
- Sell = down;
- Buy =ExRem(Buy,Sell);
- Sell=ExRem(Sell,Buy);
- if (Buy[BarCount-1]==True)
- {
- NowDateTime=Now(0);
- NowPosition = 1;
- NowClose=LastValue(Close);
- OMComAPI.GoOrder("MXF","","NowDateTime",Nowposition,Nowclose);
- }
- if (Sell[BarCount-1]==True)
- {
- NowDateTime=Now(0);
- NowPosition = 0;
- NowClose=LastValue(Close);
- OMComAPI.GoOrder("MXF","","NowDateTime",NowPosition,NowClose);
- }
- Plot(MA(C,20),"MA20",colorRed,styleLine);
- Plot(MA(C,50),"MA50",colorBlue,styleLine);
- PlotShapes(IIf(Buy , shapeSmallUpTriangle, shapeNone) ,colorYellow, 0,L,-
- 50);
- PlotShapes(IIf( Sell, shapeSmallDownTriangle, shapeNone) ,colorBlue, 0,H,-
- 45);
- _SECTION_BEGIN("Price");
- SetChartOptions(0,chartShowArrows|chartShowDates);
- _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo
- %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) )
- ));
- Plot( C, "Close", IIf( C > O, ParamColor("Up Color", colorRed ),
- ParamColor("Down Color", colorGreen ) )
- , styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
- _SECTION_END();
- buystop=0;
- sellstop=0;
- if_in_OK=0;
- //c>8000 to buy for test
- if ((LastValue(C)>8000) AND (if_in_OK=0))
- {
- NowDateTime=Now(0);
- NowPosition = 1;
- NowClose=LastValue(Close);
- OMComAPI.GoOrder("test","","NowDateTime",Nowposition,Nowclose);
- Buystop=Nowclose-10;
- Sellstop=0;
- if_in_OK=1;
- }
- //c<9500 to sell for test
- if (LastValue(C)<9500)
- {
- NowDateTime=Now(0);
- NowPosition = -1;
- NowClose=LastValue(Close);
- OMComAPI.GoOrder("test","","NowDateTime",Nowposition,Nowclose);
- Sellstop=Nowclose+10;
- Buystop=0;
- }
- //IF=OK!Abuystop AND sellstop =0
- if (LastValue(TimeNum())==134000 OR LastValue(Close)==Buystop OR LastValue(Close)==Sellstop)
- {
- NowDateTime=Now(0);
- NowPosition = 0;
- NowClose=LastValue(Close);
- OMComAPI.GoOrder("test","","NowDateTime",NowPosition,NowClose);
- Buystop=0;
- Sellstop=0;
- }
複製代碼 |