09-25-2011, 11:09 PM
|
#1 |
Join Date: Nov 2008 Location: Northeast U.S. Thanks: 373
Thanked 231 Times in 164 Posts
| Once A section of code can be designated to only run once. This may improve performance if the indicator has lines of code that only need to be run one time initially. For example, the code could have a conditional check to determine if the current bar was the first bar on the chart, and make an initial calculation. But that conditional check will run every time there is a new bar on the chart. This conditional check on every bar would be inefficient and unnecessary on every bar except the first one.
One example of using the reserved word "Once" is when you want text to only show up on the current bar, and not every bar of the chart. The "Text_New" reserved word adds a text object to the chart only once, then the subsequent position of the text object is constantly updated with the Text_SetLocation reserved word. Code: Once
begin
Value1 = Text_New( D, T, (h+L)/2, " Begin" ) ; // Text_New add text object
end;
Text_SetLocation(Value1, D, T, (H+L)/2); // Text location updated to current time
__________________ Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens. |
| |