Hi, I would like to create a color bar indicator to compile the Heikin Ashi trend of the top three market drivers tickers for /ES and /NQ which are (AAPL, NVDA, MSFT) and see the overall trend of them. If all are uptrend, then colorBar green, if all are downtrend then color bar red else orange. I have this code, but still needs to fix to do that:
If someone can help to achieve this will help me a lot. The idea is to see all three top tickers confluence in the same direction so that I can open a trade based on that.
Thanks for your help
@samer800 @chewie76 @rad14733
@MerryDay
Ruby:
declare upper;
input colorBars = yes;
# APPLE HEIKIN ASHI
def haCloseAAPL = ohlc4("AAPL");
def haOpenAAPL = (haOpenAAPL[1] + haCloseAAPL[1]) / 2;
def haTrendUpAAPL = if haCloseAAPL >= haOpenAAPL then 1 else 0;
def haTrendDnAAPL = if haCloseAAPL < haOpenAAPL then 1 else 0;
# NVIDIA HEIKIN ASHI
def haCloseNVDA = ohlc4("NVDA");
def haOpenNVDA = (haOpenNVDA[1] + haCloseNVDA[1]) / 2;
def haTrendUpNVDA = if haCloseNVDA >= haOpenNVDA then 1 else 0;
def haTrendDnNVDA = if haCloseNVDA < haOpenNVDA then 1 else 0;
# MICROSOFT HEIKIN ASHI
def haCloseMSFT = ohlc4("MSFT");
def haOpenMSFT = (haOpenMSFT[1] + haCloseMSFT[1]) / 2;
def haTrendUpMSFT = if haCloseMSFT >= haOpenMSFT then 1 else 0;
def haTrendDnMSFT = if haCloseMSFT < haOpenMSFT then 1 else 0;
def haSignal =
if ((haTrendUpAAPL == 1 and haTrendUpAAPL[1] == 1) and
(haTrendUpNVDA == 1 and haTrendUpNVDA[1] == 1) and
(haTrendUpMSFT == 1 and haTrendUpMSFT[1] == 1)) then 1
else
if ((haTrendDnAAPL == 1 and haTrendDnAAPL[1] == 1) and
(haTrendDnNVDA == 1 and haTrendDnNVDA[1] == 1) and
(haTrendDnMSFT == 1 and haTrendDnMSFT[1] == 1))
then -1 else 0;
DefineGlobalColor("UpTrend", Color.GREEN);
DefineGlobalColor("DnTrend", Color.RED);
DefineGlobalColor("Transition", Color.DARK_ORANGE);
AssignPriceColor(if colorBars then
if haSignal == 1 then GlobalColor("UpTrend")
else if haSignal == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
else color.current
);
If someone can help to achieve this will help me a lot. The idea is to see all three top tickers confluence in the same direction so that I can open a trade based on that.
Thanks for your help
@samer800 @chewie76 @rad14733
@MerryDay
Last edited: