• LIMITED TIME ONLY: Take $40 off VIP with code: BTD40.

Moving Average (MA) Heiken Ashi Trend Strategy for ThinkorSwim

Lesnewby

Member
Moving Average (MA) Heiken Ashi Trend Strategy for ThinkorSwim

Good morning, hope you are safe and well! Yes if you could share I would try it and give you some feedback!
Here is something that may interest you, it is a Strategy that I use with Expected Moves for SPY, QQQ, and IWM. I trigger a buy order on the second green bar, on the HA (Heiken-Ashi) candle without a tail. The exit is same on the 2nd red bar. I developed this with Pete Hahan, and paid him for the modifications so I can share. I only use the long order side and I only trade options on these signals.
Let me know what you think and how we can improve this!

Leslie (Lesnewby)
Code:
#start
#Software modified by Pete Hahn for #L.J.Jedrychowski

# Leslie Jedrychowski V 7.0 2grn HA bars after a HA red bar.

#---------- Strategy Inputs
input tradeSize = 100;
#---------- Moving Average Inputs
input maLengthOne = 20;
input maTypeOne = AverageType.EXPONENTIAL;
input maPriceOne = close;
input maLengthTwo = 100;
input maTypeTwo = AverageType.EXPONENTIAL;
input maPriceTwo = close;

#---------- Moving Average Section
plot maOne = MovingAverage(maTypeOne, maPriceOne, maLengthOne);
plot maTwo = MovingAverage(maTypeTwo, maPriceTwo, maLengthTwo);

#---------- Heiken-Ashi Candles Section
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def greenCandle = haClose > haOpen;
def redCandle = haClose < haOpen;
def trendUp = greenCandle and greenCandle[1] and !greenCandle[2];
def trendDown = redCandle and redCandle[1] and !redCandle[2];

#---------- Strategy Orders Section
# Long order
AddOrder(OrderType.BUY_TO_OPEN, trendUp[-1], close[-1], tradeSize, Color.CYAN, Color.CYAN, "LE");
AddOrder(OrderType.SELL_TO_CLOSE, trendDown[-1], close[-1], tradeSize, Color.MAGENTA, Color.MAGENTA, "LX");

#Short order
#AddOrder(OrderType.SELL_TO_OPEN, trendDown[-1], close[-1], tradeSize, Color.CYAN, Color.CYAN, "HA 2 Bar SE");
#AddOrder(OrderType.BUY_TO_CLOSE, trendUp[-1], close[-1], tradeSize, Color.MAGENTA, Color.MAGENTA, "HA 2 Bar SX");
#end


LJJ
 
Last edited by a moderator:

JoeSD

Member
VIP
Good morning, hope you are safe and well! Yes if you could share I would try it and give you some feedback!
Here is something that may interest you, it is a Strategy that I use with Expected Moves for SPY, QQQ, and IWM. I trigger a buy order on the second green bar, on the HA (Heiken-Ashi) candle without a tail. The exit is same on the 2nd red bar. I developed this with Pete Hahan, and paid him for the modifications so I can share. I only use the long order side and I only trade options on these signals.
Let me know what you think and how we can improve this!

Leslie (Lesnewby)

#start
#Software modified by Pete Hahn for #L.J.Jedrychowski

# Leslie Jedrychowski V 7.0 2grn HA bars after a HA red bar.

#---------- Strategy Inputs
input tradeSize = 100;
#---------- Moving Average Inputs
input maLengthOne = 20;
input maTypeOne = AverageType.EXPONENTIAL;
input maPriceOne = close;
input maLengthTwo = 100;
input maTypeTwo = AverageType.EXPONENTIAL;
input maPriceTwo = close;

#---------- Moving Average Section
plot maOne = MovingAverage(maTypeOne, maPriceOne, maLengthOne);
plot maTwo = MovingAverage(maTypeTwo, maPriceTwo, maLengthTwo);

#---------- Heiken-Ashi Candles Section
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def greenCandle = haClose > haOpen;
def redCandle = haClose < haOpen;
def trendUp = greenCandle and greenCandle[1] and !greenCandle[2];
def trendDown = redCandle and redCandle[1] and !redCandle[2];

#---------- Strategy Orders Section
# Long order
AddOrder(OrderType.BUY_TO_OPEN, trendUp[-1], close[-1], tradeSize, Color.CYAN, Color.CYAN, "LE");
AddOrder(OrderType.SELL_TO_CLOSE, trendDown[-1], close[-1], tradeSize, Color.MAGENTA, Color.MAGENTA, "LX");

#Short order
#AddOrder(OrderType.SELL_TO_OPEN, trendDown[-1], close[-1], tradeSize, Color.CYAN, Color.CYAN, "HA 2 Bar SE");
#AddOrder(OrderType.BUY_TO_CLOSE, trendUp[-1], close[-1], tradeSize, Color.MAGENTA, Color.MAGENTA, "HA 2 Bar SX");
#end


LJJ
Hi Lensnewby, I tried to load this on my TOS and could not see anything showing the study??? Can you show us what it is supposed to look like??? I tried several different time frames... Thanks.
 

Lesnewby

Member
@JoeSD
This is a strategy so you need to create a new strategy and not a study. No autotrading in ToS, however it does give you an indication of a P and L, so you can get a report on how well the indicators work. On the Heiken-Ashi 2Grn/2Red strategy, I also use volume, MA crossovers and stochastics slow to confirm trades.
Would someone please advise how to post screenshots on this site. Thx
 
Last edited by a moderator:

Similar threads

Top