Martix Mod For ThinkOrSwim

CashMoney

Member
VIP
sPFiiCU.png


original Tradingview indicator can be found
https://www.tradingview.com/v/F8xm0G4D/

for the new ThinkorSwim code, you must scroll down to the next post.
 
Last edited by a moderator:
@APOT7
see the code below

CSS:
#study("Matrix Mod",shorttitle="MS",precision=1)
# Converted and mod by Sam4Cok@Samer800 - 11/2022 - request from usethinkScript.com memeber
declare lower;
input ColorBars = yes;
input obOsBars = yes;
input Smoother = 5;
input SupResPeriod = 50;
input SupResPercentage = 100;
input BandType = {Default Dynamic, Static};
input PricePeriod = 16;
input Overbought = 200;    # "Overbought"
input Oversold = -200;     # "Oversold"


def na = Double.NaN;
def band = if BandType == BandType.Dynamic then 1 else 0;
#//--Sup/Res Detail

def ys1 = ( high + low + close * 2 ) / 4;
def rk3 = ExpAverage( ys1, Smoother );
def rk4 = StDev(ys1, Smoother);
def rk5 = (ys1 - rk3 ) * 200 / rk4;
def rk6 = ExpAverage( rk5, Smoother );
def up = ExpAverage(rk6, Smoother );
def down = ExpAverage( up, Smoother );
def Oo = If( up < down, up, down );
def Hh = Oo;
def Ll = If( up < down, down, up );
def Cc = Ll;
def vcolor = if Oo > Cc then 0 else if  up > down then 1 else 0;

#// Body Calculations
def bodyHigh = If(up > down, up, down);
def bodyLow = If(Oo < down, up, down);
def body0 = if (up > 0 and down > 0) or (up > 0 and down < 0) then bodyHigh else
            if (up < 0 and down < 0) or (up < 0 and down > 0) then bodyLow else 0;
def body1 = if up < 0 and down > 0 then bodyHigh else if up > 0 and down < 0 then bodyLow else 0;
def bodyCover = if up > 0 and down > 0 then bodyLow else if up < 0 and down < 0 then bodyHigh else 0;
#// Wick Calculations
def wick0 = If(Hh > 0, Hh, Ll);
def wick1 = If(Hh > 0 and Ll < 0, Ll, Hh);
def wickCover = if Hh > 0 and Ll > 0 then Ll else if Hh < 0 and Ll < 0 then Hh else 0;

plot Cover = bodyCover;
Cover.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Cover.SetDefaultColor(Color.WHITE);

plot LowerLine = Cc;
LowerLine.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
LowerLine.AssignValueColor(if vcolor then Color.GREEN else Color.RED);

plot HighLine = Oo;
HighLine.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
HighLine.AssignValueColor(if vcolor then Color.GREEN else Color.RED);

#//-------S/R Zones------
def Lookback = SupResPeriod;
def PerCent = SupResPercentage;
def Pds = PricePeriod;

def C3 = CCI(Length = Pds);
def Osc = C3;
def Value1 = Osc;
def Value2 = Highest(Value1, Lookback);
def Value3 = Lowest(Value1, Lookback);
def Value4 = Value2 - Value3;
def Value5 = Value4 * (PerCent / 100);
def ResistanceLine = Value3 + Value5;
def SupportLine = Value2 - Value5;

plot dynamicRes = If(band, ResistanceLine, na);
dynamicRes.SetDefaultColor(Color.GREEN);
plot dynamicSup = If(band, SupportLine, na);
dynamicSup.SetDefaultColor(Color.RED);

#//--Overbought/Oversold/Warning Detail
def UPshape = if up > 200 and up > down then Highest(up, 1) + 20 else
              if up > 200 and up < down then Highest(down, 1) + 20 else na;
def DOWNshape = if down < -200 and up > down then Lowest(down, 1) - 20 else
                if down < -200 and up < down then Lowest(up, 1) - 20 else na;

plot UpLine = UPshape;
UpLine.SetDefaultColor(Color.MAGENTA);
UpLine.SetLineWeight(2);
plot DnLine = DOWNshape;
DnLine.SetDefaultColor(Color.CYAN);
DnLine.SetLineWeight(2);

def x1 = If(band or IsNaN(close), na, Overbought);
def x2 = If(band or IsNaN(close), na, Oversold);
plot OverBoughtLine = x1;
OverBoughtLine.SetDefaultColor(Color.GRAY);
OverBoughtLine.SetStyle(Curve.MEDIUM_DASH);
plot OverSoldLine = x2;
OverSoldLine.SetDefaultColor(Color.GRAY);
OverSoldLine.SetStyle(Curve.MEDIUM_DASH);
plot ZeroLine = If(IsNaN(close), na , 0);
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.SHORT_DASH);

#--- Bar Color

AssignPriceColor(if ! ColorBars then Color.CURRENT else
                 if Oo > 0 then if vcolor then Color.GREEN else Color.DARK_RED else
                                if vcolor then Color.DARK_GREEN else Color.RED);
AssignPriceColor(if !obOsBars then Color.CURRENT else
                 if Oo > 200 then Color.MAGENTA else
                 if Cc < -200 then Color.CYAN else Color.CURRENT);


#---- ENd Code
 
@APOT7
see the code below

CSS:
#study("Matrix Mod",shorttitle="MS",precision=1)
# Converted and mod by Sam4Cok@Samer800 - 11/2022 - request from usethinkScript.com memeber
declare lower;
input ColorBars = yes;
input obOsBars = yes;
input Smoother = 5;
input SupResPeriod = 50;
input SupResPercentage = 100;
input BandType = {Default Dynamic, Static};
input PricePeriod = 16;
input Overbought = 200;    # "Overbought"
input Oversold = -200;     # "Oversold"


def na = Double.NaN;
def band = if BandType == BandType.Dynamic then 1 else 0;
#//--Sup/Res Detail

def ys1 = ( high + low + close * 2 ) / 4;
def rk3 = ExpAverage( ys1, Smoother );
def rk4 = StDev(ys1, Smoother);
def rk5 = (ys1 - rk3 ) * 200 / rk4;
def rk6 = ExpAverage( rk5, Smoother );
def up = ExpAverage(rk6, Smoother );
def down = ExpAverage( up, Smoother );
def Oo = If( up < down, up, down );
def Hh = Oo;
def Ll = If( up < down, down, up );
def Cc = Ll;
def vcolor = if Oo > Cc then 0 else if  up > down then 1 else 0;

#// Body Calculations
def bodyHigh = If(up > down, up, down);
def bodyLow = If(Oo < down, up, down);
def body0 = if (up > 0 and down > 0) or (up > 0 and down < 0) then bodyHigh else
            if (up < 0 and down < 0) or (up < 0 and down > 0) then bodyLow else 0;
def body1 = if up < 0 and down > 0 then bodyHigh else if up > 0 and down < 0 then bodyLow else 0;
def bodyCover = if up > 0 and down > 0 then bodyLow else if up < 0 and down < 0 then bodyHigh else 0;
#// Wick Calculations
def wick0 = If(Hh > 0, Hh, Ll);
def wick1 = If(Hh > 0 and Ll < 0, Ll, Hh);
def wickCover = if Hh > 0 and Ll > 0 then Ll else if Hh < 0 and Ll < 0 then Hh else 0;

plot Cover = bodyCover;
Cover.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Cover.SetDefaultColor(Color.WHITE);

plot LowerLine = Cc;
LowerLine.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
LowerLine.AssignValueColor(if vcolor then Color.GREEN else Color.RED);

plot HighLine = Oo;
HighLine.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
HighLine.AssignValueColor(if vcolor then Color.GREEN else Color.RED);

#//-------S/R Zones------
def Lookback = SupResPeriod;
def PerCent = SupResPercentage;
def Pds = PricePeriod;

def C3 = CCI(Length = Pds);
def Osc = C3;
def Value1 = Osc;
def Value2 = Highest(Value1, Lookback);
def Value3 = Lowest(Value1, Lookback);
def Value4 = Value2 - Value3;
def Value5 = Value4 * (PerCent / 100);
def ResistanceLine = Value3 + Value5;
def SupportLine = Value2 - Value5;

plot dynamicRes = If(band, ResistanceLine, na);
dynamicRes.SetDefaultColor(Color.GREEN);
plot dynamicSup = If(band, SupportLine, na);
dynamicSup.SetDefaultColor(Color.RED);

#//--Overbought/Oversold/Warning Detail
def UPshape = if up > 200 and up > down then Highest(up, 1) + 20 else
              if up > 200 and up < down then Highest(down, 1) + 20 else na;
def DOWNshape = if down < -200 and up > down then Lowest(down, 1) - 20 else
                if down < -200 and up < down then Lowest(up, 1) - 20 else na;

plot UpLine = UPshape;
UpLine.SetDefaultColor(Color.MAGENTA);
UpLine.SetLineWeight(2);
plot DnLine = DOWNshape;
DnLine.SetDefaultColor(Color.CYAN);
DnLine.SetLineWeight(2);

def x1 = If(band or IsNaN(close), na, Overbought);
def x2 = If(band or IsNaN(close), na, Oversold);
plot OverBoughtLine = x1;
OverBoughtLine.SetDefaultColor(Color.GRAY);
OverBoughtLine.SetStyle(Curve.MEDIUM_DASH);
plot OverSoldLine = x2;
OverSoldLine.SetDefaultColor(Color.GRAY);
OverSoldLine.SetStyle(Curve.MEDIUM_DASH);
plot ZeroLine = If(IsNaN(close), na , 0);
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.SHORT_DASH);

#--- Bar Color

AssignPriceColor(if ! ColorBars then Color.CURRENT else
                 if Oo > 0 then if vcolor then Color.GREEN else Color.DARK_RED else
                                if vcolor then Color.DARK_GREEN else Color.RED);
AssignPriceColor(if !obOsBars then Color.CURRENT else
                 if Oo > 200 then Color.MAGENTA else
                 if Cc < -200 then Color.CYAN else Color.CURRENT);


#---- ENd Code
nice job! thank you!!!! one request. I was playing around with the code and I wasn't able to figure out how to make both dynamic and static bands/lines show up. input BandType = {Default Dynamic, Static}. What should i change. Please help! thank you!!!
 
nice job! thank you!!!! one request. I was playing around with the code and I wasn't able to figure out how to make both dynamic and static bands/lines show up. input BandType = {Default Dynamic, Static}. What should i change. Please help! thank you!!!
change remove "Band" from x1 and x2 at the end of the code. i.e

replace the belw:

def x1 = If(band or IsNaN(close), na, Overbought);
def x2 = If(band or IsNaN(close), na, Oversold);

with

def x1 = If(IsNaN(close), na, Overbought);
def x2 = If( IsNaN(close), na, Oversold);
 
Could anyone please help in adding a scan for this - when it is Oversold and changing color, indicating to become bullish?
 
Could anyone please help in adding a scan for this - when it is Oversold and changing color, indicating to become bullish?
Given that this Matrix script uses the same calculations as the original Matrix script
https://usethinkscript.com/threads/the-matrix-indicator-for-thinkorswim.1657/

The scan filters found in the original Matrix will provide what you are seeking.
https://usethinkscript.com/threads/the-matrix-indicator-for-thinkorswim.1657/#post-150569
BUT you must change all the input settings to match!
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
649 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top