April 28, 2007
The Master AT switch
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 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.
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.
AutoTrading = nz(StaticVarGet("AutoTrading"));<p>ATonTrigger = ParamTrigger("Start AutoTrading","START");<p>AToffTrigger = ParamTrigger("Stop AutoTrading","STOP");<p>if( ATonTrigger )StaticVarSet("AutoTrading",1);<p>else if( AToffTrigger )StaticVarSet("AutoTrading",0);<p>AutoTrading = StaticVarGet("AutoTrading");<p>Title = "\nAutoTrading "+WriteIf( AutoTrading, "On","Off");<p>
Edited by Al Venosa
Filed by Herman at 9:12 pm under System Automation
Comments Off on The Master AT switch