\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}]}}