\n
Some of the other Watchlists give less exposure (profits) but this comes with lower DDs. Commissions were set to $0.005 per share. No margin used.<\/p>\n
No explicit ranking is used; tickers are traded based on their alphabetical sort in the Watchlist. This may seem odd but is significant: reversing this sort the system fails. This might mean that, due to real-time scanning problems, symbols listed at the top of this sort may be traded differently than those listed at the bottom. <\/p>\n
Pay attention to Liquidity (you might want to trade more than one position) and slippage (Entry is rather risk-free, but exits may be problematic). DDs are significant but may be offset with improved real-time traded entries and exits. When trading automatically it may be possible to place OCA DAY-LMT entry orders for all signals and just wait and see what fills. Since exits are more difficult than entries you may wish to explore other exit strategies.<\/p>\n
Parameter default values are just picked out of a hat. Almost certainly you can Optimize them or adjust them dynamically for individual tickers. I briefly tested this system in Walk-Forward mode and the results were profitable for all years tested. Except for the number of stocks traded parameters appear not very critical. Over-optimizing doesn’t seem a problem in this case.<\/p>\n
The code below is very simple and requires few explanations. However it is important to understand that this system enjoys a small edge by trading at the Open, and by calculating the TrendMA using the same Open price. Some might interpret this as future leak, however if you trade this system in real-time, it is not. Many people do not realize that if you trade at the Open you can also use this price in your calculations — as long as you perform them in real-time — this is where AmiBroker and technology can give you an edge. If you Ref() back the TrendMA by one bar the system is still very profitable however DDs increase for some Watchlists. If you use fixed investments the difference is negligible. <\/p>\n
The trading procedure would be to start scanning before the market opens and remove tickers that are priced so remote that they are unlikely to meet the OpenThresh. Thus you may start scanning 1000 symbols but very quickly the number scanned will dwindle to just a dozen or so tickers. When you approach 9:30am your real-time scan will be very fast and you will be able to place your LMT order very close to the Open – you may even be able to improve on the Open price.<\/p>\n
Even though a few people looked at the code below and found nothing wrong, the profits seem rather high for such a simple system. Please report errors you may see.<\/p>\n
<\/span>function <\/span>ParamOptimize<\/span>( <\/span>description<\/span>, <\/span>defaultVal<\/span>, <\/span>minv<\/span>, <\/span>maxv<\/span>, <\/span>step <\/span>)\r{\r return <\/span>Optimize<\/span>( <\/span>description<\/span>, <\/span>Param<\/span>( <\/span>description<\/span>, <\/span>defaultVal<\/span>, <\/span>minv<\/span>, <\/span>maxv<\/span>, <\/span>step <\/span>), <\/span>minv<\/span>, <\/span>maxv<\/span>, <\/span>step <\/span>);\r}\r\r<\/span>PosQty <\/span>= <\/span>ParamOptimize<\/span>( <\/span>"Position Qty"<\/span>, <\/span>1<\/span>, <\/span>1<\/span>, <\/span>10<\/span>, <\/span>1 <\/span>);\r<\/span>TrendPeriod <\/span>= <\/span>Paramoptimize<\/span>( <\/span>"Pd1"<\/span>, <\/span>13<\/span>, <\/span>3<\/span>, <\/span>30<\/span>, <\/span>1 <\/span>);\r<\/span>OpenOffset <\/span>= <\/span>paramOptimize<\/span>( <\/span>"OS"<\/span>, <\/span>0.99<\/span>, <\/span>0.98<\/span>, <\/span>1<\/span>, <\/span>0.001 <\/span>);\r<\/span>MinVolume <\/span>= <\/span>ParamOptimize<\/span>( <\/span>"Min. Volume (M)"<\/span>, <\/span>0.5<\/span>, <\/span>0.5<\/span>, <\/span>10<\/span>, <\/span>0.5 <\/span>);\r\r<\/span>Short <\/span>= <\/span>Cover <\/span>= <\/span>0<\/span>;\r<\/span>SetOption<\/span>( <\/span>"allowsamebarexit"<\/span>, <\/span>False <\/span>);\r<\/span>SetOption<\/span>( <\/span>"maxopenpositions"<\/span>, <\/span>PosQty <\/span>);\r\r<\/span>VolumeOK <\/span>= <\/span>MA<\/span>( <\/span>Ref<\/span>( <\/span>V<\/span>, -<\/span>1 <\/span>), <\/span>10 <\/span>) > <\/span>MinVolume<\/span>;\r<\/span>TrendMA <\/span>= <\/span>MA<\/span>( <\/span>O<\/span>, <\/span>TrendPeriod <\/span>); \r<\/span>ROCTrend <\/span>= <\/span>ROC<\/span>( <\/span>TrendMA<\/span>, <\/span>1 <\/span>);\r<\/span>TrendUp <\/span>= <\/span>ROCTrend <\/span>> <\/span>0<\/span>;\r<\/span>OpenThresh <\/span>= <\/span>Ref<\/span>( <\/span>L<\/span>, -<\/span>1 <\/span>) * <\/span>OpenOffset<\/span>;\r\r<\/span>Buy <\/span>= <\/span>O <\/span>< <\/span>OpenThresh <\/span>AND <\/span>VolumeOK <\/span>AND <\/span>TrendUp<\/span>;\r<\/span>BuyPrice <\/span>= <\/span>O<\/span>;\r\r<\/span>Sell <\/span>= <\/span>Ref<\/span>( <\/span>Buy<\/span>, -<\/span>1 <\/span>);\r<\/span>SellPrice <\/span>= <\/span>O<\/span>;\r\r<\/span>PositionSize <\/span>= -<\/span>100 <\/span>\/ <\/span>PosQty<\/span>; <\/span>\/\/ Compounded\r\/\/PositionSize = 100000; \/\/ Fixed investment\r\r<\/span>Plot<\/span>( <\/span>C<\/span>, <\/span>""<\/span>, <\/span>1<\/span>, <\/span>128 <\/span>| <\/span>styleThick <\/span>);\r<\/span>Plot<\/span>( <\/span>TrendMA<\/span>, <\/span>""<\/span>, <\/span>2<\/span>, <\/span>1 <\/span>);\r\rif ( <\/span>ParamToggle<\/span>( <\/span>"Triangles"<\/span>, <\/span>"HIDE|SHOW"<\/span>, <\/span>1 <\/span>) )\r{\r <\/span>PlotShapes<\/span>( <\/span>IIf<\/span>( <\/span>Buy<\/span>, <\/span>shapeSmallCircle<\/span>, <\/span>shapeNone <\/span>), <\/span>5<\/span>, <\/span>0<\/span>, <\/span>BuyPrice<\/span>, <\/span>0 <\/span>);\r <\/span>PlotShapes<\/span>( <\/span>IIf<\/span>( <\/span>Sell<\/span>, <\/span>shapeSmallCircle<\/span>, <\/span>shapeNone <\/span>