Comparing two index futures market in ThinkorSwim?

S

ssara

New member
VIP
Hello is there way to compare two data lines - Say YM and ES futures to see the divergence of price between the two. Please advise
 
T

tomsk

Well-known member
VIP
Real simple solution.

First load /YM on your chart
Then load the standard TOS study called Comparison, and configure the "secondary security" to /ES
You do that directly in the user interface.

Voila! You now have a nice comparison chart between /YM and /ES.
From what I see, /ES is doing better
 
wilmanv

wilmanv

Member
VIP
Yes I tested that studie, but just allow me 2 symbols , but I am looking some script that can change the # of symbols, 3-4-5-6. Thank you Sir
 
T

tomsk

Well-known member
VIP
The initial query on this thread is to compare TWO index futures market, so toward that the TOS comparison tool allows one to do that very nicely. Unfortunately there is no standard TOS study that allows you to compare 5-6 simultaneous tickers. In order to do that you'll have to write your own custom study.

The closest study I can think of that achieves that is Jaime Pinto's S&P 500 Sector Performance study which needs to be modified to suit your needs. You can read about it at the following link

https://usethinkscript.com/threads/s-p-500-sector-performance.1152/
 
Last edited:
MrD

MrD

New member
i think it also depends on what you mean, or want when you say compare. because of course, you can add more than 1 comparison to the list and thus more tickers beyond one. all 1 2 or 5 will then show in the upper price area of the chart but what type of comparison do you wish to analyze ? price action? then you are done but percentage difference? momentum, trend ? the list goes on and thus so does a complete answer. i know its easy to confuse a question, but i dont see what stops you from adding more than 1 comparison and changing the ticker to whatever you wish to compare.
 
wilmanv

wilmanv

Member
VIP
i think it also depends on what you mean, or want when you say compare. because of course, you can add more than 1 comparison to the list and thus more tickers beyond one. all 1 2 or 5 will then show in the upper price area of the chart but what type of comparison do you wish to analyze ? price action? then you are done but percentage difference? momentum, trend ? the list goes on and thus so does a complete answer. i know its easy to confuse a question, but i dont see what stops you from adding more than 1 comparison and changing the ticker to whatever you wish to compare.
To analyze correlation: Sample: QQQ, SPY, DIA, IWM - FAANG Group , Thanks
 
MrD

MrD

New member
ok so seems like you're just not sure how to do it yet right? if so add selected "comparison" to the chart, 4 or more times and you'll see they all say "SPX" but then go into settings for ea by selecting the cog *
then change the ticker of the secondary to anything you like and voila' your done ..you can also select specific colors and line, candle or bar for each. i hope that helps good luck
 
S

ssara

New member
VIP
Hello -- I was trying to do Price divergences. So ES made higher high swing but YM does not - showing YM is weaker than ES... So its like instead of some indicator vs price divergence on the same instrument - was looking to do the same for INTERMARKET - one made higher high - other did not - 3-4 times a week this condition takes place - wanted to put some ARROWS once that condition are met on 15 and 1 hr chart - 1 hr good for options. Let me try the above suggestions - thanks in advance
 
2

2sureshk

Member
Hi Experts

I need help in (RSC) relative strength comparison indicator to compare between stocks. Multiple tickers with RSC and Ratio .

please type ‘relative strength comparison’ on GOOGLE search the first page with fiedility will come with a chart.
I am looking for the same indicator

any help is appreciated
Thanks
Suresh
 
T

tlee404

New member
I am looking for code to get the difference between 2 symbols or stocks as a line on a chart. For example the difference between MA and V as a line chart.
With the current chart setup the first stock is selected when I select a stock for a chart. But How do I add the closing prices for a second stock to get the difference?
Or is there a better way to enter the closing prices for the 2 stocks?
 
JADragon3

JADragon3

New member
Multi Symbol Comparison as a lower study. You can get pretty creative with it. Add composite symbols to track indexes for better visualization.
Code:
declare lower;

#hint showKey: OFF hides the symbol key, NUM numbers the symbol text, TXT shows just the symbol text.
input showKey = {OFF, NUM, default TXT};
#hint price: Changes the fundamental price type.
input price = FundamentalType.CLOSE;
#The following symbols may be changed to your preference but none should be blank. You may turn off any of these via the 'input use? = ' function. Each symbol is implied-numbered from 1 to 10, top-to-bottom sequentially.
input symbol1 = "SPY";
input symbol2 = "QQQ";
input symbol3 = "IWM";
input symbol4 = "DIA";
input symbol5 = "AAPL";
input symbol6 = "FCX";
input symbol7 = "GOOG";
input symbol8 = "IBM";
input symbol9 = "JPM";
input symbol10 = "XOM";

#hint use1: use1 to use10 toggle display of their respective symbol.
input use1 = Yes;
input use2 = Yes;
input use3 = Yes;
input use4 = Yes;
input use5 = Yes;
input use6 = Yes;
input use7 = Yes;
input use8 = Yes;
input use9 = Yes;
input use10 = Yes;
# changing the Min and Max values will determine the minimum and maximum plotted values for all symbols.

script normalize {
    input data = close;
    input Min = -10000;
    input Max = 10000;

    def ha = HighestAll( data );
    def la = LowestAll( data );
    plot normalize = (((Max - Min) * (data - la)) / (ha - la)) + Min;
}

def s1 = if use1 then Fundamental(price, symbol1) else Double.NaN;
def s2 = if use2 then Fundamental(price, symbol2) else Double.NaN;
def s3 = if use3 then Fundamental(price, symbol3) else Double.NaN;
def s4 = if use4 then Fundamental(price, symbol4) else Double.NaN;
def s5 = if use5 then Fundamental(price, symbol5) else Double.NaN;
def s6 = if use6 then Fundamental(price, symbol6) else Double.NaN;
def s7 = if use7 then Fundamental(price, symbol7) else Double.NaN;
def s8 = if use8 then Fundamental(price, symbol8) else Double.NaN;
def s9 = if use9 then Fundamental(price, symbol9) else Double.NaN;
def s10 = if use10 then Fundamental(price, symbol10) else Double.NaN;

def r1 = CompoundValue(1, if !IsNaN(s1) then normalize(s1) else r1[1], Double.NaN);
def r2 = CompoundValue(1, if !IsNaN(s2) then normalize(s2) else r2[1], Double.NaN);
def r3 = CompoundValue(1, if !IsNaN(s3) then normalize(s3) else r3[1], Double.NaN);
def r4 = CompoundValue(1, if !IsNaN(s4) then normalize(s4) else r4[1], Double.NaN);
def r5 = CompoundValue(1, if !IsNaN(s5) then normalize(s5) else r5[1], Double.NaN);
def r6 = CompoundValue(1, if !IsNaN(s6) then normalize(s6) else r6[1], Double.NaN);
def r7 = CompoundValue(1, if !IsNaN(s7) then normalize(s7) else r7[1], Double.NaN);
def r8 = CompoundValue(1, if !IsNaN(s8) then normalize(s8) else r8[1], Double.NaN);
def r9 = CompoundValue(1, if !IsNaN(s9) then normalize(s9) else r9[1], Double.NaN);
def r10 = CompoundValue(1, if !IsNaN(s10) then normalize(s10) else r10[1], Double.NaN);

# States: 0 = Not initialized, 1 = Initialized.
def st = {default "0", "1"};
# Offsets:
def ofst1;
def ofst2;
def ofst3;
def ofst4;
def ofst5;
def ofst6;
def ofst7;
def ofst8;
def ofst9;
def ofst10;

if st[1] == st."0" {
    if (!use1 or !IsNaN(r1)) and (!use2 or !IsNaN(r2))
  and (!use3 or !IsNaN(r3)) and (!use4 or !IsNaN(r4))
  and (!use5 or !IsNaN(r5)) and (!use6 or !IsNaN(r6))
  and (!use7 or !IsNaN(r7)) and (!use8 or !IsNaN(r8))
  and (!use9 or !IsNaN(r9)) and (!use10 or !IsNaN(r10))
    {
        ofst1 = r1;
        ofst2 = r2;
        ofst3 = r3;
        ofst4 = r4;
        ofst5 = r5;
        ofst6 = r6;
        ofst7 = r7;
        ofst8 = r8;
        ofst9 = r9;
        ofst10 = r10;
        st = st."1";
    } else {
    # Not initialized.
        ofst1 = Double.NaN;
        ofst2 = Double.NaN;
        ofst3 = Double.NaN;
        ofst4 = Double.NaN;
        ofst5 = Double.NaN;
        ofst6 = Double.NaN;
        ofst7 = Double.NaN;
        ofst8 = Double.NaN;
        ofst9 = Double.NaN;
        ofst10 = Double.NaN;
        st = st[1];
    }
} else {
    ofst1 = ofst1[1];
    ofst2 = ofst2[1];
    ofst3 = ofst3[1];
    ofst4 = ofst4[1];
    ofst5 = ofst5[1];
    ofst6 = ofst6[1];
    ofst7 = ofst7[1];
    ofst8 = ofst8[1];
    ofst9 = ofst9[1];
    ofst10 = ofst10[1];
    st = st[1];
}

def ok = !IsNaN(close) and st == st."1";
plot p1 = if ok then r1 - ofst1 else Double.NaN;
plot p2 = if ok then r2 - ofst2 else Double.NaN;
plot p3 = if ok then r3 - ofst3 else Double.NaN;
plot p4 = if ok then r4 - ofst4 else Double.NaN;
plot p5 = if ok then r5 - ofst5 else Double.NaN;
plot p6 = if ok then r6 - ofst6 else Double.NaN;
plot p7 = if ok then r7 - ofst7 else Double.NaN;
plot p8 = if ok then r8 - ofst8 else Double.NaN;
plot p9 = if ok then r9 - ofst9 else Double.NaN;
plot p10 = if ok then r10 - ofst10 else Double.NaN;

plot Zero = 0;
Zero.SetDefaultColor(Color.GRAY);

def n = showKey == showKey.NUM;

AddLabel(showKey and use1, (if n then "1. " else "") + symbol1, p1.TakeValueColor());
AddLabel(showKey and use2, (if n then "2. " else "") + symbol2, p2.TakeValueColor());
AddLabel(showKey and use3, (if n then "3. " else "") + symbol3, p3.TakeValueColor());
AddLabel(showKey and use4, (if n then "4. " else "") + symbol4, p4.TakeValueColor());
AddLabel(showKey and use5, (if n then "5. " else "") + symbol5, p5.TakeValueColor());
AddLabel(showKey and use6, (if n then "6. " else "") + symbol6, p6.TakeValueColor());
AddLabel(showKey and use7, (if n then "7. " else "") + symbol7, p7.TakeValueColor());
AddLabel(showKey and use8, (if n then "8. " else "") + symbol8, p8.TakeValueColor());
AddLabel(showKey and use9, (if n then "9. " else "") + symbol9, p9.TakeValueColor());
AddLabel(showKey and use10, (if n then "10. " else "") + symbol10, p10.TakeValueColor());
# end
 
Y

Youngjohnrhodes

New member
Hello is there way to compare two data lines - Say YM and ES futures to see the divergence of price between the two. Please advise
/YM - /ES
if you want to use a factor u can do 2*/YM-/ES
 
2

2sureshk

Member
How to find the factor ..

The above code gives the below error
No such variable: showkey
No such variable: showKey
No such variable: showKey
 
hectorgasm

hectorgasm

New member
@JADragon3 Thank you so much for this! do you know how can I make it work for tick charts?
 
S

ssara

New member
VIP
Also if there a way to add CYCLE start -- Weekly RESET - Daily Rest - Monthly Reset -- so for example with weekly FLAG we have the instrument reset at beginning of each week. So we can see all thing reset at 0 at start of the week
 
W

want2skydive

New member
Love this thing. Is it possible to pass through a Text the Displays the Symbol you have chosen instead of use1?

input symbol1 = "/ZT";

input "/ZT" = Yes;

Great stuff. Did all the heavy lifting.
 
W

wen

New member
is it possible Comparison VIX with different time frame like 9 days, 30 days, 3 month, 6 month and year. add 100 sma
 
wilmanv

wilmanv

Member
VIP
Any scrip to comparing more than 3 symbols on TOS, I now TOS already has one but just is for 2 symbols

Thanks
 

Similar threads

Top