Heiken-Ashi Based on MACD Indicator for ThinkorSwim

W

WaveRiderJ

New member
Here is a study that I call the HAMACD. It is the moving average of the Heiken Ashi candle difference.

Rich (BB code):
#HAMACD
#
declare lower;  

def haclose = (open + high + low + close) / 4; 
def haopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close[1]) / 2); 
def diff = (haclose - haopen)*100; 
def HADiff = diff; 

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;

plot Value = MovingAverage(averageType, diff, fastLength) - MovingAverage(averageType, diff, slowLength);
plot Avg2 = MovingAverage(averageType, Value, MACDLength);

plot Diff2 = Value - Avg2;
plot ZeroLine = 0;

plot UpSignal = if value crosses above avg2 then avg2 else Double.NaN;
plot DownSignal = if  value crosses below avg2 then avg2 else Double.NaN;
plot UpEND = if Diff2 > 0 && diff2 < diff2[1] && diff2[1] > diff2[2] then Diff2 else double.nan;
plot DnEND = if Diff2 < 0 && diff2 > diff2[1] && diff2[1] < diff2[2] then Diff2 else double.nan;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

Value.SetDefaultColor(GetColor(1));
Avg2.SetDefaultColor(GetColor(8));
Diff2.SetDefaultColor(GetColor(5));
Diff2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff2.SetLineWeight(3);
Diff2.DefineColor("Positive and Up", Color.GREEN);
Diff2.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff2.DefineColor("Negative and Down", Color.RED);
Diff2.DefineColor("Negative and Up", Color.DARK_RED);
Diff2.AssignValueColor(
           if Diff2 >= 0 then if Diff2 > Diff2[1] then Diff2.color("Positive and Up")      
           else Diff2.color("Positive and Down")         
           else if Diff2 < Diff2[1] then Diff2.color("Negative and Down") 
           else Diff2.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.green);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upsignal.SetLineWeight(5);
DownSignal.SetDefaultColor(Color.red);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
downsignal.SetLineWeight(5);
DnEND.SetDefaultColor(Color.UPTICK);
DnEND.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DnEND.SetLineWeight(1);
UpEND.SetDefaultColor(Color.DOWNTICK);
UpEND.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpEND.SetLineWeight(1);
#
 
Last edited by a moderator:
markos

markos

Active member
VIP
@WaveRiderJ Very Interesting. How do use the diff in HA values to trade?
What time frame do you trade with this one?
Could you post a picture?
 
Thread starter Similar threads Forum Replies Date
C Questions 2
T Strategies 3

Top