Hi everyone. I've been playing around with this Heiken Ashi alerting script from mobius. I'm not having any luck getting it to plot on my charts. Am I missing something simple in my chart setup or is it something in the code? Appreciate any help or if it is working on others ToS charts. thanks.
Code:
# Heiken Ashi Pivot "Strategy"
# Mobius
# V01.08.2018
# Entries marked by arrows. Risk would be prior pivot lines or whatever your comfortable with. Target would be breach of next pivot generated. Needs some more work.
def x = barNumber();
def nan = Double.NaN;
def RTH = getTime() >= RegularTradingStart(getYYYYMMDD()) and
getTime() <= RegularTradingEnd(getYYYYMMDD());
def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = Round((CompoundValue(1, HAopen[1] + HAclose[1], open[1] + close)/2) / TickSize(), 0) * TickSize();
HAhigh = Max(high, close[1]);
HAlow = Min(low, close[1]);
haclose = (HAopen + HAhigh + HAlow + HAclose[1]) / 4;
AssignPriceColor(if HAclose > HAopen
then color.green
else color.red);
def up = if HAclose crosses above HAopen
then HAclose + TickSize()
else up[1];
def upX = if HAclose crosses above HAopen
then x
else nan;
plot upLine = if x >= highestAll(upX)
then highestAll(if isNaN(close[-1])
then up
else nan)
else nan;
upLine.SetDefaultColor(Color.Green);
plot upArrow = if close crosses above upLine
then low - TickSize()
else nan;
upArrow.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
upArrow.SetLineWeight(3);
upArrow.SetDefaultColor(Color.Green);
def dn = if HAclose crosses below HAopen
then low - TickSize()
else dn[1];
def dnX = if HAclose crosses below HAopen
then x
else nan;
plot dnLine = if x >= highestAll(dnX)
then highestAll(if isNaN(close[-1])
then dn
else nan)
else nan;
dnLine.SetDefaultColor(Color.Red);
plot dnArrow = if close crosses below dnLine
then high + TickSize()
else nan;
dnArrow.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
dnArrow.SetLineWeight(3);
dnArrow.SetDefaultColor(Color.Red);
# End Code HA Pivot Strategy
addOrder(OrderType.BUY_AUTO, RTH and HAclose crosses above up, up, name = "BTO " + HAopen[-1]);
addOrder(OrderType.Sell_Auto, RTH and HAclose crosses below dn, dn, name = "STO " + HAopen[-1]);
addOrder(OrderType.Sell_To_Close, !RTH and RTH[1], name = "EOD-S");
addOrder(OrderType.Buy_To_Close, !RTH and RTH[1], name = "EOD-B");
# End Code