{"id":59,"date":"2007-04-28T21:12:30","date_gmt":"2007-04-28T21:12:30","guid":{"rendered":"http:\/\/www.amibroker.org\/userkb\/2007\/04\/28\/preventing-false-at-starts\/"},"modified":"2007-10-19T12:52:09","modified_gmt":"2007-10-19T12:52:09","slug":"preventing-false-at-starts","status":"publish","type":"post","link":"http:\/\/www.amibroker.org\/editable_userkb\/2007\/04\/28\/preventing-false-at-starts\/","title":{"rendered":"The Master AT switch"},"content":{"rendered":"
When you are using an Automated Trading system, you need a master switch to allow you to Enable\/Disable all automated action. It is very important for this switch to be Off when you start AmiBroker because the last thing you want is to see is that orders are going out right after launching AmiBroker.<\/p>\n
You cannot use the ParamToggle() because this function resumes the last state it was in before you closed AmiBroker, i.e. if it was Enabled when AmiBroker shut down, then it would be Enabled after startup. You need a function that always starts up Disabled, no matter under what condition AmiBroker closed.<\/p>\n
To create a switch that is always Off at the time of startup, you use two ParamTrigger()s, one to turn On Automation and one to turn Off Automation.<\/p>\n
AutoTrading <\/span>= <\/span>nz<\/span>(<\/span>StaticVarGet<\/span>(<\/span>"AutoTrading"<\/span>));<<\/span>p<\/span>><\/span>ATonTrigger <\/span>= <\/span>ParamTrigger<\/span>(<\/span>"Start AutoTrading"<\/span>,<\/span>"START"<\/span>);<<\/span>p<\/span>><\/span>AToffTrigger <\/span>= <\/span>ParamTrigger<\/span>(<\/span>"Stop AutoTrading"<\/span>,<\/span>"STOP"<\/span>);<<\/span>p<\/span>>if( <\/span>ATonTrigger <\/span>)<\/span>StaticVarSet<\/span>(<\/span>"AutoTrading"<\/span>,<\/span>1<\/span>);<<\/span>p<\/span>>else if( <\/span>AToffTrigger <\/span>)<\/span>StaticVarSet<\/span>(<\/span>"AutoTrading"<\/span>,<\/span>0<\/span>);<<\/span>p<\/span>><\/span>AutoTrading <\/span>= <\/span>StaticVarGet<\/span>(<\/span>"AutoTrading"<\/span>);<<\/span>p<\/span>><\/span>Title <\/span>= <\/span>"\\nAutoTrading "<\/span>+<\/span>WriteIf<\/span>( <\/span>AutoTrading<\/span>, <\/span>"On"<\/span>,<\/span>"Off"<\/span>);<<\/span>p<\/span>><\/span><\/pre>\nEdited by Al Venosa<\/p>\n","protected":false},"excerpt":{"rendered":"
When you are using an Automated Trading system, you need a master switch to allow you to Enable\/Disable all automated action. It is very important for this switch to be Off when you start AmiBroker because the last thing you want is to see is that orders are going out right after launching AmiBroker. You […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[124],"tags":[],"_links":{"self":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/59"}],"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=59"}],"version-history":[{"count":0,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}