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);
Last edited by a moderator: