Turn bottom Zig Zag into an MTF indicator

germanburrito

Active member
I cannot seem to figure out how to add the bottom code MTF, its great for direction.

Code:
declare lower;


input method = {default average, high_low};

def percentamount = .01;
def revAmount = .05;
def atrreversal = 1.68;
def atrlength = 5;
def pricehigh = high;
def pricelow = low;
def averagelength = 5;
def averagetype = AverageType.WEIGHTED;
def mah = MovingAverage(averagetype, pricehigh, averagelength);
def mal = MovingAverage(averagetype, pricelow, averagelength);
def priceh2 = if method == method.high_low then pricehigh else mah;
def pricel2 = if method == method.high_low then pricelow else mal;
def EI = ZigZagHighLow("price h" = priceh2, "price l" = pricel2, "percentage reversal" = percentamount, "absolute reversal" = revAmount, "atr length" = atrlength, "atr reversal" = atrreversal);

rec EISave = if !IsNaN(EI) then EI else GetValue(EISave, 1);
def chg = (if EISave == priceh2 then priceh2 else pricel2) - GetValue(EISave, 1);
def isUp = chg > 0;
def isDown = chg < 0;

plot Bullish = isUp;
Bullish.SetDefaultColor(Color.GREEN);
plot Bearish = isDown;
Bearish.SetDefaultColor(Color.RED);



# Alerts:
#
rec counter;
if (Bullish) {
    counter = 1;
} else {
    if (counter[1] == 1 or counter[1] < 10) {
        counter = counter[1] + 1;
    } else {
        counter = 1;
    }
}

rec counterd;
if (Bearish) {
    counterd = 1;
} else {
    if (counterd[1] == 1 or counterd[1] < 10) {
        counterd = counterd[1] + 1;
    } else {
        counterd = 1;
    }
}

def LongSignal = counterd == 3;
def ShortSignal = counter == 3;


# BLOCK CODE BELOW
input AlertSoundUP = {default “Bell”, “Chimes”, “Ding”, “NoSound”, “Ring”};
input AlertSoundDOWN = {“Bell”, “Chimes”, “Ding”, “NoSound”, default “Ring”};
Alert(LongSignal , text = "UP UP UP", Alert.BAR, AlertSoundUP);
Alert(ShortSignal , text = "DOWN DOWN DOWN", Alert.BAR, AlertSoundDOWN);

q4RrLQq.png
 
Last edited by a moderator:
Well, I haven't had much time to look into this but I did run a test by simply duplicating the indicator so there are three iterations with different average lengths by changing atrlength and averagelength just to see what that would show... Here was the result... Do you see any benefit from this...??? That was the best I could do for a quick test... I'm not sure if I'll have time later so perhaps someone else can dig deeper...

1uRdP1z.jpg
 
Thank you so much I do think it helps visualize what how the trend changes on with different lengths, I have not tested this indicator to this extent. I know someone else who can help and simplify the indicator into a binary code, however I do not want to give him homework lol, but I know henry1224 is great with these type of indicators from what I've seen, I even believe he might have codes like these.
 
hi, can anyone help me with making a scanner with this study? i tried to disable everything below the "def chg = (if EISave == priceh2 then priceh2 else pricel2) - GetValue(EISave, 1);" and then added the "plot = datachg = chg;". then i went to scan and created a new scan. added the study "MTF_plotchg" then selected greater than value "0". but i get the error "folding: 'from' cannot be greater than 'to': 1>0". i figured this would work, since i am essentially using the "def isUp = chg > 0 and def isDown = chg < 0" outside into the scan. Any suggestions on how i can create a scan?
also what does " if !IsNaN(EI) then EI else GetValue(EISave, 1);" does this mean (!IsNaN(EI)?
 
@taipanaz You cannot scan based on the code above... The issue at hand is the inclusion and complexity of the reference to the ZigZagHighLow indicator. It will throw "Too Complex" errors. There is no workaround.
 
Last edited by a moderator:

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