<\/a>One type of more advanced problem that is easily addressed with Intelligent Optimization is\u00a0that of\u00a0System Generation by use of rule creation, selection and combination.<\/p>\nWhat we’ll do in this simple example is to write a variety of loose rules for both the entry and exit\u00a0side of a long only intermediate term system and let intelligent optimization find the rules that work best together for entries and exits.<\/p>\n
The general indicators we’ll use are a MACD, Stochastic, RSI & ROC each of which will be considered to be either on a buy or on a sell by using 3 length parameters each.\u00a0 In addition we’ll attach optimizable factors with values of 0 or 1 to the entry and exit side of each of these subsystems\u00a0that allows them to either be used or ignored\u00a0and we’ll use optimizable thresholds for the number of subsystems\u00a0to be on a buy or on a sell to drive when entries and exits take place.<\/p>\n
Below is the\u00a0AFL to accomplish the task … The values in the default values\u00a0of each of the optimization statements are what IO <\/em>put there as a result of the run that took place.<\/p>\n<\/span>\/\/IO: Fitness:\u00a0\u00a0\u00a0 CAR - MDD\r\/\/IO: Goal:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Trades: >: 4\r\/\/IO: Goal:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Trades: <: 12\r\r\/\/IO: BegISDate:\u00a0 12\/20\/2000\r\/\/IO: EndOSDate:\u00a0 01\/31\/2004\r\/\/IO: LastOSDate: 01\/31\/2004\r\r<\/span>M1Len\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"M1Len"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 52<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0 100<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>M2Len\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"M2Len"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 40<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0 100<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>M3Len\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"M3Len"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 48<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0 100<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>MBB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"MBB"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 0<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>MSS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"MSS"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 0<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r\r<\/span>M1 <\/span>= <\/span>AMA<\/span>(<\/span>C<\/span>, <\/span>2 <\/span>\/ (<\/span>M1Len <\/span>+ <\/span>1<\/span>));\r<\/span>M2 <\/span>= <\/span>AMA<\/span>(<\/span>C<\/span>, <\/span>2 <\/span>\/ (<\/span>M2Len <\/span>+ <\/span>1<\/span>));\r<\/span>M3 <\/span>= <\/span>M1 <\/span>- <\/span>M2<\/span>;\r<\/span>M4 <\/span>= <\/span>AMA<\/span>(<\/span>M3<\/span>, <\/span>2 <\/span>\/ (<\/span>M3Len <\/span>+ <\/span>1<\/span>));\r<\/span>MB <\/span>= <\/span>M3 <\/span>&<\/span>gt<\/span>; <\/span>M4<\/span>;\r<\/span>MS <\/span>= <\/span>M3 <\/span>&<\/span>lt<\/span>; <\/span>M4<\/span>;\r\r<\/span>\/\/Plot(M3, \"M3\", colorRed);\r\/\/Plot(M4, \"M4\", colorWhite);\r\r<\/span>S1Len\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"S1Len"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 44<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0 100<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>S2Len\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"S2Len"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 55<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0 100<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>S3Len\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"S3Len"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 58<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0 100<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>SBB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"SBB"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 0<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r<\/span>SSS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>= <\/span>Optimize<\/span>(<\/span>"SSS"<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 0<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>,<\/span>\u00a0\u00a0\u00a0\u00a0 1<\/span>);\r\r<\/span>S1H <\/span>= <\/span>HHV<\/span>(<\/span>C<\/span>, <\/span>S1Len<\/span>);\r<\/span>S1L <\/span>= <\/span>LLV<\/span>(<\/span>C<\/span>, <\/span>S1Len<\/span>);\r<\/span>S1\u00a0 <\/span>= (<\/span>C <\/span>- <\/span>S1L<\/span>) \/ (<\/span>S1H <\/span>- <\/span>S1L<\/span>);\r<\/span>S2\u00a0 <\/span>= <\/span>AMA<\/span>(<\/span>S1<\/span>, <\/span>2 <\/span>\/ (<\/span>S2Len <\/span>+ <\/span>1<\/span>));\r<\/span>S3\u00a0 <\/span>= <\/span>AMA<\/span>(<\/span>S2<\/span>, <\/span>2 <\/span>\/ (<\/span>S3Len <\/span>