Completed Heikin_Ashi Indicator

BonBon

Member
VIP
Thanks to everyone for their work as I would not have gotten this far without your contribution. I have referenced members of the community as you have either commented or contributed to the HA forums/discussions.

After conducting research on indicators/studies that would aid in my entry and exits as well as keeping me in the trend longer than usual, I came upon Sylvan Vervoort and his work. ( I have previously used the TrendPainter, Supertrend etc.) After reading “Trading with the Heikin-Ashi Candlestick Oscillator" and “Trading Medium-Term Divergences” I began searching the site for script that emulates his work.

@BenTen, @zkm, @mc01439, @HighBredCloud, @JBTrades, @markos, @tomsk @horserider @YungTraderFromMontana @diazlaz @J007RMC

Key components
TEMA, Reversal bubbles and/or arrows, MTF indicator, Addchart script used to create the HA , does not repaint.

Strategy – long and/or short. Enter and/or exit based on reversals (however, I utilize other indicators and signals such as the RSI, MTF, increased volume, stocks with strong catalyst, RV above 2.0 and Fib retracement.

Scan
The scan comprises of the MTF script along with the script for liquidity, relative volume and/or stocks that are near (2-5%) to their 52wk high and short interest. I scan for stocks that are low float.

Watchlist
The watchlist is based on the buy and sell signals.

Feedback from members

I would like feedback from members regarding changing those candles that are “in the trend” but have a different color. (see chart). This would eliminate the number of signals that appear. (especially where there is only one red or green candle in the middle of the current trend. I have tried using strategies such as increasing the lookback period, using the previous candle(s) script but with no success. Please see notes within the chart.

Also, can someone please provide the information for making the Fib lines shorter. Please see notes within the chart.

It is a work in progress. I have made profitable trades and this indicator has allowed me to find setups before major breakouts etc. (this is in combination with the Buy-the Dip).

This is a chart without the regular candles. This shows the HA with the buy and sell signals and the Multi Time Frames. This is the main trading chart. The chart with the candlesticks is used for reference during trading. (I use two monitors when trading)
i7GJm5H.jpg


This is the above chart with the regular candles.
O3grdOi.jpg


This chart shows the Fib Lines and notes on the feedback needed.
ZrGyZKw.jpg


This chart shows the HA candles without the new HA_smoothing chart
3pBHtFX.jpg


This chart shows the scan criteria
DllROT7.jpg


Code
Code:
#Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update Jan 17th 2021
#Influenced by script from HoboTheClown / blt,http://www.thinkscripter.com, TD Hacolt etc.
#MTF based on HannTech's MTF_MACD script
#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

### YOU MUST HAVE THE STYLE SETTING FIT STUDIES ENABLED ###
#hint: The style setting Fit Studies must be enabled to use these bars.


input period = 50;
input hideCandles = yes;
input candleSmoothing = {default Valcu, Vervoort};
input show_bubble_labels = yes;
input bubbles = yes;
input arrows = yes;


#input smoothingLength = 3;

input movingAverageType = {default  TEMA, Exponential, Hull };

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Exponential:
    openMA = CompoundValue(1, ExpAverage(open, period), open);
    closeMA = CompoundValue(1, ExpAverage(close, period), close);
    highMA = CompoundValue(1, ExpAverage(high, period), high);
    lowMA = CompoundValue(1, ExpAverage(low, period), low);

case Hull:
    openMA = CompoundValue(1, HullMovingAvg(open, period), open);
    closeMA = CompoundValue(1,  HullMovingAvg(close, period), close);
    highMA = CompoundValue(1,  HullMovingAvg(high, period), high);
    lowMA = CompoundValue(1,  HullMovingAvg(low, period), low);

case TEMA:
    openMA = CompoundValue(1, TEMA(open, period), open);
    closeMA = CompoundValue(1, TEMA(close, period), close);
    highMA = CompoundValue(1, TEMA(high, period), high);
    lowMA = CompoundValue(1, TEMA(low, period), low);

}


HidePricePlot(hideCandles);

def haOpen;
def haClose;

switch (candleSmoothing){
case Valcu:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);
case Vervoort:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0 ) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);

}

plot o = haOpen;
o.Hide();

def haLow =  Min(lowMA, haOpen);
def haHigh = Max(highMA, haOpen);

#Zero Lag System - MetaStock Crossover Formula
#zero-lagging principle
#Zero-lagging TEMA average on closing prices

#Medium-term price reversals - upward trend

def avg = 34;
def TMA1 = reference TEMA(haClose, avg); # triple exponential moving average (TEMA) of 34 bars
def TMA2 =  reference TEMA(TMA1, avg);
def Diff = TMA1 - TMA2;
def ZlHa = TMA1 + Diff; #Zero-lagging TEMA average on closing prices - medium term uptrend;

#Medium-term price reversals - downward trend
def TMA1_ = reference TEMA((high + low) / 2, avg);
def Diff2 = TMA1_ - TMA2;
def ZlCl = TMA1_ + Diff2; #Zero-lagging TEMA average on closing prices - medium term doenwardtrend;

def ZlDif = ZlCl - ZlHa; # Zero-Lag close - Zero-Lag HA(green candle) Uptrend when ZlDif is equal to or greater than zero

#uptrend {green candle}
def keep1 = if (haClose >= haOpen and haClose[1] >= haOpen[1]) then 1 else 0;
def keep2 = if ZlDif >= 0 then 1 else 0;
def keep3 = if (AbsValue(close - open) < ((high - low) * 0.35)) and high >= low[1] then 1 else 0;
def keeping = if (keep1 or keep2) then 1 else 0;
def keepall = if keeping or (keeping[1]) and close >= open or close >= (close[1]) then 1 else 0;

def utr = if keepall or (keepall[1]) and keep3 then 1 else 0;

#downtrend red candle

def keep1_ = if (haClose < haOpen and haClose[1] < haOpen[1]) then 1 else 0;
def keep2_ = if ZlDif < 0 then 1 else 0;
def keep3_ = if (AbsValue(close - open) < ((high - low) * 0.35)) and low <= high[1] then 1 else 0;
def keeping_ = if (keep1_ or keep2_) then 1 else 0;
def dkeepall_ = if keeping_ or (keeping_[1]) and close < open or close < (close[1]) then 1 else 0;

def dtr = if dkeepall_ or (dkeepall_[1] - 1) and keep3_ == 1 then 1 else 0;  #downtrend
def upw = if dtr and (dtr[1]) and utr then 1 else 0;
def dnw = if !utr and (utr[1] ) and dtr then 1 else 0;

def results = if upw then 1 else if dnw then 0 else results[1];

#Change the color of HA and Japanese Candles - turn off to show only HA on chart
AssignPriceColor(if haClose >= haOpen
                 then Color.GREEN else
                 if  haClose < haOpen
                 then Color.RED else Color.WHITE);


#Heiken_A script

#####################################################################################################
input charttype = ChartType.CANDLE;

def haopen_ = if haClose <= haOpen
              then haOpen + 0
             else Double.NaN;

def HAhi   = if haClose <= haOpen
              then haHigh
              else Double.NaN;

def HAlo =   if haClose <= haOpen
              then haLow
              else Double.NaN;


AddChart(growColor = Color.RED, neutralColor = Color.CURRENT, high = HAhi, low = HAlo, open = haopen_, close = haClose, type = ChartType.CANDLE);

def HAclose1 = ohlc4;
def HAopen1  = if haClose >= haOpen
               then CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (open[1] + close[1]) / 2)   
               else Double.NaN;

def haopen_1 = if haOpen <= haClose
               then HAopen1 + 0  else Double.NaN;

def HAhigh1  = haHigh;
def HAlow1   = haLow;


AddChart(growColor = Color.GREEN, neutralColor = Color.CURRENT,  high = HAhigh1, low = HAlow1, open = haopen_1, close = haClose, type = ChartType.CANDLE);

#####################################################################################################
#Buy and sell signals
def trend =  haClose >= haOpen; 
def trendup = trend and !trend[1];
def trendd =  haClose < haOpen;
def trendDown = trendd and !trendd[1];

AddChartBubble(bubbles and trendup and trendup, HAlow1, ("Reversal:"    + round(HAlow1, 2)), Color.GREEN, no);

AddChartBubble(bubbles and trendDown and trendDown, HAhigh1, ("Reversal:"  + round(HAhigh1,2)), Color.LIGHT_RED, yes);

#Arrows instead of bubbles
#def trend = haClose >= haOpen ;
#plot trendup = trend and !trend[1];
#trendup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#trendup.SetDefaultColor(Color.CYAN);


#def trendd = haClose <= haOpen ;
#plot trendDown = trendd and !trendd[1];
#trendDown.SetDefaultColor(Color.MAGENTA);
#trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

I am looking forward to your feedback. Thanks.
 
Last edited:
@Joseph Patrick 18 ....Here is another that I traded in the pre-market. Its the same code but I used two signals to further time my entry. This chart is not showing the MTF as I use 2 monitors with split charts on one of the monitor. The MTF shows on the other monitor screen. Its the same script that I posted(minus the RSI oscillator).

Hi, so the only script that you are using for both these photo's are the single script in post #134? Thanks and sorry to bother
 

BonBon

Member
VIP
Hi BonBon, I just added #'s because of errors showing up. Which script is the updated correct one? The one at post #1 or the #134? Also will this script do the top and bottom indicators like shown in your images? Only reason why I am asking is that it shows as a lower study. I am not getting the HA smoothing on the upper study at all and the lower study on say 15M TF it shows the smoothed HA with no regular MTF lower study and say on a 5M TF it shows your MTF lower study but it is compressed even tho I have "fit studies enabled"? Thanks



When using the original code are you seeing the same output??????? Did you change the sequence of the script?????? As you can see from my previous post our charts are entirely different. Can you send me a screenshot of your chart settings??
 

BonBon

Member
VIP
Hi, so the only script that you are using for both these photo's are the single script in post #134? Thanks and sorry to bother
Yes... its the same script from #134. Its no bother....... as a Dr. (Ph.D) and educator, research, problem-solving and knowing that different perspectives, levels of understanding etc is unique to us as individuals ..... By all means ask questions to ensure you understand how to install the chart correctly. It defeats our purpose (mine, yours and other members) if installation issues and potentials pitfalls are apparent and we do not address them.

Another option is to make two studies. One for the upper chart and the other for the lower chart. The MTF script begins the lower chart. Let me know if this works. If it does then this solution can be utilized by other members.
 

BonBon

Member
VIP
i couldn't get the original code to show the MTF on lower, so i just copied it from the code and made it a new lower study, then deselected the plots in the upper study. hope that makes sense.
@floydddd .... nice!!!!! great minds think alike!!!!! 💃 💃 💃 I just suggested this to @Joseph Patrick 18 . I find it interesting that the chart is not appearing on our TOS in the same manner as mine.
 
When using the original code are you seeing the same output??????? Did you change the sequence of the script?????? As you can see from my previous post our charts are entirely different. Can you send me a screenshot of your chart settings??
@floydddd .... nice!!!!! great minds think alike!!!!! 💃 💃 💃 I just suggested this to @Joseph Patrick 18 . I find it interesting that the chart is not appearing on our TOS in the same manner as mine.
Hi BonBon:) Ok I did what you and Floyddd suggested. I just split the script in post #134 in 2. The upper study was from the MTF (not including) all the way up, and the lower study was from the MTF all the way down not including anything above the MTF.



Thanks appreciate taking the time out to help me:)
 
Yes... its the same script from #134. Its no bother....... as a Dr. (Ph.D) and educator, research, problem-solving and knowing that different perspectives, levels of understanding etc is unique to us as individuals ..... By all means ask questions to ensure you understand how to install the chart correctly. It defeats our purpose (mine, yours and other members) if installation issues and potentials pitfalls are apparent and we do not address them.

Another option is to make two studies. One for the upper chart and the other for the lower chart. The MTF script begins the lower chart. Let me know if this works. If it does then this solution can be utilized by other members.
Hi, when you say there are 3 different signals, in order to use them I would remove #...are the three, #plot trendup, #plot trenddown and the #zig zag line? Sorry it's just that I am slowly learning, little by little. Thanks
 

BonBon

Member
VIP
Hi BonBon:) Ok I did what you and Floyddd suggested. I just split the script in post #134 in 2. The upper study was from the MTF (not including) all the way up, and the lower study was from the MTF all the way down not including anything above the MTF.



Thanks appreciate taking the time out to help me:)
Excellent!!!!! You are seeing the yellow, pink colors to the right of the MTF because you increased your "chart expansion" size. If you decrease your expansion size (based on your preference) it will show red or green only and/or only a minimal yellow pink green etc.
 

BonBon

Member
VIP
Hi, when you say there are 3 different signals, in order to use them I would remove #...are the three, #plot trendup, #plot trenddown and the #zig zag line? Sorry it's just that I am slowly learning, little by little. Thanks

The plot trendup and plot trenddown are the original signals that is why I kept them with the HA_Script. After the HA_script there are 3 additional signals. My charts within #134 reference these signals. After the HA_script, there are 3 signals. You do not need to use all 3 of them. I placed them in the script for the benefit of previous members who were on this thread from the inception (work had kept me busy and I wanted members to receive all the updates I made). Additionally, it gives choice as to which members would prefer to use. If you have not done so please read the thread beginning with my first posting. I hope this helps.
 
The plot trendup and plot trenddown are the original signals that is why I kept them with the HA_Script. After the HA_script there are 3 additional signals. My charts within #134 reference these signals. After the HA_script, there are 3 signals. You do not need to use all 3 of them. I placed them in the script for the benefit of previous members who were on this thread from the inception (work had kept me busy and I wanted members to receive all the updates I made). Additionally, it gives choice as to which members would prefer to use. If you have not done so please read the thread beginning with my first posting. I hope this helps.
Ok thanks again.
 

RickK

Active member
Hi @BonBon ... stellar enhancements! Thanks again.

Say, would you be willing to share your scan query? I can't seem to get it to work based on the criteria you stated in post #1 and I don't recall seeing it addressed elsewhere.

I understand though if you'd prefer to keep that under wraps. :)
 

RickK

Active member
@everyone .... here's a very slight enhancement to the Multi time-frame Heikin (lower) study for those who might be confused by the multi color scheme for the dots to the right of the current minute. I set the default color to black.


Code:
# Multi time-frame Heikin
#BonBon 1/29/21
#  Four hours and Day MTF not included in the top plot. Three or more of the indicators must be green or red to plot.


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);
HA_Up5.SetDefaultColor(color.black);
############################################

#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);
HA_Up15.SetDefaultColor(color.black);
#######################################

#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);
HA_Up30.SetDefaultColor(color.black);

################################
#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);
HA_Up60.SetDefaultColor(color.black);
##################################
#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);
HA_Up4hr.SetDefaultColor(color.black);
#######################################

#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);
HA_Upday.SetDefaultColor(color.black);

####################################
#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);
Main_Heikin.SetDefaultColor(color.black);

#End code
 

BonBon

Member
VIP
@RickK.... thank you for making the change.

@everyone... another alternative that I referenced earlier is to minimize your right expansion area. Please see below. As you can see I have my expansion area set at 5. You can set it to zero etc. and it will remove the colors as well as the the black area (those who are interested in the aesthetics.

GEAxupH.jpg
 

BonBon

Member
VIP
Hi @BonBon ... stellar enhancements! Thanks again.

Say, would you be willing to share your scan query? I can't seem to get it to work based on the criteria you stated in post #1 and I don't recall seeing it addressed elsewhere.

I understand though if you'd prefer to keep that under wraps. :)
@RickK..... I will definitely share with everyone along with the watchlist.

@everyone, if you experimented with the signals you would realize some of the appear late (the zigzag and swing). You have to determine how you want to use them and/or minimize the reversal swings etc. in the code. There are threads and forums you can use to reference the swing highs/lows, etc. If anyone finds an alternative please share.

I tend to use the zigzag signal to identify the low swing which also signals the end of the pullback or retracement (I tend to use the fib to identify retracement levels with gappers ). This signals that the HA_ trend signal is about to appear and helps my entry (buy low sell high) which puts me in a favorable position.
 

Similar threads

Top