PureBytes Links
Trading Reference Links
|
Variables retain their values from bar to bar so if you assign a variable to a value, you can use that variable on any subsequent bar. You can also declare arrays of one or two (and possible more) dimensions. (Three dimensional arrays did not work with TS4.0 but may work in TS2000i.)
In the following code:
Input: Length(10), XYZ(0), Slope(0);
Vars: Factor(2 / (Length + 1)), j(0);
Array: MyArray[10](0);
if CurrentBar = 1 then begin
for j = 0 to 10 begin
MyArray[j] = j;
end;
end;
XYZ = MyArray[6] * Factor * Close;
Slope = XYZ - XYZ[10];
The variable "Factor" is initialized to a calculated value as part of the declaration. The eleven values assigned to the array elements are initialized on the first bar and retain their values for all subsequent bars (or until you change their values).
The variable XYZ is calculated on every bar and will have different values depending upon the closing price on each bar. Past values of XYZ are available. The equation for Slope refers to the value of XYZ 10 bars back.
A bit confusing - but it works.
Bob Fulks
At 10:57 PM +0200 8/18/00, Carsten Wolters wrote:
>I'm working on a radar screen indicator with trendlines. I have much
>experience in programming but I'm a newbie in using Easy Language.
>
>My question: can I (and how) store computed data in a persitent
>memory block, which will live more than the one tick the indicator is
>called?
>
>I calculate many trendlines and would like to store the data of them
>in a persitent array. Then every tick I will do some examinations
>with the array without regenerating the whole stuff.
>
>Is this possible and how to can I do it ?
|