Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 10-03-2008, 10:47 AM   #1

Tasuki's Avatar

Join Date: Mar 2007
Location: San Diego north
Posts: 439
Ignore this user

Thanks: 143
Thanked 181 Times in 90 Posts

Recoding TS Indicators to Make Them More Efficient?

The gist of this post is that I'm looking for someone to help me re-code tradestation indicators to make them more efficient. However, I don't even know if this is worth the time and effort. The idea for doing this began when I started a thread on the tradestation forum which wound up turning into a discussion of the importance of re-coding TS indicators to make them more efficient. Here's the thread (you have to be a TS customer to get in, I think):
https://www.tradestation.com/Discuss...Topic_ID=81245

Anyway, I was wondering if anyone who knows easylanguage and tradestation knows:
1) whether this is possible?
2) how you'd know if your new code was more efficient?
3) whether it would be worth the time and effort?

Here's a quote from the thread that gets to the heart of the matter:

-----------------------------------------------------------------------
"First thing is make sure your code is running efficiently. Clean up the code, make it efficient. And either use STO or something similar. STO reduces the # of calcs by as much as 90%. I have one indicator that I only update once per second. Another thing I do is to consolidate indicators/paintbars/everything running realtime into one indicator. You have to look at it from the perspective of reducing the # of instructions being sent to the cpu. Every if statement matters.
Further still, arrange your code so you don't keep repeating the same calc when nothing will change. For example, there is no need to keep repeating the lookback calcs over and over in stochastics. Do it once then modify the result if the current bar changes.
It is worth noting also that many "stock" TS indicators are built for convenience, not speed. I don't use userfunctions in realtime indicators. And sure as heck would never use one of those multi-ouput 3-4 layer of userfunction things. Make your own to do only what you need. Look at the TS function highest. Dig through all the layers to get to the real meat of it. In comparison, all you actually need is 4-5 lines of code. "
------------------------------------------------------------------------

So, my dear Traders Labmates, does this make sense? And is there anybody out there in TL-land that can do this (for a fee, of course)?
Tasuki is offline  
Reply With Quote
Old 10-03-2008, 07:08 PM   #2

Join Date: Feb 2007
Location: US
Posts: 314
Ignore this user

Thanks: 86
Thanked 206 Times in 89 Posts

Re: Recoding TS Indicators to Make Them More Efficient?

You are unlikely to get more detailed help here than on the TS forum. The advices on the TS forum from the likes of solidus, mmillar, Javln, goose are all good and should be followed. The whole idea of optimization is to avoid calculations that you don't need or want and be sure you don't have to do it intrabar if you can help it. That is the basis of STO (same tick optimization).

Quote:
The Auto Detect feature can be overwritten, and the optimization can be forced to be always on or off by selecting either the On or Off setting on the Advanced tab. The setting can also be set through an EasyLanguage attribute in the code. The syntax of the attribute is:
[SameTickOpt = Value] where Value can be either True or False

If you have EasyLanguage analysis techniques which do not require that calculations occur when multiple ticks are received at the same price level, then you might consider using this new optimization setting to reduce any unnecessary CPU load and improve overall tradestation platform performance.
When plotting text, avoid updating the same text intrabar by:
Quote:
You may want to plot Text only at the End of the Bar...

if (BarStatus(1)=2) then
begin
::::::
::::::
end;
thrunner is offline  
Reply With Quote
Old 10-10-2008, 06:27 AM   #3

BlowFish's Avatar

Join Date: Mar 2007
Location: In Da House
Posts: 3,292
Ignore this user

Thanks: 129
Thanked 1,054 Times in 702 Posts

Re: Recoding TS Indicators to Make Them More Efficient?

What is the study you want to speed up? The chances are that you will be able to, often significantly. Some of the inbuilt TS functions are pretty in efficient for a kick off. The big savings are if you can avoid loops and to shorten the stuff that's done on every tick.
BlowFish is offline  
Reply With Quote
Old 10-10-2008, 10:55 PM   #4

Tasuki's Avatar

Join Date: Mar 2007
Location: San Diego north
Posts: 439
Ignore this user

Thanks: 143
Thanked 181 Times in 90 Posts

Re: Recoding TS Indicators to Make Them More Efficient?

Blowfish, I 'm using mostly just the basic indicators, CCI, MACD, RSI, stochs, a few moving averages.

How do you know if an indicator is updating on every tick? I can't tell myself by looking at the code. Is there some way to tell the indicator only to update if the value changes, rather than every tick whether the value changes or not?
Tasuki is offline  
Reply With Quote
Old 10-11-2008, 10:25 AM   #5

Blu-Ray's Avatar

Join Date: Nov 2006
Location: England
Posts: 508
Ignore this user

Thanks: 164
Thanked 292 Times in 105 Posts

Re: Recoding TS Indicators to Make Them More Efficient?

Quote:
Originally Posted by Tasuki »
How do you know if an indicator is updating on every tick? I can't tell myself by looking at the code. Is there some way to tell the indicator only to update if the value changes, rather than every tick whether the value changes or not?
Hi Taz

I've sent you an email about it, but I'll quickly explain it here for anyone else reading this.

Format the indicator and select the "Advanced tab", then select the "On" rather than "Auto Detect"..... but there is a bug within TS 8.3 build 1631 so this feaute won't work unless you get the fix via request from TS.



Hope this helps

Blu-Ray
Attached Thumbnails
Recoding TS Indicators to Make Them More Efficient?-sto.png  
__________________

“ Search is the ultimate expression of the power of the individual, using a computer, looking at the world, and finding exactly what they want ” – Eric Schmidt, Google
Blu-Ray is offline  
Reply With Quote
The Following 2 Users Say Thank You to Blu-Ray For This Useful Post:
minoo (10-19-2008), Tasuki (10-12-2008)
Old 10-12-2008, 06:00 AM   #6

BlowFish's Avatar

Join Date: Mar 2007
Location: In Da House
Posts: 3,292
Ignore this user

Thanks: 129
Thanked 1,054 Times in 702 Posts

Re: Recoding TS Indicators to Make Them More Efficient?

Quote:
Originally Posted by Tasuki »
Blowfish, I 'm using mostly just the basic indicators, CCI, MACD, RSI, stochs, a few moving averages.

How do you know if an indicator is updating on every tick? I can't tell myself by looking at the code. Is there some way to tell the indicator only to update if the value changes, rather than every tick whether the value changes or not?
If memory serves correctly (and things haven't changed) TS does not code moving averages efficiently.

For example the common way to do a 10 period simple moving average is in a loop adding each of the 10 closes and then dividing by 10.

The efficient way is to add 1/10th of the new close and subtract 1/10th of the close 10 bars ago.

There are many examples of this sort of optimisation that will yield significant speed improvements.
BlowFish is offline  
Reply With Quote
Old 10-13-2008, 01:13 AM   #7

Tasuki's Avatar

Join Date: Mar 2007
Location: San Diego north
Posts: 439
Ignore this user

Thanks: 143
Thanked 181 Times in 90 Posts

Re: Recoding TS Indicators to Make Them More Efficient?

Quote:
Originally Posted by BlowFish »
If memory serves correctly (and things haven't changed) TS does not code moving averages efficiently.

For example the common way to do a 10 period simple moving average is in a loop adding each of the 10 closes and then dividing by 10.

The efficient way is to add 1/10th of the new close and subtract 1/10th of the close 10 bars ago.

There are many examples of this sort of optimisation that will yield significant speed improvements.
Blowfish, in what way is your approach more efficient?
Tasuki is offline  
Reply With Quote
Old 10-13-2008, 07:15 PM   #8

Join Date: Nov 2007
Location: Chicago
Posts: 12
Ignore this user

Thanks: 1
Thanked 1 Time in 1 Post

Re: Recoding TS Indicators to Make Them More Efficient?

Quote:
Originally Posted by Blu-Ray »
Hi Taz

I've sent you an email about it, but I'll quickly explain it here for anyone else reading this.

Format the indicator and select the "Advanced tab", then select the "On" rather than "Auto Detect"..... but there is a bug within TS 8.3 build 1631 so this feaute won't work unless you get the fix via request from TS.



Hope this helps

Blu-Ray
Blue-Ray,

Just for clarification, are you suggesting that the "On" versus "Auto Detect" option should be used as the default setting only if the indicator has been optimized or regardless if it has been optimized or not?

Thanks
buysell84 is offline  
Reply With Quote

Reply

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dollar Getting Ready to Make a Big Leg Down downrivertrader Market Analysis 17 08-08-2008 09:07 PM
Make sure to give the CL (Crude Oil) Contract Consideration! brownsfan019 Futures Trading Laboratory 11 12-06-2007 11:40 PM
How You Make Money Trading Forex keegan99k9 Forex Trading Laboratory 14 07-12-2007 11:08 AM
How Can We Make The Site Better? Soultrader General Discussion 37 02-04-2007 06:07 PM
How Many Trades Do You Make A Day? Soultrader Beginners Forum 13 01-16-2007 06:48 PM

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