Hi,
How can I access the code of the built in studies?
I have coding experience but new to thinkorswim
Thanks.
Hi,
I'm looking to edit the MACD indicator to add some sort of signal (maybe the pointer) when the macd values crosses a certain value.
Can the builtin studies be edited?
Or can this be done with having to touch the code? I don't seem to find a way.
Thanks
You can make a copy of the built-in code, create a new study and paste the ccde there. You can then modify it as you would like. Look at built-in scripts with crossovers or here in the search area, on how to code these. If you need more help, come back with a more specific request.
Hi,
How can I access the code of the built in studies?
I have coding experience but new to thinkorswim
Thanks.
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
# show macd value signals 20/06/2022
input macdHigh = 15;
input macdLow = -15;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
# show macd value signals 20/06/2022
plot UpSignalMacdValue = if Value >= macdHigh then Value else Double.NaN;
plot DownSignalMacdValue = if Value <= macdLow then Value else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
# show macd value signals 20/06/2022
UpSignalMacdValue.SetDefaultColor(Color.UPTICK);
UpSignalMacdValue.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignalMacdValue.SetDefaultColor(Color.DOWNTICK);
DownSignalMacdValue.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
I've done my mod. Not sure if this is useful to anyone but I'll share it.
It adds a signal when the MACD value goes above/below a previously set value for high and low.
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
# show macd value signals 20/06/2022
input macdHigh = 15;
input macdLow = -15;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
# show macd value signals 20/06/2022
plot UpSignalMacdValue = if Value >= macdHigh then Value else Double.NaN;
plot DownSignalMacdValue = if Value <= macdLow then Value else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
# show macd value signals 20/06/2022
UpSignalMacdValue.SetDefaultColor(Color.UPTICK);
UpSignalMacdValue.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignalMacdValue.SetDefaultColor(Color.DOWNTICK);
DownSignalMacdValue.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
R | Stoch, RSI, MACD bullish | Questions | 4 | |
R | AO, MACD and RSI of VIX in SPY chart | Questions | 3 | |
E | Help: ATR Zones, EMA Cloud, MACD, and Structure Lines | Questions | 1 | |
J | psar macd --need ma cross | Questions | 1 | |
V | Reference Different Symbol for MACD | Questions | 2 |
Start a new thread and receive assistance from our community.
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.
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.