MAC-Z VWAP Indicator For ThinkOrSwim

MasterMe

New member
MAC-Z VWAP Indicator - TradingView to TOS conversion
I am looking for some help in converting the below to a TOS script. This is currently in TradingView as "MAC-Z VWAP Indicator". Below is the source code and wondering if I can get some experts help to convert this to a TOS script.! Thank you
https://www.tradingview.com/script/HNrsbpJ2-MAC-Z-VWAP-Indicator-LazyBear/
AqqmP79.png
 
Last edited by a moderator:

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

I am pretty sure this is it, but keep in mind I don't actually know pine script.

Ruby:
# MAC-Z VWAP Indicator by LazyBear
# conversion by @Joshua 11/2021
input fastLength = 12;
input slowLength= 25;
input signalLength = 9;
input lengthz = 20;
input lengthStdev = 25;
input A = 1.0;
input B = 1.0;
input useLag = no;
input gamma = 0.02;
def source = close;
script Nz {
    input Num = 0;
    plot Nz = if isNaN(Num) then 0 else Num;
}
script calc_laguerre {
    input s = 0;
    input g = 0;
    def l0 = (1 - g)*s+g*nz(l0[1]);
    def l1 = -g*l0+nz(l0[1])+g*nz(l1[1]);
    def l2 = -g*l1+nz(l1[1])+g*nz(l2[1]);
    def l3 = -g*l2+nz(l2[1])+g*nz(l3[1]);
    plot calc_laguerre = (l0 + 2*l1 + 2*l2 + l3)/6;
}
script calc_zvwap {
    input pds = 0;
    def mean = sum(volume*close,pds)/sum(volume,pds);
    def vwapsd = sqrt(simpleMovingAvg(power(close-mean,2),pds));
    plot calc_zvwap = (close-mean)/vwapsd;
}
def zscore = calc_zvwap(lengthz);
def fastMA = simpleMovingAvg(source, fastLength);
def slowMA = simpleMovingAvg(source, slowLength);
def macd = fastMA - slowMA;
def macz_t = zscore*A+ macd/stdev(source, lengthStdev)*B;
def macz = if uselag then calc_laguerre(macz_t,gamma) else macz_t;
def signal=simpleMovingAvg(macz, signalLength);
def hist = macz-signal;
plot Histo = Hist;
Histo.SetDefaultColor(color.red);
Histo.setPaintingStrategy(paintingStrategy.HISTOGRAM);
plot MackLine = MacZ;
MackLine.SetDefaultColor(color.Green);
plot Sig = Signal;
Sig.SetDefaultColor(color.orange);
 
Last edited by a moderator:
I am pretty sure this is it, but keep in mind I don't actually know pine script.

Ruby:
# MAC-Z VWAP Indicator by LazyBear
# conversion by @Joshua 11/2021
input fastLength = 12;
input slowLength= 25;
input signalLength = 9;
input lengthz = 20;
input lengthStdev = 25;
input A = 1.0;
input B = 1.0;
input useLag = no;
input gamma = 0.02;
def source = close;
script Nz {
    input Num = 0;
    plot Nz = if isNaN(Num) then 0 else Num;
}
script calc_laguerre {
    input s = 0;
    input g = 0;
    def l0 = (1 - g)*s+g*nz(l0[1]);
    def l1 = -g*l0+nz(l0[1])+g*nz(l1[1]);
    def l2 = -g*l1+nz(l1[1])+g*nz(l2[1]);
    def l3 = -g*l2+nz(l2[1])+g*nz(l3[1]);
    plot calc_laguerre = (l0 + 2*l1 + 2*l2 + l3)/6;
}
script calc_zvwap {
    input pds = 0;
    def mean = sum(volume*close,pds)/sum(volume,pds);
    def vwapsd = sqrt(simpleMovingAvg(power(close-mean,2),pds));
    plot calc_zvwap = (close-mean)/vwapsd;
}
def zscore = calc_zvwap(lengthz);
def fastMA = simpleMovingAvg(source, fastLength);
def slowMA = simpleMovingAvg(source, slowLength);
def macd = fastMA - slowMA;
def macz_t = zscore*A+ macd/stdev(source, lengthStdev)*B;
def macz = if uselag then calc_laguerre(macz_t,gamma) else macz_t;
def signal=simpleMovingAvg(macz, signalLength);
def hist = macz-signal;
plot Histo = Hist;
Histo.SetDefaultColor(color.red);
Histo.setPaintingStrategy(paintingStrategy.HISTOGRAM);
plot MackLine = MacZ;
MackLine.SetDefaultColor(color.Green);
plot Sig = Signal;
Sig.SetDefaultColor(color.orange);

I am pretty sure this is it, but keep in mind I don't actually know pine script.

Ruby:
# MAC-Z VWAP Indicator by LazyBear
# conversion by @Joshua 11/2021
input fastLength = 12;
input slowLength= 25;
input signalLength = 9;
input lengthz = 20;
input lengthStdev = 25;
input A = 1.0;
input B = 1.0;
input useLag = no;
input gamma = 0.02;
def source = close;
script Nz {
    input Num = 0;
    plot Nz = if isNaN(Num) then 0 else Num;
}
script calc_laguerre {
    input s = 0;
    input g = 0;
    def l0 = (1 - g)*s+g*nz(l0[1]);
    def l1 = -g*l0+nz(l0[1])+g*nz(l1[1]);
    def l2 = -g*l1+nz(l1[1])+g*nz(l2[1]);
    def l3 = -g*l2+nz(l2[1])+g*nz(l3[1]);
    plot calc_laguerre = (l0 + 2*l1 + 2*l2 + l3)/6;
}
script calc_zvwap {
    input pds = 0;
    def mean = sum(volume*close,pds)/sum(volume,pds);
    def vwapsd = sqrt(simpleMovingAvg(power(close-mean,2),pds));
    plot calc_zvwap = (close-mean)/vwapsd;
}
def zscore = calc_zvwap(lengthz);
def fastMA = simpleMovingAvg(source, fastLength);
def slowMA = simpleMovingAvg(source, slowLength);
def macd = fastMA - slowMA;
def macz_t = zscore*A+ macd/stdev(source, lengthStdev)*B;
def macz = if uselag then calc_laguerre(macz_t,gamma) else macz_t;
def signal=simpleMovingAvg(macz, signalLength);
def hist = macz-signal;
plot Histo = Hist;
Histo.SetDefaultColor(color.red);
Histo.setPaintingStrategy(paintingStrategy.HISTOGRAM);
plot MackLine = MacZ;
MackLine.SetDefaultColor(color.Green);
plot Sig = Signal;
Sig.SetDefaultColor(color.orange);

You made my day Joshua. You are just awesome.!
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
306 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