Impulse MACD [LazyBear] For ThinkOrSwim

Check it out.

CSS:
#// @author LazyBear
#// List of my public indicators: http://bit.ly/1LQaPK8
#// List of my app-store indicators: http://blog.tradingview.com/?p=970
#study("Impulse MACD [LazyBear]", shorttitle="IMACD_LB", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022

declare lower;
input BarColor = no;#input(false, title="Enable bar colors")
input lengthMA = 34;
input lengthSignal = 9;
input src = hlc3;

def na = Double.NaN;
#calc_smma(src, len) =>
script calc_smma {
input src = close;
input len = 34;
    def smma = if isNaN(smma[1]) then SimpleMovingAvg(src, len) else (smma[1] * (len - 1) + src) / len;
    plot return = smma;
}
#calc_zlema(src, length) =>
script calc_zlema {
input src = close;
input length = 34;
    def ema1 = ExpAverage(src, length);
    def ema2 = ExpAverage(ema1, length);
    def d    = ema1-ema2;
    def zelma = ema1+d;
 plot return = zelma;
}

def hi=calc_smma(high, lengthMA);
def lo=calc_smma(low, lengthMA);
def mi=calc_zlema(src, lengthMA);

def md = if (mi>hi)then (mi-hi) else if (mi<lo) then (mi - lo) else 0;
def sb = SimpleMovingAvg(md, lengthSignal);
def sh=md-sb;
def mdc = if src>mi then if src>hi then 2 else 1 else if src<lo then -2 else -1;

#--- PLots
plot ImpulseSignal = sb;
ImpulseSignal.SetDefaultColor(Color.WHITE);
ImpulseSignal.SetLineWeight(2);

plot ImpulseHisto = sh;
ImpulseHisto.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
ImpulseHisto.SetDefaultColor(Color.BLUE);

plot ImpulseMACD = md;
ImpulseMACD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ImpulseMACD.AssignValueColor(if mdc==2 then Color.GREEN else
                             if mdc==1 then Color.DARK_GREEN else
                             if mdc==-2 then Color.RED else Color.DARK_RED);

plot "0" = if isNaN(close) then na else 0;
"0".SetDefaultColor(Color.DARK_GRAY);

#--- Bar Color
AssignPriceColor(if !BarColor then Color.CURRENT else
                 if mdc==2 then Color.GREEN else
                 if mdc==1 then Color.DARK_GREEN else
                 if mdc==-2 then Color.RED else Color.DARK_RED);


#--- END Code
 
hello samer800 awesome work as Allways thankyou my problem is I TRY convert this inciator
Impulse MACD [Lazy Bear] For Thinkorswim AFTER I copy I paste Create It show Red please help
tank you YOUR FOLLOWERS RUSS
 
Last edited by a moderator:
hello samer800 awesome work as Allways thankyou my problem is I TRY convert this inciator
Impulse MACD [Lazy Bear] For Thinkorswim AFTER I copy I paste Create It show Red please help
tank you YOUR FOLLOWERS RUSS
Nope, no red here. It sounds like you copy & pasted the wrong script or did not copy & paste the complete script
Copy & paste this one:
https://usethinkscript.com/threads/impulse-macd-lazybear-for-thinkorswim.13333/#post-112509
vufvpQu.png

KciqS8u.png


You need to cut and paste again.
1. follow these instructions:
https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/
2. RE-COPY the WHOLE script MAKE SURE you are using this one:
https://usethinkscript.com/threads/impulse-macd-lazybear-for-thinkorswim.13333/#post-112509

Still having trouble?
You can use this shared study link: http://tos.mx/gM5vEan Click here for --> Easiest way to load shared links
 
#// @author LazyBear
#// List of my public indicators: http://bit.ly/1LQaPK8
#// List of my app-store indicators: http://blog.tradingview.com/?p=970
#study("Impulse MACD [LazyBear]", shorttitle="IMACD_LB", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
# modified on 5/Feb/2023

declare lower;
input BarColor = no; #input(false, title="Enable bar colors")
input lengthMA = 34;
input lengthSignal = 9;
input src = hlc3;

def na = Double.NaN;
#calc_smma(src, len) =>
script calc_smma {
input src = close;
input len = 34;
def smma = if isNaN(smma[1]) then SimpleMovingAvg(src, len) else (smma[1] * (len - 1) + src) / len;
plot return = smma;
}
#calc_zlema(src, length) =>
script calc_zlema {
input src = close;
input length = 34;
def ema1 = ExpAverage(src, length);
def ema2 = ExpAverage(ema1, length);
def d = ema1-ema2;
def zelma = ema1+d;
plot return = zelma;
}

def hi=calc_smma(high, lengthMA);
def lo=calc_smma(low, lengthMA);
def mi=calc_zlema(src, lengthMA);

def md = if (mi>hi)then (mi-hi) else if (mi<lo) then (mi - lo) else 0;
def sb = SimpleMovingAvg(md, lengthSignal);
def sh=md-sb;
def mdc = if src>mi then if src>hi then 2 else 1 else if src<lo then -2 else -1;

#--- PLots
plot ImpulseSignal = sb;
ImpulseSignal.SetDefaultColor(Color.WHITE);
ImpulseSignal.SetLineWeight(2);

plot ImpulseHisto = sh;
ImpulseHisto.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
ImpulseHisto.SetDefaultColor(Color.BLUE);

plot ImpulseMACD = md;
ImpulseMACD.SetLineWeight(2);
ImpulseMACD.AssignValueColor(if mdc==2 then Color.GREEN else
if mdc==1 then Color.DARK_GREEN else
if mdc==-2 then Color.RED else Color.orange);

plot "0" = if isNaN(close) then na else 0;
"0".SetDefaultColor(Color.DARK_GRAY);

#--- Bar Color
AssignPriceColor(if !BarColor then Color.CURRENT else
if mdc==2 then Color.GREEN else
if mdc==1 then Color.DARK_GREEN else
if mdc==-2 then Color.RED else Color.orange);
I would recommend changing the Plot of value "md" from histogram to line. In order to show the crossing more clearly.
 
Last edited:
where do you change that?
2oNJw4R.png

To change paint properties:
1. Click on gear to the right of the indicator in chart settings
2. Click on the ImpulseMACD
3. Click where there is a histogram icon and change it to a line
4. You can unclick Show Plot on the ImpulseHisto
Below see the MACD as a histogram versus as a line
If you prefer the line. Here is the cloud statement that is shown below. Add it to the bottom of your script
Ruby:
addcloud(md, sb, color.green, color.red);
HRIeY5H.png
 
Last edited:
Hello, is there a way to make the impulse histogram bigger (taller)?
You can. Not sure that you should.
To specify that the impulse histogram be a certain percentage bigger:

change this:
plot ImpulseHisto = sh;

to this:
plot ImpulseHisto = sh *1.5 ;
Change the 1.5 to whatever percentage "taller" that you want.

The blue impulse historgram at normal size
p9U1DzL.png

The blue histogram made bigger (taller)
88cBuFr.png

 
Last edited:
check it out
CSS:
#// @author LazyBear
#// List of my public indicators: http://bit.ly/1LQaPK8
#// List of my app-store indicators: http://blog.tradingview.com/?p=970
#study("Impulse MACD [LazyBear]", shorttitle="IMACD_LB", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022

declare lower;
input BarColor = no;#input(false, title="Enable bar colors")
input lengthMA = 34;
input lengthSignal = 9;
input src = hlc3;

def na = Double.NaN;
#calc_smma(src, len) =>
script calc_smma {
input src = close;
input len = 34;
    def smma = if isNaN(smma[1]) then SimpleMovingAvg(src, len) else (smma[1] * (len - 1) + src) / len;
    plot return = smma;
}
#calc_zlema(src, length) =>
script calc_zlema {
input src = close;
input length = 34;
    def ema1 = ExpAverage(src, length);
    def ema2 = ExpAverage(ema1, length);
    def d    = ema1-ema2;
    def zelma = ema1+d;
 plot return = zelma;
}

def hi=calc_smma(high, lengthMA);
def lo=calc_smma(low, lengthMA);
def mi=calc_zlema(src, lengthMA);

def md = if (mi>hi)then (mi-hi) else if (mi<lo) then (mi - lo) else 0;
def sb = SimpleMovingAvg(md, lengthSignal);
def sh=md-sb;
def mdc = if src>mi then if src>hi then 2 else 1 else if src<lo then -2 else -1;

#--- PLots
plot ImpulseSignal = sb;
ImpulseSignal.SetDefaultColor(Color.WHITE);
ImpulseSignal.SetLineWeight(2);

plot ImpulseHisto = sh;
ImpulseHisto.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
ImpulseHisto.SetDefaultColor(Color.BLUE);

plot ImpulseMACD = md;
ImpulseMACD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ImpulseMACD.AssignValueColor(if mdc==2 then Color.GREEN else
                             if mdc==1 then Color.DARK_GREEN else
                             if mdc==-2 then Color.RED else Color.DARK_RED);

plot "0" = if isNaN(close) then na else 0;
"0".SetDefaultColor(Color.DARK_GRAY);

#--- Bar Color
AssignPriceColor(if !BarColor then Color.CURRENT else
                 if mdc==2 then Color.GREEN else
                 if mdc==1 then Color.DARK_GREEN else
                 if mdc==-2 then Color.RED else Color.DARK_RED);


#--- END Code
Thank you! This is awesome!
I would recommend changing the Plot of value "md" from histogram to line. In order to show the crossing more clearly.
I have been testing this indicator and it has been pretty good. I have the histogram hidden and I converted the impulse macd to line as mentioned above. I was wondering if it's possible to apply a highertime frame impulse on a smaller time frame chart to stay in trades longer? I am mostly day trading on the 5 min and would like to apply the impulse macd from the 10 min to the 5 min chart.
 
Is it possible to add overbought and oversold levels to the study?

It's not hard to add them dynamically. Just add a plot for the highest high and lowest low of the impulse signal for last X number of bars. I did that mod for another platform (not TOS so please don't ask for the code). I haven't found the OB and OS levels as helpful as I'd hoped. For the timeframes and instruments that I trade, I prefer to look for agreement between fast and slow inputs. YMMV.

Best wishes and happy trading.
 
It's not hard to add them dynamically. Just add a plot for the highest high and lowest low of the impulse signal for last X number of bars. I did that mod for another platform (not TOS so please don't ask for the code). I haven't found the OB and OS levels as helpful as I'd hoped. For the timeframes and instruments that I trade, I prefer to look for agreement between fast and slow inputs. YMMV.

Best wishes and happy trading.
I tried this, but I can never get a straight horizontal line. Ended up getting lines that follow above or below the signal line instead
 
Can someone post the script with the cloud version only....I can't seem to get it to work by adding it at the end of the script. Thanks
 
Can someone post the script with the cloud version only....I can't seem to get it to work by adding it at the end of the script. Thanks
try thid
CSS:
#// @author LazyBear
#// List of my public indicators: http://bit.ly/1LQaPK8
#// List of my app-store indicators: http://blog.tradingview.com/?p=970
#study("Impulse MACD [LazyBear]", shorttitle="IMACD_LB", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022

declare lower;
input BarColor = no;#input(false, title="Enable bar colors")
input lengthMA = 34;
input lengthSignal = 9;
input src = hlc3;

def na = Double.NaN;
#calc_smma(src, len) =>
script calc_smma {
input src = close;
input len = 34;
    def smma = if isNaN(smma[1]) then SimpleMovingAvg(src, len) else (smma[1] * (len - 1) + src) / len;
    plot return = smma;
}
#calc_zlema(src, length) =>
script calc_zlema {
input src = close;
input length = 34;
    def ema1 = ExpAverage(src, length);
    def ema2 = ExpAverage(ema1, length);
    def d    = ema1-ema2;
    def zelma = ema1+d;
 plot return = zelma;
}

def hi=calc_smma(high, lengthMA);
def lo=calc_smma(low, lengthMA);
def mi=calc_zlema(src, lengthMA);

def md = if (mi>hi)then (mi-hi) else if (mi<lo) then (mi - lo) else 0;
def sb = SimpleMovingAvg(md, lengthSignal);
def sh=md-sb;
def mdc = if src>mi then if src>hi then 2 else 1 else if src<lo then -2 else -1;

#--- PLots
plot ImpulseSignal = sb;
ImpulseSignal.SetDefaultColor(Color.WHITE);
ImpulseSignal.SetLineWeight(2);

plot ImpulseHisto = sh;
ImpulseHisto.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
ImpulseHisto.SetDefaultColor(Color.BLUE);

plot ImpulseMACD = md;
#ImpulseMACD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ImpulseMACD.AssignValueColor(if mdc==2 then Color.GREEN else
                             if mdc==1 then Color.DARK_GREEN else
                             if mdc==-2 then Color.RED else Color.DARK_RED);

plot "0" = if isNaN(close) then na else 0;
"0".SetDefaultColor(Color.DARK_GRAY);

#--- Bar Color
AssignPriceColor(if !BarColor then Color.CURRENT else
                 if mdc==2 then Color.GREEN else
                 if mdc==1 then Color.DARK_GREEN else
                 if mdc==-2 then Color.RED else Color.DARK_RED);


#--- END Code

addcloud(md, sb, color.green, color.red);
 

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
448 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