Moxie Indicator & Trend Trader Pro Strategies Combined

Hello All, I’m new to this forum (First Post!) and TOS, but not new to investing in stocks. I apologize in advance if some of the images look small as this is my first post. I’ve been watching a few threads over the past few weeks and doing my best to employ the ideas I think would fit into how I like to trade. Mainly the combo of the Moxie indicator & Trend Trader Pro strategies is what I’ve been employing recently with some success. I am fascinated by the technical analysis aspect of trading and believe I’ve found a good way to day-trade/swing-trade using a combo of some of the indicators and scanners from the following two forum threads:

https://usethinkscript.com/threads/completed-heikin_ashi-indicator.5251/

https://usethinkscript.com/threads/moxie-indicator-for-thinkorswim.369/

Thank you, @BonBon & @tradegeek, for starting/contributing to these threads along with the brilliant work/contributions of others like @Slippage @AspaTrader @MerryDay @VictusJogi @J007RMC @RickK @Alb @germanburrito @Homemadeitmyself @Ghs @floydddd @irishgold @rlohmeyer (along with countless others) who made these threads better by refining code, helping with scanners/watchlists, and asking great questions. @BenTen, your indicators also fit the spirit of what I’m trying to accomplish here. I would love for your eyes to take a look at this as well if you think it’s worthy of your time.

I am no coder by any means, and I know there are brilliant people on this forum who can help bring the ideas in my head into fruition, make them better, and hopefully benefit in the process.

I’ll start with an easy example on the chart below of ticker QS. (My Current Workspace Link if you want to see my current chart setup: https://tos.mx/D5H5YNS)

  • We have a normal 1-minute candle chart, no Heikin Ashi or smoothed HA candles because I prefer to view real prices on the chart. On the chart, I have the following moving averages
    • 8 day moving avg exponential
    • 21 day moving avg exponential
    • 50 day moving avg simple
    • 200 day moving avg simple
    • Wedges by @AspaTrader from @BonBon’s thread
    • Support & Resistance lines by @AspaTrader from @BonBon’s thread

  • The 1st indicator is the @Slippage momentum indicator that indicates a positive (Green) or negative (Red) momentum at any given time. When the indicator is above zero, momentum is very positive, and the higher above 0, the better. And conversely, when below 0, that means you need to be careful because momentum isn’t great at the moment.

  • The middle indicator is the @Slippage momentum indicator smoothed and has a slightly different formula, so it doesn’t turn red/green exactly at the same time as the 1st indicator, sometimes turns green/red earlier or later than the other one, and doesn’t repaint which is good.


  • The bottom indicator in this chart is the @BonBon lower multiple time frame indicator which is great for getting an overall picture of where the stock is on longer time frame charts without having to look at 6 charts at a time. It tracks 5min, 15min, 30min, 1hr, 4hr & 1D timeframes with different color dots, green being the best and red being the worst with a color range in between. The top indicator bubble turns green when 5 of 6 time frames are green (in some cases, it’s also black when 5 are green, so not sure what the exact rules are, @BonBon if you can explain exactly how this works, that will be a huge help!), empty when 2 /4 green or red, red when 5 red or more.


In the chart below, you’ll notice that at around 9 am, both @Slippage indicators are green and close to the zero line, @BonBon’s MTF indicators are all green, and we’re hovering around the 200 SMA line. This would be a near-perfect entry. The only thing more perfect would be if the @Slippage indicators were both green and above the 0 line. So, let’s say you entered at the start of this trend at around $59. Theoretically, you would ride this all the way up to around $64-$65, which is when the first @Slippage indicator turns red and to me would signal the beginning of a trend reversal and potentially a great time to take profits and exit. The 2nd @Slippage indicator shortly turns red afterward, confirming that a trend reversal might be near, another opportunity to exit. Luckily for those who still had the nerve to hang in there knowing that the trend, even though red on the @Slippage indicator is still very high above the 0 line, we're able to see both indicators become green again and go back up to $65. Then both indicators turn red again, another signal of a trend reversal/take profit exit opportunity if you’re still in. If you still haven’t sold, then your sell signal would come when both @Slippage lines are red, and the 5-minute @BonBon indicator starts turning light blue then red in this case. At this point, you’d still be out safely with around a $4-5 gain per share in about an hour.

ELw8W37.png


Now let’s look at a RIOT chart and look for a re-entry opportunity after the first sell signal while we’re still in the heavier volume period before 11 am. At around 10:10 am, you’ll notice both slippage indicators start turning green again, and all the @BonBon MTF bubbles are green…Theoretically, you can re-enter under these conditions and again apply the same rules as above to signal trend reversals/take profit exit opportunities. So, in this 2nd sequence, you would get 3 trend reversal/take profit messages before you get the hard sell at around 10:20 ish when the @BonBon MTF 5-minute bubbles change from green to blue/red. Now you’re safely out with both @Slippage indicators in red and slowly heading down below zero. At around 10:45, the @Slippage indicator is below 0, and that’s where you see that series of red arrows. This would be considered a Strong sell no matter what, and as you’ll notice, the price dropped sharply afterward.

2bfUYez.png


I will give more examples later, but I just wanted to give you the gist of what I’m trying to accomplish here and then move onto the nuances which must be accounted for.

Overall Objective: To create labels on the top chart that indicate what actions to take in real-time based on the @BonBon and @Slippage indicators and any additional factors we believe might make these signals more reliable while keeping the chart as clean looking/low-noise as possible.

Buy Types/Levels(Open to adding more if you see more intricate patterns)
  • Cautious Buy/Trend Reversal –When both @Slippage indicators are green and under 0 line, and all @BonBon MTF are not all green, maybe only the 5-minute bubble is green.
FtnXGoF.png

  • Buy – When both @Slippage indicators are green and under 0, and all @BonBon MTF indicators are green. If @Slippage indicators go above the zero line during a trade, a strong buy label appears as further confirmation the trade is good and continuing momentum. (Re-entry – Above 0 line would mean both @Slippage lines are green again and either all of some of the @BobBon MTF bubbles are green again?)
7PJV9ku.png

  • Strong Buy - When both @Slippage indicators are green, and over 0 and then all @BonBon MTF indicators are green.
ftaCYVa.png


Sell Types/Levels(Open to adding more if you see more intricate patterns)
  • Trend Reversal/Take Profit – If over the 0 line on the @Slippage indicator and 1 or 2 of the indicators turns red, all @BonBon indicators still green
29uRY4h.png

  • Sell - If over the 0 line on the @Slippage indicator and both of the indicators turn red, and @BonBon indicator starts turning blue/red on the 5-minute MTF bubbles. It could also be when only the lower MTF bubbles turn blue/red, but @Slippage indicators are still green.
b18zUua.png

  • Strong Sell –If over the 0 line on the @Slippage indicator, and then it touches and/or dips below the 0 line on the @Slippage indicator.
1q2k9JO.png


  • Also, Strong Sell - if any buy signal happens below the 0 line on the @Slippage indicator, and then the slippage indicators turn red again.

EYyzFbj.png


So, as you can see, there are many ways a buy or sell trigger can be generated with these indicators, which I believe is a good thing because you can manage your risk with the varying degrees of buys and sells along with different timeframes. I’m sure there are many more scenarios that could constitute a buy/sell signal, but these are the types of buys and sells I’ve identified as patterns so far. There could also be many more factors put into play by utilizing the moving averages to make better buy/sell decisions (ex. maybe only take trades and give buy signals above the 200-day moving avg etc.?), Fibonacci levels, last high, last low’s and whatever you guys think might help make a better trade in tandem with the two main indicators, all while keeping the chart clean, easy to read and easy to react to. Or maybe incorporate those things into risk levels that will give a signal based on whether the price is above or below these moving averages etc. Everything and anything is fair game so long as it gives you one clean view of the chart and lets you know what kind of trade you could potentially be getting into risk-wise.

Considerations-

Repainting –
I believe that @Slippage indicator with the ladders (not smoothed) repaints, so does the @BonBon MTF indicator, so what could seem like a good trade and holding pattern one second could be a very different scenario if you’re dealing with a stock that has relatively high volume and volatile swings that day.

If anyone here can create @Bonbon’s lower MTF indicator without the repainting (if possible), that would help make for more solid buy/sell entry/exit points and make looking at past data more reliable to determine proper entry/exit points.

A case in point would be this chart below—high relative volume for SGLB on 3/15/2021 due to news catalyst. Buy signal happens at around 2:30 pm, and all is looking steady with a nice bump up in price around 2:43 pm as it crosses the @Slippage 0 line…all is looking good, all green indicators until the price immediately drops by 50 cents 2:54 pm and then turns the top @Slippage indicator red very far back behind till about 2:50 pm as well as turning the @BonBon indicator light blue then red starting at 2:50 pm as well (Repaint)…Smoothed @Slippage indicator stays true to the past few minutes and does not repaint. Because the drop happens almost instantaneously, the indicator gave no signs that this was going to happen…because the stock was so high volume, the only things you could have done to get out of that in time was to A) set a stop/trailing stop, or B) say to yourself that you don’t like two red candles in a row…C) Don’t trade highly volatile stocks with high relative volume after a certain hour in the day. I’ve replayed the moment OnDemand multiple times, and there’s nothing I could have done to avoid that because it happened in less than a second.

M65E3tw.png


Smoothed Candles? – I love the look and simplicity of smoothed candles of the same color to indicate buy/sell trends on the chart. However, the biggest drawbacks for me on @BonBon’s upper chart with the smoothed candles is that the price is based on Heikin Ashi candles which don’t reflect the true current price, and most times seem to offer entries and exits that are too late if you’re only relying on the chart and no other indicators to make your buy/sell decisions (She mentions this as well in her post). If there is a way to make everything look smoothed, whether it is candles or a line while reflecting the true price, I’m all for whatever will make it easier to make the right choice at the right time, whether it’s buying, selling, or continuing to hold your position. As long as we’re always dealing with buy/sell triggers & labels based on actual real-time prices, candle look is not important, only for looks really.

Triggers – Would Buy/Sell labels be confirmed on the next candle but start showing up in the current candle whenever conditions are met? Repainting throws a wrench into this part.

Timeframes – ideally, this would work on any timeframe you wish to trade on, but if that is not possible, maybe go in between 1minute to 1day and intervals for the candles? So that means all indicators, scanners, and watchlists would have to function correctly on all these timeframes.

Scanners & Watchlists – Once a solid strategy is made and backtests successfully, scanners should be made to reflect all buy/sell status variations per time frame. This way, anyone can choose to trade risk levels they are comfortable within the time frames they are comfortable trading in. For example, if you only want to trade buys and strong buys on a 5-minute chart, you’ll only see those stocks that fit that criteria, or if you want to see the range of buy/sell statuses, that would be possible too. You could scan for all stocks or just ones from any segmented watchlist in your TOS. Any other creativity or items to add to the scanner’s reliability, efficacy and simplicity would be amazing to add. Also, maybe scanners for trampoline setups (Moxie) as well per timeframe. @BonBon has a great watchlist for her indicators. Something similar with all of the data points of this idea would be awesome to present all opportunities available during the entire trading day, which is what I envision.

Example scanner for @BonBon lower indicator

0tRW7tG.jpg


Example scanner for @Slippage indicators

29hKuUP.jpg


More examples:

LYFT 3/15/2021 –
  • 12:34 pm: Start watching because the 1st @Slippage indicator turned green
  • 12:39 pm: Trend Reversal/Cautious Buy Signal -The 2nd @Slippage indicator is green but under the 0 line
  • 12:45 pm: Buy Signal – Both @Slippage indicators are green, and all @BonBon MTF bubbles are green and under the 0 @Slippage line.
  • 12:55 pm: Strong Buy Signal – Both @Slippage indicators are green, and all @BonBon MTF bubbles are green and over the 0 @Slippage line.
  • 1:15 pm: Trend Reversal/Take Profit Signal – 1st @Slippage indicator turns red (Not 100% sure if this was a repaint, in that case, the 1st take profit signal was probably at 1:18 pm)
  • 1:18 pm: 2nd Trend Reversal/Take Profit Signal – 2nd @Slippage indicator turns red
  • 1:20-121pm: Sell Signal – Both @Slippage signals are red, and @BonBon 5-minute bubbles turn blue then red.
FyUTeCn.png


QS - 3/16/2021 –
  • On a 5-minute chart, riding out the green would not make sense in this case. This would have been a cautious buy to begin with at around 12:45 pm because it is under the 0 line and MTF dots are not all green at the entry. The key, in this case, would be to get out asap when the 5-minute MTF bubble turned light blue/red. That shows the intricacies that must be accounted for when in different time frames and different scenarios. Maybe because we are in the 5-minute time frame, you need to always listen to the 5-minute TMF bubbles over the green trend lines? Maybe that is the case for whatever time frame you are trading in?
FmH4PVK.png


In conclusion, I hope I have demonstrated the framework of a winning system. I’m sure I’m probably missing a few nuts and bolts here and there, but the framework is solid, in my view. I believe that the combination of on-chart buy/sell signals/labels and the right scanners/watchlists to find the right opportunities during the trading day can prove to be a profitable system that will leave little to the user besides deciding how much risk they can handle per trade. I would be eternally grateful for your collaboration in making a good system great and easier to implement.

If you have any questions I'll do my best to help elaborate wherever I can...

Appreciate your brains and talent. I hope this leads to something we can all be proud of and use. Cheers!
 
Last edited:

BonBon

Active member
VIP
@[email protected] great work. Just to clarify one of your statements. The Heikin_Ashi smoothed signals don't repaint. There are 3 different signals that I placed in the thread....the signal script that is derived from the zigzag indicator as well as the the swing/low signal are the ones that repaint . The heikin-ashi smoothed signal. If you are using the modified zigzag signal and the modified swing/low your signals will repaint. The MFT does not repaint as it is based on the heikin_ashi smoothed. script. Which script are you using? Ensure you are using the heikin_ashi smoothed signal script if you don't want your signals to repaint. I use part of the zigzag script(I modified it based on my trading plan. I do not use the zigzag section of the script)

I only enter the trade when the Heikin_ashi signal appears after the modified zigzag reversal script as backtesting/strategies showed a 100% profit.

Hope this helps.
 
@[email protected] great work. Just to clarify one of your statements. The Heikin_Ashi smoothed signals don't repaint. There are 3 different signals that I placed in the thread....the signal script that is derived from the zigzag indicator as well as the the swing/low signal are the ones that repaint . The heikin-ashi smoothed signal. If you are using the modified zigzag signal and the modified swing/low your signals will repaint. The MFT does not repaint as it is based on the heikin_ashi smoothed. script. Which script are you using? Ensure you are using the heikin_ashi smoothed signal script if you don't want your signals to repaint. I use part of the zigzag script(I modified it based on my trading plan. I do not use the zigzag section of the script)

I only enter the trade when the Heikin_ashi signal appears after the modified zigzag reversal script as backtesting/strategies showed a 100% profit.

Hope this helps.

Hi @BonBon and thanks for responding! The code I used for the lower MTF indicator is below. At the moment I'm not using the chart indicators from your thread. I admit that I'm a total newbie when it comes to coding and the jargon that comes with it. There were many updates to your original code throughout the thread but as a code newbie, I got lost trying to figure out where in the original code to make the updates you suggested.

Below is the most complete version of the lower code I was able to find in that thread. I believe the version below does repaint because throughout the day I see dots on the 1-minute chart that were green a few minutes ago, turn blue/red when price takes a sharp turn lower, even after those minutes are over and in the past. If you can let me know what I need to change in the code below in order to get this MTF indicator not to repaint, that will be a huge chunk of making the vision above a reality!

I will also continue to read your post when I have time after work to figure out your complete upper and lower code because what brought me to your post initially was my interest in the complete trend trader pro strategy that included the smoothed heiken-ashi upper chart with the buy/sell labels combined with the lower MTF indicator. I think what you did was brilliant and would love to learn how to execute it just like you as well as combining the moxie strategy as well.

I look forward to your response!

Code:
#BonBon - Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update 2/1/2021, Jan 17th 2021,
#Influenced by script from HoboTheClown / blt,[URL]http://www.thinkscripter.com[/URL], TD Hacolt etc., Thinkscript Cloud, TOS & Thinkscript Collection
#update 1/2/21 - changed the default moving average to TEMA.  Changed the period to 35.
#update changed reversal arrows to reversal bubbles with price
#PLEASE DO NOT REMOVE THE HASHTAGS!!!! ONLY REMOVE THEM IF YOU PLAN ON USING THAT PARTICULAR SIGNAL. THERE ARE 3 DIFFERENT SIGNALS IN THE SCRIPT!!!!! IF YOU REMOVE ALL THE HASHTAGS YOU WILL HAVE NUMEROUS SIGNALS ON YOUR CHART!!!!!!!!!


declare lower;

input UsePeriod5 = AggregationPeriod.FIVE_MIN;
input UsePeriod15 = AggregationPeriod.FIFTEEN_MIN;
input UsePeriod30 = AggregationPeriod.thirty_MIN;
input UsePeriod60 = AggregationPeriod. HOUR;
input UsePeriod4hr = AggregationPeriod. FOUR_HOURS;
input UsePeriodday = AggregationPeriod.DAY;

input  Con_Cri = 3;

input Main_Heikin_Plot = Yes;


#Timeframe1 5 min

def aOpen5 = open(period = UsePeriod5);
def aClose5 = close(period = UsePeriod5);
def aHigh5 = high(period = UsePeriod5);
def aLow5 = low(period = UsePeriod5);

def haClose5 = (aOpen5 + aClose5 + aHigh5 + aLow5) / 4;
def haOpen5 = (haOpen5[1] + haClose5[1]) / 2;

def trend5 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
plot HA_Up5 = if IsNaN(UsePeriod5) then Double.NaN else 6;
HA_Up5.SetPaintingStrategy(PaintingStrategy.POINTS);#SetStyle(curve.Points);
HA_Up5.AssignValueColor(if haClose5 >= haOpen5 then Color.GREEN else if haClose5[1] < haOpen5[1] then Color.RED else Color.CURRENT);
HA_Up5.SetLineWeight(4);
############################################

#Timeframe2 15 mins

def aOpen15 = open(period = UsePeriod15);
def aClose15 = close(period = UsePeriod15);
def aHigh15 = high(period = UsePeriod15);
def aLow15 = low(period = UsePeriod15);

def haClose15 = (aOpen15 + aClose15 + aHigh15 + aLow15) / 4;
def haOpen15 = (haOpen15[1] + haClose15[1]) / 2;


def trend15 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
plot HA_Up15 = if IsNaN(UsePeriod15) then Double.NaN else 5;
#plot HA_Up15 = if haClose15 >= haOpen15 then 1 else 0;
HA_Up15.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up15.AssignValueColor(if haClose15 >= haOpen15 then Color.GREEN else if haClose15 [1]< haOpen15[1] then Color.RED else Color.CURRENT);
HA_Up15.SetLineWeight(4);
#######################################

#Timeframe3  30 mins

def aOpen30 = open(period = UsePeriod30);
def aClose30 = close(period = UsePeriod30);
def aHigh30 = high(period = UsePeriod30);
def aLow30 = low(period = UsePeriod30);

def haClose30 = (aOpen30 + aClose30 + aHigh30 + aLow30) / 4;
def haOpen30 = (haOpen30[1] + haClose30[1]) / 2;


def trend30 = if haClose30 >= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
plot HA_Up30 = if IsNaN(UsePeriod30) then Double.NaN else 4;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up30.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up30.AssignValueColor(if haClose30 >= haOpen30 then Color.GREEN else if haClose30[1] < haOpen30[1] then Color.RED else Color.CURRENT);
HA_Up30.SetLineWeight(4);

################################
#Timeframe4  60mins

def aOpen60 = open(period = UsePeriod60);
def aClose60 = close(period = UsePeriod60);
def aHigh60 = high(period = UsePeriod60);
def aLow60 = low(period = UsePeriod60);

def haClose60 = (aOpen60 + aClose60 + aHigh60 + aLow60) / 4;
def haOpen60 = (haOpen60[1] + haClose60[1]) / 2;

def trend60 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
plot HA_Up60 = if IsNaN(UsePeriod60) then Double.NaN else 3;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up60.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up60.AssignValueColor(if haClose60 >= haOpen60 then Color.GREEN else if haClose60[1] < haOpen60[1] then Color.RED else Color.CURRENT);
HA_Up60.SetLineWeight(4);

##################################
#Timeframe5 4hrs

def aOpen4hr = open(period = UsePeriod4hr);
def aClose4hr = close(period = UsePeriod4hr);
def aHigh4hr = high(period = UsePeriod4hr);
def aLow4hr = low(period = UsePeriod4hr);

def haClose4hr = (aOpen4hr + aClose4hr + aHigh4hr + aLow4hr) / 4;
def haOpen4hr = (haOpen4hr[1] + haClose4hr[1]) / 2;

def trend4hr = if haClose4hr >= haOpen4hr then 1 else if haClose4hr < haOpen4hr then -1 else 0;
plot HA_Up4hr = if IsNaN(UsePeriod4hr) then Double.NaN else 2;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up4hr.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up4hr.AssignValueColor(if haClose4hr >= haOpen4hr then Color.GREEN else if haClose4hr[1] < haOpen4hr[1] then Color.RED else Color.CURRENT);
HA_Up4hr.SetLineWeight(4);
#######################################

#Timeframe6 Day

def aOpenday = open(period = UsePeriodday);
def aCloseday = close(period = UsePeriodday);
def aHighday = high(period = UsePeriodday);
def aLowday = low(period = UsePeriodday);

def haCloseday = (aOpenday + aCloseday + aHighday + aLowday) / 4;
def haOpenday = (haOpenday[1] + haCloseday[1]) / 2;

def trendday = if haCloseday >= haOpenday then 1 else if haCloseday [1] < haOpenday[1] then -1 else 0;
plot HA_Upday = if IsNaN(UsePeriodday) then Double.NaN else 1;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Upday.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Upday.AssignValueColor(if haCloseday >= haOpenday then Color.GREEN else if haCloseday[1] < haOpenday[1] then Color.RED else Color.CURRENT);
HA_Upday.SetLineWeight(4);

####################################
#def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
#def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
#def Trend3 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
#def Trend4 = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
#def Trend5_ = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
#def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
#def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
#def Trend3c = if haClose60 < haOpen60  then 1 else if haClose60[1]>= haOpen60[1] then -1 else 0;
#def Trend4d = if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
#def Trend5e = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#Up Trend
def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
def Trend3 = if haClose30>= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
def Trend4 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
def Trend5_ = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
def Trend6 = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
def Trend3c = if haClose30 < haOpen30 then 1 else if haClose30[1] >= haOpen30[1] then -1 else 0;
def Trend4d = if haClose60 < haOpen60  then 1 else if haClose60[1] >= haOpen60[1] then -1 else 0;
def Trend5e= if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
def Trend6f = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#plot MTF_TREND = 6;
#MTF_TREND.SetPaintingStrategy(PaintingStrategy.Points);
#MTF_TREND.SetLineWeight(lineWeight = 3);
#MTF_TREND.DefineColor("Buy", GetColor(5));
#MTF_TREND.DefineColor("Sell", GetColor(6));
#MTF_TREND.AssignValueColor(if (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 then Color.GREEN else Color.RED);

#MTF_TREND.AssignValueColor(if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 #then Color.GREEN else if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) < 3 then #Color. RED else Color.CURRENT);

def HA_MTF_TrendUP = (Trend1 + Trend2 + Trend3 + Trend4) >=  Con_Cri ;
def HA_MTF_TrendDN = (Trend1a + Trend2b + Trend3c + Trend4d) >=  Con_Cri;

plot Main_Heikin = 7;
Main_Heikin.SetPaintingStrategy(PaintingStrategy.POINTS);
Main_Heikin.AssignValueColor(if HA_MTF_TrendUP == 1 then Color.Green else if HA_MTF_TrendDN == 1 then color.red else Color.Black);
Main_Heikin.SetLineWeight(4);

#End code
#######################################################
 

BonBon

Active member
VIP
Hi @BonBon and thanks for responding! The code I used for the lower MTF indicator is below. At the moment I'm not using the chart indicators from your thread. I admit that I'm a total newbie when it comes to coding and the jargon that comes with it. There were many updates to your original code throughout the thread but as a code newbie, I got lost trying to figure out where in the original code to make the updates you suggested.

Below is the most complete version of the lower code I was able to find in that thread. I believe the version below does repaint because throughout the day I see dots on the 1-minute chart that were green a few minutes ago, turn blue/red when price takes a sharp turn lower, even after those minutes are over and in the past. If you can let me know what I need to change in the code below in order to get this MTF indicator not to repaint, that will be a huge chunk of making the vision above a reality!

I will also continue to read your post when I have time after work to figure out your complete upper and lower code because what brought me to your post initially was my interest in the complete trend trader pro strategy that included the smoothed heiken-ashi upper chart with the buy/sell labels combined with the lower MTF indicator. I think what you did was brilliant and would love to learn how to execute it just like you as well as combining the moxie strategy as well.

I look forward to your response!

Code:
#BonBon - Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update 2/1/2021, Jan 17th 2021,
#Influenced by script from HoboTheClown / blt,[URL]http://www.thinkscripter.com[/URL], TD Hacolt etc., Thinkscript Cloud, TOS & Thinkscript Collection
#update 1/2/21 - changed the default moving average to TEMA.  Changed the period to 35.
#update changed reversal arrows to reversal bubbles with price
#PLEASE DO NOT REMOVE THE HASHTAGS!!!! ONLY REMOVE THEM IF YOU PLAN ON USING THAT PARTICULAR SIGNAL. THERE ARE 3 DIFFERENT SIGNALS IN THE SCRIPT!!!!! IF YOU REMOVE ALL THE HASHTAGS YOU WILL HAVE NUMEROUS SIGNALS ON YOUR CHART!!!!!!!!!


declare lower;

input UsePeriod5 = AggregationPeriod.FIVE_MIN;
input UsePeriod15 = AggregationPeriod.FIFTEEN_MIN;
input UsePeriod30 = AggregationPeriod.thirty_MIN;
input UsePeriod60 = AggregationPeriod. HOUR;
input UsePeriod4hr = AggregationPeriod. FOUR_HOURS;
input UsePeriodday = AggregationPeriod.DAY;

input  Con_Cri = 3;

input Main_Heikin_Plot = Yes;


#Timeframe1 5 min

def aOpen5 = open(period = UsePeriod5);
def aClose5 = close(period = UsePeriod5);
def aHigh5 = high(period = UsePeriod5);
def aLow5 = low(period = UsePeriod5);

def haClose5 = (aOpen5 + aClose5 + aHigh5 + aLow5) / 4;
def haOpen5 = (haOpen5[1] + haClose5[1]) / 2;

def trend5 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
plot HA_Up5 = if IsNaN(UsePeriod5) then Double.NaN else 6;
HA_Up5.SetPaintingStrategy(PaintingStrategy.POINTS);#SetStyle(curve.Points);
HA_Up5.AssignValueColor(if haClose5 >= haOpen5 then Color.GREEN else if haClose5[1] < haOpen5[1] then Color.RED else Color.CURRENT);
HA_Up5.SetLineWeight(4);
############################################

#Timeframe2 15 mins

def aOpen15 = open(period = UsePeriod15);
def aClose15 = close(period = UsePeriod15);
def aHigh15 = high(period = UsePeriod15);
def aLow15 = low(period = UsePeriod15);

def haClose15 = (aOpen15 + aClose15 + aHigh15 + aLow15) / 4;
def haOpen15 = (haOpen15[1] + haClose15[1]) / 2;


def trend15 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
plot HA_Up15 = if IsNaN(UsePeriod15) then Double.NaN else 5;
#plot HA_Up15 = if haClose15 >= haOpen15 then 1 else 0;
HA_Up15.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up15.AssignValueColor(if haClose15 >= haOpen15 then Color.GREEN else if haClose15 [1]< haOpen15[1] then Color.RED else Color.CURRENT);
HA_Up15.SetLineWeight(4);
#######################################

#Timeframe3  30 mins

def aOpen30 = open(period = UsePeriod30);
def aClose30 = close(period = UsePeriod30);
def aHigh30 = high(period = UsePeriod30);
def aLow30 = low(period = UsePeriod30);

def haClose30 = (aOpen30 + aClose30 + aHigh30 + aLow30) / 4;
def haOpen30 = (haOpen30[1] + haClose30[1]) / 2;


def trend30 = if haClose30 >= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
plot HA_Up30 = if IsNaN(UsePeriod30) then Double.NaN else 4;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up30.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up30.AssignValueColor(if haClose30 >= haOpen30 then Color.GREEN else if haClose30[1] < haOpen30[1] then Color.RED else Color.CURRENT);
HA_Up30.SetLineWeight(4);

################################
#Timeframe4  60mins

def aOpen60 = open(period = UsePeriod60);
def aClose60 = close(period = UsePeriod60);
def aHigh60 = high(period = UsePeriod60);
def aLow60 = low(period = UsePeriod60);

def haClose60 = (aOpen60 + aClose60 + aHigh60 + aLow60) / 4;
def haOpen60 = (haOpen60[1] + haClose60[1]) / 2;

def trend60 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
plot HA_Up60 = if IsNaN(UsePeriod60) then Double.NaN else 3;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up60.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up60.AssignValueColor(if haClose60 >= haOpen60 then Color.GREEN else if haClose60[1] < haOpen60[1] then Color.RED else Color.CURRENT);
HA_Up60.SetLineWeight(4);

##################################
#Timeframe5 4hrs

def aOpen4hr = open(period = UsePeriod4hr);
def aClose4hr = close(period = UsePeriod4hr);
def aHigh4hr = high(period = UsePeriod4hr);
def aLow4hr = low(period = UsePeriod4hr);

def haClose4hr = (aOpen4hr + aClose4hr + aHigh4hr + aLow4hr) / 4;
def haOpen4hr = (haOpen4hr[1] + haClose4hr[1]) / 2;

def trend4hr = if haClose4hr >= haOpen4hr then 1 else if haClose4hr < haOpen4hr then -1 else 0;
plot HA_Up4hr = if IsNaN(UsePeriod4hr) then Double.NaN else 2;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up4hr.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up4hr.AssignValueColor(if haClose4hr >= haOpen4hr then Color.GREEN else if haClose4hr[1] < haOpen4hr[1] then Color.RED else Color.CURRENT);
HA_Up4hr.SetLineWeight(4);
#######################################

#Timeframe6 Day

def aOpenday = open(period = UsePeriodday);
def aCloseday = close(period = UsePeriodday);
def aHighday = high(period = UsePeriodday);
def aLowday = low(period = UsePeriodday);

def haCloseday = (aOpenday + aCloseday + aHighday + aLowday) / 4;
def haOpenday = (haOpenday[1] + haCloseday[1]) / 2;

def trendday = if haCloseday >= haOpenday then 1 else if haCloseday [1] < haOpenday[1] then -1 else 0;
plot HA_Upday = if IsNaN(UsePeriodday) then Double.NaN else 1;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Upday.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Upday.AssignValueColor(if haCloseday >= haOpenday then Color.GREEN else if haCloseday[1] < haOpenday[1] then Color.RED else Color.CURRENT);
HA_Upday.SetLineWeight(4);

####################################
#def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
#def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
#def Trend3 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
#def Trend4 = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
#def Trend5_ = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
#def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
#def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
#def Trend3c = if haClose60 < haOpen60  then 1 else if haClose60[1]>= haOpen60[1] then -1 else 0;
#def Trend4d = if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
#def Trend5e = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#Up Trend
def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
def Trend3 = if haClose30>= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
def Trend4 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
def Trend5_ = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
def Trend6 = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
def Trend3c = if haClose30 < haOpen30 then 1 else if haClose30[1] >= haOpen30[1] then -1 else 0;
def Trend4d = if haClose60 < haOpen60  then 1 else if haClose60[1] >= haOpen60[1] then -1 else 0;
def Trend5e= if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
def Trend6f = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#plot MTF_TREND = 6;
#MTF_TREND.SetPaintingStrategy(PaintingStrategy.Points);
#MTF_TREND.SetLineWeight(lineWeight = 3);
#MTF_TREND.DefineColor("Buy", GetColor(5));
#MTF_TREND.DefineColor("Sell", GetColor(6));
#MTF_TREND.AssignValueColor(if (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 then Color.GREEN else Color.RED);

#MTF_TREND.AssignValueColor(if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 #then Color.GREEN else if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) < 3 then #Color. RED else Color.CURRENT);

def HA_MTF_TrendUP = (Trend1 + Trend2 + Trend3 + Trend4) >=  Con_Cri ;
def HA_MTF_TrendDN = (Trend1a + Trend2b + Trend3c + Trend4d) >=  Con_Cri;

plot Main_Heikin = 7;
Main_Heikin.SetPaintingStrategy(PaintingStrategy.POINTS);
Main_Heikin.AssignValueColor(if HA_MTF_TrendUP == 1 then Color.Green else if HA_MTF_TrendDN == 1 then color.red else Color.Black);
Main_Heikin.SetLineWeight(4);

#End code
#######################################################
@[email protected] please see thread #163 and #164 where I explain why you are seeing the different colors within the MTF. It is not repainting but rather is based on timeframes.
 
@[email protected] please see thread #163 and #164 where I explain why you are seeing the different colors within the MTF. It is not repainting but rather is based on timeframes.
@BonBon Thank You and absolutely, I know that each line of the MTF represents a different time frame. For example, if I'm looking at a 1-minute timeframe and I'm looking at the 5-minute line of bubbles on the MTF indicator (2nd Line), let's say they've already turned blue then red....but then if the price gaps up a few minutes later, the red and blue dots from the 5-minute bubble line will all change back to green again as if they were never blue or red.

So when looking back, it looks like they were always green, and thus it looks like a perfect trade that you could just hold onto....but in reality, it did turn blue/red at some point which would be a trigger to sell because the price is going down at that point.

What I'm trying to accomplish if possible is to make sure that if those bubbles were once blue/red, that they always stay blue/red after that candle has closed (in whichever timeframe you're looking at), this way you can look back and see what the MTF indicator said at any point in time in the past and learn from it!

Anyhow, I'm going back to your post and reading it again from the beginning to see where you learned from and how to get to the final version of your script where you mentioned it's backtesting at 100% profit...thank you for making the wheels in my mind spin!
 

Slippage

Active member
@MerryDay appreciate it, will take a look at that now, thanks!!
The higher timeframe data causing repainting on the lower timeframe is the same reason the stair-stepped (clone of the official version) Moxie repaints. The signal may change up until the higher timeframe period closes. I created the "smooth" version to work around that. As you've seen it's an approximation and the signals are similar but different.

Creating a single label instructing what action to take for the combined signals is possible but would require merging all of these scripts into a single script and resolving any code conflicts between them (mostly duplicated names for variables, if any). They'd also have to be merged to do any scripted back-testing. It's not a huge effort but potentially a pain to maintain if if you want it updated as the individual pieces change, if they aren't already final. I'll be posting a change in the next week or so for Moxie trampoline setup indication but aside from that I don't expect to make other changes. Another option would be to have one label from each script. Instead of something like "Early buy" you'd get "Buy" "Buy" "Sell" "Buy" "Buy" which with color coding can still be quick to read but takes up more space and doesn't seem as cool.

For the Moxie scripts since you're not using the squeeze functionality and the trampolines it'd be ideal to strip that stuff out. Also, because the stair-stepped Moxie repaints, it might be advantageous to test alternate signals from the smooth version. For instance, 2 or 3 consecutive red periods on the smooth version instead of a signal from the stair-stepped version.

That hideous Moxie watchlist is a screenshot of the crap provided when you buy Moxie and isn't even used by its creator. We'd need to come up with something custom. And less ugly.

I might have some time to get back into code next week. I've got a couple of things in line before this but I might be able to contribute to this next week.
 
The higher timeframe data causing repainting on the lower timeframe is the same reason the stair-stepped (clone of the official version) Moxie repaints. The signal may change up until the higher timeframe period closes. I created the "smooth" version to work around that. As you've seen it's an approximation and the signals are similar but different.

Creating a single label instructing what action to take for the combined signals is possible but would require merging all of these scripts into a single script and resolving any code conflicts between them (mostly duplicated names for variables, if any). They'd also have to be merged to do any scripted back-testing. It's not a huge effort but potentially a pain to maintain if if you want it updated as the individual pieces change, if they aren't already final. I'll be posting a change in the next week or so for Moxie trampoline setup indication but aside from that I don't expect to make other changes. Another option would be to have one label from each script. Instead of something like "Early buy" you'd get "Buy" "Buy" "Sell" "Buy" "Buy" which with color coding can still be quick to read but takes up more space and doesn't seem as cool.

For the Moxie scripts since you're not using the squeeze functionality and the trampolines it'd be ideal to strip that stuff out. Also, because the stair-stepped Moxie repaints, it might be advantageous to test alternate signals from the smooth version. For instance, 2 or 3 consecutive red periods on the smooth version instead of a signal from the stair-stepped version.

That hideous Moxie watchlist is a screenshot of the crap provided when you buy Moxie and isn't even used by its creator. We'd need to come up with something custom. And less ugly.

I might have some time to get back into code next week. I've got a couple of things in line before this but I might be able to contribute to this next week.
@Slippage thanks for taking a look at the post, you bring up some great points to take into consideration when refining this strategy, I'm also studying the crap out of @BonBon 's post and I'm thinking about incorporating her ORB (Opening Range Breakout) strategy as well as part of this whole deal...Combined with her scanner for relative volume %, I'm seeing many winners on a daily basis after the ORB buy price is met/exceeded. Going to post more about that once I get my thoughts together on that and study her post a bit more.

Still following your thread as well for any updates...looking forward to your post on the trampoline setup and seeing if there's a way to incorporate that along with the squeeze functionality in this strategy if possible.

As for the smoother Moxie you made, I'm generally put more weight into that one because it doesn't repaint and that's most often the one that goes red first in real-time...because I'm a more conservative type I generally out of a trade once I start seeing that and the candle close with it in red...so in my strategy I'm the "take profit" guy!

I'm going to think up some more ways to scan for all of this stuff as well in order to find those optimal trades throughout the day...The ORB strategy with the high RV% strategy looks very juicy, just have to keep studying it more before I'm confident enough to risk real money on it.

If anybody else is reading this and has a shiny light bulb over your head, feel free to chime in!
 
Last edited:

Similar threads

Top