Turn bottom ZigZag 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:

rad14733

Well-known member
VIP
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
 

germanburrito

Active member
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.
 

taipanaz

New member
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)?
 

rad14733

Well-known member
VIP
@taipanaz You may or may not be able to get a scan to work based on the code above... The issue at hand is the inclusion and complexity of the reference to the ZigZagHighLow indicator, which also contributes to repainting issues... It may throw "Too Complex" errors...
 

Similar threads

Top