The code below is run on a watchlist of the DJ-30. When an exploration is run, AFL apparantly zeros out every variable when it finishes with one symbol and starts with another. When AA (Alcoa) is finished the variable count1 is reset to 0. I need to find a way to make a variable hold a value to the end of the whole run. In the code below, after the run is complete the variables count1 and percent1 in the AddColumn statements reflect the values applicable to the last ticker only. I need a way to get a cummulation of variables for all of the symbols together. Has anyone got any ideas? Could ths be accomplished with the StaticVarSet function? I don't know a lot of code.
lastSymbol="XOM"; k= 95; S=StochK(14,3)>k-2.5 AND StochK(14,3)< k+2.5; count1=Cum(IIf(s,1,0)); percent1=Cum(IIf(s,Ref(C,5)/C-1,0)); Filter=Name()==LastSymbol; AddColumn( BarCount, "Barcount", 1.0 ); AddColumn( count1, "count1", 1.4 ); AddColumn( percent1, "percent1", 1.4 ); AddColumn( percent1/count1, "percent change", 1.4 ); On another note, when the two lines of code are changed the result shows how the average % change for each stock 4 days later when the 14 day stochanstic is at a certain level. (in this case + or - 2.5 from 95. k= 95; S=StochK(14,3)>k-2.5 AND StochK(14,3)< k+2.5; count1=Cum(IIf(s,1,0)); percent1=Cum(IIf(s,Ref(C,5)/C-1,0)); Filter=1; AddColumn( BarCount, "Barcount", 1.0 ); AddColumn( count1, "count1", 1.4 ); AddColumn( percent1, "percent1", 1.4 ); AddColumn( percent1/count1, "percent change", 1.4 );
