Welcome to the Traders Laboratory Forums.
TradeStation Custom Programming Discuss projects, ideas, obstacles in programming with TradeStation.

Reply
Old 09-25-2011, 11:09 PM   #1

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

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.
Tradewinds is offline  
Reply With Quote
The Following User Says Thank You to Tradewinds For This Useful Post:
MadMarketScientist (09-26-2011)

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


All times are GMT -4. The time now is 10:00 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.