{"id":102,"date":"2007-05-06T04:49:20","date_gmt":"2007-05-06T04:49:20","guid":{"rendered":"http:\/\/www.amibroker.org\/userkb\/2007\/05\/06\/bar-magnifier\/"},"modified":"2007-07-07T19:36:43","modified_gmt":"2007-07-07T19:36:43","slug":"bar-scaling-tool","status":"publish","type":"post","link":"http:\/\/www.amibroker.org\/editable_userkb\/2007\/05\/06\/bar-scaling-tool\/","title":{"rendered":"Bar-Scaling Tool"},"content":{"rendered":"
When testing short-term trading systems that respond to single-bar price changes it is very convenient to be able to manually change a bar’s price and force a signal. The small program listed below can be prefixed to your system’s code and will do this by magnifying the selected High, Low and Close price with respect to the Open price of the bar.<\/p>\n
SetBarsRequired<\/span>(<\/span>100000<\/span>,<\/span>10000<\/span>);\r<\/span>BI<\/span>=<\/span>BarIndex<\/span>();\r<\/span>SB<\/span>=<\/span>LastValue<\/span>(<\/span>ValueWhen<\/span>(<\/span>BI<\/span>==<\/span>SelectedValue<\/span>(<\/span>BI<\/span>),<\/span>BI<\/span>));\r<\/span>EnableScaling<\/span>=<\/span>ParamToggle<\/span>(<\/span>"Bar Scaling"<\/span>,<\/span>"DISABLED|ENABLED"<\/span>);\r<\/span>ScalingFactor<\/span>=<\/span>Param<\/span>(<\/span>"HLC Scaling Factor"<\/span>,<\/span>1<\/span>,<\/span>0<\/span>,<\/span>5<\/span>,<\/span>0.01<\/span>);\rif(<\/span>EnableScaling<\/span>)\r{\r<\/span>Hd<\/span>=<\/span>H<\/span>[<\/span>sb<\/span>]-<\/span>O<\/span>[<\/span>sb<\/span>];\r<\/span>Ld<\/span>=<\/span>O<\/span>[<\/span>sb<\/span>]-<\/span>L<\/span>[<\/span>sb<\/span>];\r<\/span>Cd<\/span>=<\/span>C<\/span>[<\/span>sb<\/span>]-<\/span>O<\/span>[<\/span>sb<\/span>];\r<\/span>Hd<\/span>=<\/span>ScalingFactor<\/span>*<\/span>Hd<\/span>;\r<\/span>Ld<\/span>=<\/span>ScalingFactor<\/span>*<\/span>Ld<\/span>;\r<\/span>Cd<\/span>=<\/span>ScalingFactor<\/span>*<\/span>Cd<\/span>;\r<\/span>H<\/span>[<\/span>sb<\/span>]=<\/span>O<\/span>[<\/span>sb<\/span>]+<\/span>Hd<\/span>;\r<\/span>L<\/span>[<\/span>sb<\/span>]=<\/span>O<\/span>[<\/span>sb<\/span>]-<\/span>Ld<\/span>;\r<\/span>C<\/span>[<\/span>sb<\/span>]=<\/span>O<\/span>[<\/span>sb<\/span>]+<\/span>Cd<\/span>;\r}\r<\/span>\/\/Code to demonstrate bar scaling\r<\/span>Short<\/span>=<\/span>Cover<\/span>=<\/span>0<\/span>;\r<\/span>Buy<\/span>=<\/span>Cross<\/span>(<\/span>High<\/span>,<\/span>Ref<\/span>(<\/span>H<\/span>,-<\/span>1<\/span>));\r<\/span>Sell<\/span>=<\/span>Cross<\/span>(<\/span>Ref<\/span>(<\/span>L<\/span>,-<\/span>1<\/span>),<\/span>L<\/span>);\r<\/span>BuyPrice<\/span>=<\/span>Ref<\/span>(<\/span>H<\/span>,-<\/span>1<\/span>);\r<\/span>SellPrice<\/span>=<\/span>Ref<\/span>(<\/span>L<\/span>,-<\/span>1<\/span>);\r<\/span>Plot<\/span>(<\/span>C<\/span>,<\/span>""<\/span>,<\/span>1<\/span>,<\/span>128<\/span>);\r<\/span>PlotShapes<\/span>(<\/span>IIf<\/span>(<\/span>Buy<\/span>,<\/span>shapeUpTriangle<\/span>,<\/span>shapeNone<\/span>),<\/span>colorBrightGreen<\/span>,<\/span>0<\/span>,<\/span>BuyPrice<\/span>,<\/span>0<\/span>);\r<\/span>PlotShapes<\/span>(<\/span>IIf<\/span>(<\/span>Sell<\/span>,<\/span>shapeDownTriangle<\/span>,<\/span>shapeNone<\/span>),<\/span>colorRed<\/span>,<\/span>0<\/span>,<\/span>SellPrice<\/span>,<\/span>0<\/span>);<\/span><\/pre>\nEdited by Al Venosa<\/p>\n","protected":false},"excerpt":{"rendered":"
When testing short-term trading systems that respond to single-bar price changes it is very convenient to be able to manually change a bar’s price and force a signal. The small program listed below can be prefixed to your system’s code and will do this by magnifying the selected High, Low and Close price with respect […]<\/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\/102"}],"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=102"}],"version-history":[{"count":0,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}