TO ALL; Faster scanning speed, (very long post)
I have experienced a decrease in scan time, depending on how the scan is designed, that may be of interest. These considerations may be old hat to you old timers, but I hope some find this info useful. It relates to 'how' you put a scan together and what I found to be the 'faster' method. If anyone has comments or even faster methods I would be more than interested to hear from them. Of course this ALL depends on the amount of conditions you are using. All of these samples returned the same results with the conditions I was using, the length of time it took to run each is shown on the first line. I tried using variables {i.e. TdCls=Close(0)} and found a significant increase in scanning time. Not only did I find a difference in scanning time, but the readability (following the If-EndIf trail) of the faster scans is also easier. (Of course, the faster scans are the last 2 of the four methods.)
Sorry for the length of this post, but I didn't want to leave out any details of the scans.
Best to all, Roy
Method 1: 9 min 0 sec / / If-Then-If-Then-Print-Else-If-Then-Print-EndIf;EndIF;EndIf; Output "file.lst"; IssueType Common; Integer I; For i = -0 to -0 step -1 Do If //Primary Conditions X and Y and Z Then If //First set of Secondary Conditions A and B and C Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // The Following 3 Print lines are used only for back testing // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "A":4; PrintLn; Else If //Second set of Secondary Conditions A and D and E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // The Following 3 Print lines are used only for back testing // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "C":4; PrintLn; Else If // Third set of Secondary Conditions B and C and E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // The Following 3 Print lines are used only for back testing // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "D":4; PrintLn; Else // Next Secondary Conditions C & D & E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // The Following 3 Print lines are used only for back testing // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "H":4; PrintLn; Else If //Next set of Secondary Conditions B and E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // The Following 3 Print lines are used only for back testing // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "L":4; PrintLn; Else If // Next Set of Secondary Conditions E and F Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // The Following 3 Print lines are used only for back testing // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "M":4; PrintLn; Endif; Endif; Endif; Endif; Endif; Endif; Endif; next i; . Method 2: 8 min 40 sec //If-Then-If-Then-Print-EndIf;If-Then-Print-EndIf;EndIf; Output " file.lst "; IssueType Common; Integer I; For i = -0 to -0 step -1 Do If //Primary Conditions X and Y and Z Then //First set of Secondary Conditions A and B and C Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "A":4; PrintLn; Endif; If //Second set of Secondary Conditions A and D and E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "C":4; PrintLn; EndIf; If // Third set of Secondary Conditions B and C and E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "D":4; PrintLn; EndIf; If // Next Secondary Conditions C & D & E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "H":4; PrintLn; EndIf; If //Next set of Secondary Conditions B and E Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "L":4; PrintLn; EndIf; If // Next Set of Secondary Conditions E and F Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print "M":4; PrintLn; Endif; Endif; next i;
Method 3: 7 min 50 sec //If-OR-OR-OR-Then-Print-EndIf; NOTE you can't record which condition met you criteria with this method Output " file.lst "; IssueType Common; Integer I; For i = -0 to -0 step -1 Do If //Primary Conditions X and Y and Z Then //First set of Secondary Conditions A and B and C OR //Second set of Secondary Conditions A and D and E OR If // Third set of Secondary Conditions B and C and E OR // Next Secondary Conditions C & D & E OR //Next set of Secondary Conditions B and E OR // Next Set of Secondary Conditions E and F Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; PrintLn; EndIf; EndIf; next i;
Method 4: 8 min 0 sec ////If-Then-Set--EndIf;If-Then-Set-EndIf;If-Then-SET?-Print-EndIf; Output " file.lst "; IssueType Common; String Cond; Integer I,T; For i = -0 to -0 step -1 Do T:=0; // String expression comparison does not exist, this variable is used for conditional testing; If //Primary Conditions X and Y and Z Then If //First set of Secondary Conditions A and B and C Then Cond:="A"; T:=1;//Set test condition Endif; If //Second set of Secondary Conditions A and D and E Then Cond:="C"; T:=1;//Set test condition EndIf; If // Third set of Secondary Conditions B and C and E Then Cond:="D"; T:=1;//Set test condition EndIf; If // Next Secondary Conditions C & D & E Then Cond:="H"; T:=1;//Set test condition EndIf; If //Next set of Secondary Conditions B and E Then Cond:="L"; T:=1;//Set test condition EndIf; If // Next Set of Secondary Conditions E and F Then Cond:="M"; T:=1;//Set test condition EndIf; If T>0// Only print if a condition was found Then Print Symbol: -7,Date(i):12; Print Open(i+0):7:3,High(i+0):7:3,Low(i+0):7:3,Close(i+0):7:3,Vol(i):9; // Print Open(i+1):7:3,High(i+1):7:3,Low(i+1):7:3,Close(i+1):7:3; // Print Open(i+2):7:3,High(i+2):7:3,Low(i+2):7:3,Close(i+2):7:3; // Print Close(i+2)-Open(i+1):7:3; Print Cond:3; PrintLn; T:=0;// reset test variable EndIf; Endif; next i; |