Heiken Ashi Pivot "Strategy" for ThinkOrSwim

borntostun

New member
Lifetime
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
 
Worked for me on the daily chart. The obvious question is: did you add this as a strategy?

Because I keep making that same mistake :)
 
This^^ Be sure you go to "Create" to post the code while on the strategy tab and not the study tab or it won't show up
 
Is there a reason this does not work on a Daily chart only lower time frames?
can you explain what this strategy is? thanks
The code in the top post is a chopped up version of Mobius's Trend Pivots. Here is a working one:
https://usethinkscript.com/threads/trend-pivot-indicator-by-mobius-for-thinkorswim.1631/

If you are just looking for the HA flip. Here are a dozen flavor of scanners:
https://usethinkscript.com/threads/heiken-ashi-scan.7501/
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
458 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top