{"id":3374,"date":"2011-09-01T18:53:49","date_gmt":"2011-09-01T18:53:49","guid":{"rendered":"http:\/\/www.amibroker.org\/userkb\/?p=3374"},"modified":"2011-09-03T10:12:16","modified_gmt":"2011-09-03T10:12:16","slug":"a-long-only-eod-gap-trading-idea","status":"publish","type":"post","link":"http:\/\/www.amibroker.org\/editable_userkb\/2011\/09\/01\/a-long-only-eod-gap-trading-idea\/","title":{"rendered":"A Long-only EOD Gap trading idea"},"content":{"rendered":"

This idea was posted ( #161332<\/a> ) on the main AmiBroker list on July 3, 2011. There were numerous excellent comments on the list and if you are interested in working on this system you do well to read them all before starting. After posting I found a number of posts on the web discussing this trading idea, some claimed to be trading a similar system with good success. <\/p>\n

I referred to this system a “Gap Trading” system but this may be a bit of a misnomer, “Mean reversion” might be a better classification. Googling for it<\/a> will get you many more hits to similar systems. Here are a few links:<\/p>\n

NDX100: Trading intraday mean reversion using limit orders<\/a>
\n
Trading intraday mean reversion using limit orders \u2013 does it work?<\/a><\/p>\n

It appears to be a fairly widely discussed trading idea and I suggest you’ll do some Googling on your own to learn the latest. As an Amibroker user you have better tools than most traders and you have a better chance than most to come up with a variation that works. Perhaps with a little less profits, and with a significant amount of additional code — it won’t be a “quicky” project :-) <\/p>\n

Some people commented that this system will not work in real trading, while they may be right others say schemes like this work. I didn’t finish the system and can’t claim to know whether it is tradable or not.<\/p>\n

The system Buys at a certain percentage below yesterday’s Low, on a LMT order, and exits in the same day at the Close. <\/p>\n

\n\"\"<\/a><\/p>\n
\n
Short <\/span>= <\/span>Cover <\/span>= <\/span>0<\/span>;\r<\/span>Qty <\/span>= <\/span>6<\/span>;\r<\/span>SetTradeDelays<\/span>( <\/span>0<\/span>, <\/span>0<\/span>, <\/span>0<\/span>, <\/span>0 <\/span>);\r<\/span>SetOption<\/span>( <\/span>"AllowSameBarExit"<\/span>, <\/span>True <\/span>);\r<\/span>SetOption<\/span>( <\/span>"maxopenpositions"<\/span>, <\/span>Qty <\/span>);\r\r<\/span>GapAmount <\/span>= <\/span>Param<\/span>( <\/span>"Gap (%)"<\/span>, <\/span>1.5<\/span>, <\/span>0<\/span>, <\/span>3<\/span>, <\/span>0.01 <\/span>);\r<\/span>BuyPrice <\/span>= ( <\/span>1 <\/span>- <\/span>GapAmount <\/span>\/ <\/span>100 <\/span>) * <\/span>Ref<\/span>( <\/span>L<\/span>, -<\/span>1 <\/span>);\r<\/span>BuyPrice <\/span>= <\/span>Min<\/span>( <\/span>O<\/span>, <\/span>BuyPrice <\/span>); <\/span>\/\/ Enter immediately at Open if below BuyPrice\r<\/span>Buy <\/span>= <\/span>L <\/span>< <\/span>BuyPrice <\/span>AND <\/span>Ref<\/span>( <\/span>MA<\/span>( <\/span>V<\/span>, <\/span>10 <\/span>), -<\/span>1 <\/span>) > <\/span>1000000<\/span>;\r<\/span>SellPrice <\/span>= <\/span>C<\/span>;\r<\/span>Sell <\/span>= <\/span>Buy<\/span>;\r\r<\/span>\/\/ To test for ticker-sensitivity turn on Random Ticker Selection\r\/\/ and run this code in the Optimizer to see how performance varies\r\/\/ Because it is unknown which ticker will trigger first actual\r\/\/ performance will be somewhere between the min\/max profits shown\r\r<\/span>if ( <\/span>ParamToggle<\/span>( <\/span>"Random Ticker Selection"<\/span>, <\/span>"OFF|ON"<\/span>, <\/span>0 <\/span>) )\r{\r    <\/span>Optimize<\/span>( <\/span>"Dummy"<\/span>, <\/span>1<\/span>, <\/span>1<\/span>, <\/span>100<\/span>, <\/span>1 <\/span>);\r    <\/span>PositionScore <\/span>= <\/span>mtRandom<\/span>();\r}\r\r<\/span>PositionSize <\/span>= -<\/span>100 <\/span>\/ <\/span>Qty<\/span>;\r\r<\/span>Plot<\/span>( <\/span>C<\/span>, <\/span>""<\/span>, <\/span>1<\/span>, <\/span>128 <\/span>);\r\rif ( <\/span>ParamToggle<\/span>( <\/span>"Arrows"<\/span>, <\/span>"HIDE|SHOW"<\/span>, <\/span>0 <\/span>) )\r{\r    <\/span>Equity<\/span>( <\/span>1 <\/span>);\r    <\/span>PlotShapes<\/span>( <\/span>IIf<\/span>( <\/span>Buy<\/span>, <\/span>shapeUpArrow<\/span>, <\/span>shapeNone <\/span>), <\/span>colorGreen<\/span>, <\/span>0<\/span>, <\/span>BuyPrice <\/span>);\r    <\/span>PlotShapes<\/span>( <\/span>IIf<\/span>( <\/span>Sell<\/span>, <\/span>shapeDownArrow<\/span>, <\/span>shapeNone <\/span>), <\/span>colorRed<\/span>, <\/span>0<\/span>, <\/span>SellPrice <\/span>);\r    <\/span>PlotShapes<\/span>( <\/span>IIf<\/span>( <\/span>Buy<\/span>, <\/span>shapeSmallCircle<\/span>, <\/span>shapeNone <\/span>), <\/span>colorGreen<\/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>), <\/span>colorRed<\/span>, <\/span>0<\/span>, <\/span>SellPrice<\/span>, <\/span>0 <\/span>);\r}<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"

This idea was posted ( #161332 ) on the main AmiBroker list on July 3, 2011. There were numerous excellent comments on the list and if you are interested in working on this system you do well to read them all before starting. After posting I found a number of posts on the web discussing […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[108],"tags":[],"_links":{"self":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/3374"}],"collection":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/comments?post=3374"}],"version-history":[{"count":16,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/3374\/revisions"}],"predecessor-version":[{"id":3390,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/3374\/revisions\/3390"}],"wp:attachment":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/media?parent=3374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/categories?post=3374"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/tags?post=3374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}