Hello DM,
the Switch() function is a great tool to organize complex and interdependent tasks. In fact I am beginning to think it is indispensable in the design of Automated and Real-Time trading systems where many operations must be confirmed before proceeding with the next.
Here is a post I made some time ago on the -at list.
best regards,
herman
This is a forwarded message
From: Herman <psytek@xxxxxxxx>
To: AmiBroker-at <AmiBroker-at@xxxxxxxxxxxxxxx>
Date: Friday, April 20, 2007, 7:53:25 PM
Subject: Using Switch(): State Engines a snap!
===8<==============Original message text===============
Congratulations to Tomasz for introducing the Switch()! Great feature.
Auto-Traders, you must have a closer look at the new Switch() statement.
I just rewrote my system using the Switch() and the entire code suddenly became extremely easy to read and modify. Suddenly it is a "snap", to implement and display states like:
Cancel All Orders
Verify All Orders cancelled
Close All Positions
Verify All Positions Closed
Place Orders
Verify All Orders Placed
etc. etc.
I now use ParamTrigger() like this:
if( ParamTrigger("Close, Cancel and Reset All","RESET") ) StaticVarSet("SystemState",100);
and space my triggers by 10 (100, 90, 80, ...) to allow me to add in additional states later. My Switch() looks like this:
SystemState = Nz(StaticVarGet("SystemState"));
switch( SystemState )
{
case 100:
MS = ", Reset Phase 1: Cancel all orders";
_TRACE("# SystemState: "+NumToStr(StaticVarGet("SystemState"),1.0,False)+MS);
CancelAllOrders();
StaticVarSet("SystemState",SystemState = 99 );
break;
case 99:
....
This method logs to DBV but as well shows the current system state in the Title using:
Title = "System State: "+StrMid(MS,2,100);
Of course this is just my first draft and I am sure there are many and better ways of doing this, however this is a great improvement over my earlier state engines.
best regards,
herman
===8<===========End of original message text===========
--
Best regards,
Herman mailto:psytek@xxxxxxxx
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
__,_._,___
|