How To Combine Studies (Indicators) For ThinkOrSwim
Members combine studies to create comprehensive strategies to be able to test for multiple conditions.
If the combined study is of ToS built-in indicators and it is only needed for upper chart calculations.
It is as simple as referencing the studies:
When combining lower chart studies with the purpose of creating a combined plot:
Combining and plotting lower chart studies can be problematic. While they may look good when you overlay them in your chart. Lower chart oscillators cannot be plotted together in the same script unless they show the same SCALE on the vertical axis. While it is possible to "normalize" indicators to the same scale, this has shown to sometimes have the habit of skewing the data.
Below are the simple steps to combine as many studies as you want for the purpose of manipulating the data (not attempting to plot the data on a lower chart).
It should be noted that studies should still be used separately in the Scan Hacker, where possible. The scanner is temperamental about studies that get too complex.
Bad News: It is an excruciatingly boring detailed process so unless the studies being combined are small and simple or another member is interested enough in the results to do it for you, the requests to combine indicators tend to not be fulfilled on this forum.
Good News: Combining Indicators is a relatively easy procedure. So feel free to do this yourself!![Thumbs up (y) (y)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
- - - - - - - - - - - - - - - - - - - - - -
Before Combining The Studies:
Review the code in each study.
Every statement in each of the studies that you want to smoosh together must have a unique identifying field names.
For example: if
StudyA has
StudyB has
The Combined Study will vomit an error when you paste them both together. Because they are both using the same named field: length .
Duplicate names are not allowed.
- - - - - - - - - - - - - - - - - - - - - -
StudyB has
That is all there is too it. Rinse and repeat for every duplicate name.
Then copy and paste your indicators into a new combined study.
Here are the additional common errors that will need to be cleaned up:
Members combine studies to create comprehensive strategies to be able to test for multiple conditions.
If the combined study is of ToS built-in indicators and it is only needed for upper chart calculations.
It is as simple as referencing the studies:
Ruby:
def RSI = reference RSI() ;
def Vroc= reference VolumeRateOfChange();
When combining lower chart studies with the purpose of creating a combined plot:
Combining and plotting lower chart studies can be problematic. While they may look good when you overlay them in your chart. Lower chart oscillators cannot be plotted together in the same script unless they show the same SCALE on the vertical axis. While it is possible to "normalize" indicators to the same scale, this has shown to sometimes have the habit of skewing the data.
Below are the simple steps to combine as many studies as you want for the purpose of manipulating the data (not attempting to plot the data on a lower chart).
It should be noted that studies should still be used separately in the Scan Hacker, where possible. The scanner is temperamental about studies that get too complex.
Bad News: It is an excruciatingly boring detailed process so unless the studies being combined are small and simple or another member is interested enough in the results to do it for you, the requests to combine indicators tend to not be fulfilled on this forum.
Good News: Combining Indicators is a relatively easy procedure. So feel free to do this yourself!
- - - - - - - - - - - - - - - - - - - - - -
Before Combining The Studies:
Review the code in each study.
Every statement in each of the studies that you want to smoosh together must have a unique identifying field names.
For example: if
StudyA has
andinput length =13 ;
plot ema21 = ExpAverage(close, length);
StudyB has
input length= 30;
def VolDayAvg = (fold index = 1 to length+ 1 with Avg = 0 do (Avg + volume(period = "DAY")[index])) / length;
The Combined Study will vomit an error when you paste them both together. Because they are both using the same named field: length .
Duplicate names are not allowed.
- - - - - - - - - - - - - - - - - - - - - -
- THEREFORE, EVERY NAME TO THE LEFT OF AN EQUAL SIGN MUST BE UNIQUE.
- Once you create a unique name THAT NEW NAME must be substituted throughout the code.
input lengthA =13 ;
plot ema21 = ExpAverage(close, lengthA );
StudyB has
input lengthB= 30;
def VolDayAvg = (fold index = 1 to lengthB+ 1 with Avg = 0 do (Avg + volume(period = "DAY")[index])) / lengthB;
That is all there is too it. Rinse and repeat for every duplicate name.
Then copy and paste your indicators into a new combined study.
Here are the additional common errors that will need to be cleaned up:
Error: Can only have one declare statement. Fix: delete any extra declare statements
Most Common Error: Identifier Already Used or Already assigned This means there STILL duplicate names. The error message will tell you what the duplicate name is. Go back to square one and rename the duplicates.
Last edited: