#Converted MT4 HeikinAshi_EntryExit Indicator
#MikeLikesAnacottSteel
#8-27-2022
#MT4 indicator source: https://forex-station.com/app.php/attach/file/3349947
input MaMethod1 = AverageType.EXPONENTIAL;
input MaPeriod = 40;
input MaMethod2 = AverageType.EXPONENTIAL;
input MaPeriod2 = 1;
def maOpen = MovingAverage(MaMethod1, open, MaPeriod);
def maClose = MovingAverage(MaMethod1, close, MaPeriod);
def maLow = MovingAverage(MaMethod1, low, MaPeriod);
def maHigh = MovingAverage(MaMethod1, high, MaPeriod);
def haClose = (maOpen + maHigh + maLow + maClose) / 4;
def haOpen = (GetValue(haOpen, 1) + GetValue(haClose, 1)) / 2;
def haHigh = Max(maHigh, Max(haOpen, haClose));
def haLow = Min(maLow, Min(haOpen, haClose));
def ExtMapBuffer7;
def ExtMapBuffer8;
if (haOpen < haClose)
{
ExtMapBuffer7 = haLow;
ExtMapBuffer8 = haHigh;
}
else
{
ExtMapBuffer7 = haHigh;
ExtMapBuffer8 = haLow;
}
def ExtMapBuffer5 = haOpen;
def ExtMapBuffer6 = haClose;
plot ExtMapBuffer1 = MovingAverage(MaMethod2, ExtMapBuffer7, MaPeriod2);
plot ExtMapBuffer2 = MovingAverage(MaMethod2, ExtMapBuffer8, MaPeriod2);
plot ExtMapBuffer3 = MovingAverage(MaMethod2, ExtMapBuffer5, MaPeriod2);
plot ExtMapBuffer4 = MovingAverage(MaMethod2, ExtMapBuffer6, MaPeriod2);
ExtMapBuffer1.SetDefaultColor(Color.RED);
ExtMapBuffer1.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer1.SetLineWeight(1);
ExtMapBuffer2.SetDefaultColor(Color.BLUE);
ExtMapBuffer2.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer2.SetLineWeight(1);
ExtMapBuffer3.SetDefaultColor(Color.RED);
ExtMapBuffer3.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer3.SetLineWeight(1);
ExtMapBuffer4.SetDefaultColor(Color.BLUE);
ExtMapBuffer4.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer4.SetLineWeight(1);
AddCloud(ExtMapBuffer1, ExtMapBuffer2, CreateColor(255, 0, 102), CreateColor(0, 102, 255));
AddCloud(ExtMapBuffer1, ExtMapBuffer4, CreateColor(255, 0, 102), CreateColor(0, 102, 255));
AddCloud(ExtMapBuffer2, ExtMapBuffer1, CreateColor(0, 102, 255), CreateColor(255, 0, 102));
AddCloud(ExtMapBuffer2, ExtMapBuffer3, CreateColor(0, 102, 255), CreateColor(255, 0, 102));
AddCloud(ExtMapBuffer3, ExtMapBuffer4, CreateColor(255, 0, 102), CreateColor(0, 102, 255));
def cond1 = ExtMapBuffer1 crosses ExtMapBuffer2;
def xdate = if cond1 then GetYYYYMMDD() else Double.NaN;
input timezone = {default "ET", "CT", "MT", "PT"};
def starthour = (if timezone == timezone."ET"
then 9
else if timezone == timezone."CT"
then 8
else if timezone == timezone."MT"
then 7
else 6) ;
def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;
AddVerticalLine(cond1, "PUTS " + AsPrice(xdate) + " " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, Color.RED, Curve.FIRM);