I came across this macd study and I rather like it
Code:
plot Data = close;# MACD by the math
# Mobius
# Mobius at MyTrade
declare lower;
input agg1 = AggregationPeriod.Day;
input agg2 = AggregationPeriod.Hour;
Input fastEMA = 13;
Input slowEMA = 21;
Input Smooth = 8;
def value = close;
def value2 = close(period = agg1);
def value3 = close(period = agg2);
def FSignal = (value * .15) + (.85 * ExpAverage(value, fastEMA)[1]);
def SSignal = (value * .075) + (.925 * ExpAverage(value, slowEMA)[1]);
plot MACD = FSignal - SSignal;
plot MACDSL = ExpAverage(MACD, Smooth);
plot zero = 0;
MACD.SetpaintingStrategy(PaintingStrategy.Line);
MACD.SetLineWeight(2);
MACD.AssignValueColor(if MACD > MACD[1] and MACD[1] > MACD[2]
then Color.Green else Color.Red);
MACDSL.AssignValueColor(if MACDSL > MACDSL[1] and MACDSL[1] > MACDSL[2]
then Color.Blue else Color.Yellow);
def FSignal2 = (value2 * .15) + (.85 * ExpAverage(value2, fastEMA)[1]);
def SSignal2 = (value2 * .075) + (.925 * ExpAverage(value2, slowEMA)[1]);
plot MACD2 = FSignal2 - SSignal2;
plot MACDSL2 = ExpAverage(MACD2, Smooth);
MACD2.SetpaintingStrategy(PaintingStrategy.Line);
MACD2.SetLineWeight(2);
MACD2.AssignValueColor(if MACD2 > MACD2[1] and MACD2[1] > MACD2[2]
then Color.White else Color.Plum);
MACDSL2.AssignValueColor(if MACDSL2 > MACDSL2[1] and MACDSL2[1] > MACDSL2[2]
then Color.Orange else Color.Dark_Orange);
def FSignal3 = (value3 * .15) + (.85 * ExpAverage(value3, fastEMA)[1]);
def SSignal3 = (value3 * .075) + (.925 * ExpAverage(value3, slowEMA)[1]);
plot MACD3 = FSignal3 - SSignal3;
plot MACDSL3 = ExpAverage(MACD3, Smooth);
MACD3.SetpaintingStrategy(PaintingStrategy.Line);
MACD3.SetLineWeight(2);
MACD3.AssignValueColor(if MACD3 > MACD3[1] and MACD3[1] > MACD3[2]
then Color.Gray else Color.Cyan);
MACDSL3.AssignValueColor(if MACDSL3 > MACDSL3[1] and MACDSL3[1] > MACDSL3[2]
then Color.Magenta else Color.Pink);
# End Code
Last edited by a moderator: