{"id":50,"date":"2007-04-28T04:35:45","date_gmt":"2007-04-28T04:35:45","guid":{"rendered":"http:\/\/69.65.98.246\/userkb\/2007\/04\/28\/price-bound-checking\/"},"modified":"2007-07-07T19:36:21","modified_gmt":"2007-07-07T19:36:21","slug":"price-bound-checking","status":"publish","type":"post","link":"http:\/\/www.amibroker.org\/editable_userkb\/2007\/04\/28\/price-bound-checking\/","title":{"rendered":"Price Bound Checking"},"content":{"rendered":"

When you start to design your own trading system, you will soon realize the need to custom define the BuyPrice, SellPrice, ShortPrice, and CoverPrice. Similarly, you may want to set your trade delays using the in-code function SetTradeDelays(d,d,d,d). Such hard-coded definitions will override the default trade prices and delays set in the Automatic Analysis (AA) Settings, and this will prevent you from inadvertently using the default settings. The problem is that defining your own price arrays increases the risk of introducing pricing errors, such as Price Bound Errors.<\/p>\n

AmiBroker provides a function called SetOption(“PriceBoundChecking”,TRUE\/FALSE) <\/em>to Enable\/Disable Price Bound Checking. Enabling this option will adjust\u009d prices so that they fall within the High-Low range and mask your pricing errors. The problem, of course, is that in practical trading these prices are impossible to trade, and your Backtests will not reflect realistic conditions. The best way to handle this is to turn Off Price Bound Checking and write your own error detection code. The code below checks your trade prices for Out of Bounds errors, displays the number of errors it finds, and plots a red marker (bar) at the bottom of your chart where the error occurs.<\/p>\n

SetOption(\"PriceBoundChecking\",False);
\nBuyError = ( BuyPrice > H OR BuyPrice < L ) AND Buy;
\nSellError = ( SellPrice > H OR SellPrice < L ) AND Sell;
\nShortError = ( ShortPrice > H OR ShortPrice < L ) AND Short;
\nCoverError = ( CoverPrice > H OR CoverPrice < L ) AND Cover;
\nPricingErrors = BuyError OR SellError OR ShortError OR CoverError;
\nPlot(PricingErrors ,\"Bound Errors\",colorRed,styleArea|styleOwnScale,0,10);
\nTitle = \"# Price Bound Errors: \"+NumToStr(Cum(PricingErrors),1.0,False)+\"\\n\";<\/code><\/p>\n

Edited by Al venosa<\/p>\n","protected":false},"excerpt":{"rendered":"

When you start to design your own trading system, you will soon realize the need to custom define the BuyPrice, SellPrice, ShortPrice, and CoverPrice. Similarly, you may want to set your trade delays using the in-code function SetTradeDelays(d,d,d,d). Such hard-coded definitions will override the default trade prices and delays set in the Automatic Analysis (AA) […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[63],"tags":[],"_links":{"self":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/50"}],"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=50"}],"version-history":[{"count":0,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}