Study on a Study; then scale the study with the other?

Mal

New member
Hi All,

I have a strategy that I want to implement on TOS, but it rely's on indicators being set up the same way on another charting platform called TC2000. TC2000 allows you to overlay indicators and then has a feature to allow you take each indicator and scale it with another indicator you have overlayed. I do not see any scaling features on TOS so I am thinking unfortunately the code for the indicator would have to modified to provide the scaling.

Below shows an identical chart and setup for both TOS and TC2000 so you can see the visual difference that scaling creates in TC2000.

On the left is the TOS version; right is TC2000. The 2 indicators are at the bottom; the RSI 2 and the ADX 10. In the TC2000 picture the ADX indicator has been "Scaled with the RSI 2 indicator". TOS does not allow you to do this and you can see from the 2 pictures how different the ADX indicator looks on both.

Question:

1) Am I missing something on TOS that would allow this scaling to be done?
2) If there is nothing in TOS that would allow this scaling feature, does anyone understand exactly what the scaling might be doing to be able to say if the TOS ADX indicator could be changed to mimic this scaling feature in TC2000?

Really appreciate any help at all. My only other alternative is to subscribe to a monthly data plan with TC2000 which I really do not want to do as I do all of my trading / charting with TOS and have real time data there.

HPo8CHq.jpg
 

horserider

Well-known member
VIP
Code:
# RSI and ADX combined in one study. Horserider 2/29/2020
declare lower;

input lengthadx = 14;
input averageType = AverageType.WILDERS;

plot ADX = DMI(lengthadx, averageType).ADX;
ADX.setDefaultColor(GetColor(5));



input lengthrsi = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageTypersi = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageTypersi, price - price[1], lengthrsi);
def TotChgAvg = MovingAverage(averageTypersi, AbsValue(price - price[1]), lengthrsi);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 

Mal

New member
Code:
# RSI and ADX combined in one study. Horserider 2/29/2020
declare lower;

input lengthadx = 14;
input averageType = AverageType.WILDERS;

plot ADX = DMI(lengthadx, averageType).ADX;
ADX.setDefaultColor(GetColor(5));



input lengthrsi = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageTypersi = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageTypersi, price - price[1], lengthrsi);
def TotChgAvg = MovingAverage(averageTypersi, AbsValue(price - price[1]), lengthrsi);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Holy smokes that was fast :)
I applied it and it worked! Matches TC2000 perfectly.
Thank you very much Horserider, this is awesome, I was preparing myself for the response that is cannot be done or or incredibly difficult. I am looking at the code now to see if I can figure it out (i have not programmed any Thinkscript).
I actually have another indicator i also want to overlay on the RSI as well as this one; the "DMI" indicator. I posted the easiest question first just to see if it is possible and was hoping to get a response so that I can look into it and see if I can do the DMI myself. I am looking at the code you sent now along with the DMI base code and trying to figure out first the concept of what has changed from the original code.

If it easy for you to do and if you are bored lol if you want to take a shot at adding the DMI into this all that would be great. I am going to see if I can figure it out. Will check back if I am stumped.
Thanks one again!
 

Mal

New member
Nothing. All on same scale. So erase ADX code and Copy and paste the DMI code.
Unreal, it worked :). I am lacking some concepts in how this all works, will dig into it now that it works to see if I can understand. I can't thank you enough for the quick help on this. Glad it was not all that complicated.
 

Similar threads

Top