• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Heiken Ashi Pivot "Strategy" - mobius - help question.


New member
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.

# 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;
plot upArrow = if close crosses above upLine
               then low - TickSize()
               else nan;
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;
plot dnArrow = if close crosses below dnLine
               then high + TickSize()
               else nan;
# 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

Similar threads