|
本帖最後由 joshsmi 於 14-3-21 03:37 編輯
osdak 發表於 14-3-21 01:02
如果我是想控制每天的下單數目, 請問應如何做? 比如每天做十次買單, 十次賣單? 我寫了個for loop, 於backte ...
I don't completely understand your text and I haven't checked your code but if you wanna limit the number of trades per day you don't need loop.
// limit number of daily signals
Buy = Cross( MACD(), Signal() );
dn = DateNum();
NewDay = dn != Ref( dn, -1 );// new day marker
BuyNum = Cum( Buy );
DailyBuyNum = BuyNum - ValueWhen( NewDay, BuyNum ); // number of daily signals
Buy = Buy AND DailyBuyNum <= 4; // change the trade number you want to limit
// for test
Plot( DailyBuyNum, "DBN", colorRed, styleStaircase );
Buycolor = colorGreen;
Colorborder = colorLightGrey;
PlotShapes( Buy*shapeSmallUpTriangle, Buycolor, 0, DailyBuyNum, -15 );
PlotShapes( Buy*shapeHollowSmallUpTriangle, Colorborder, 0, DailyBuyNum, -15 );
PlotShapes( Buy*shapeHollowSmallCircle, Buycolor, 0, DailyBuyNum, 0 );
|
評分
-
查看全部評分
|