Cannot Hide AssignPriceColor on Daily chart?

sandstromb

New member
Code:
def Day = GetAggregationPeriod() >=AggregationPeriod.DAY;

AssignPriceColor(if Day then Double.NaN else if StrongBuy  then GlobalColor("OpenLongPosition") else if StrongShort then GlobalColor("OpenShortPosition") else if (SoftBuyEmaCross) and (MacdBullish) or (SoftBuyEmaCross) and (MacdBullishStrong) and (close > EMA5) then GlobalColor("HoldLongPosition") else if SoftShortMacd or SoftShortEma then GlobalColor("HoldShortPosition") else GlobalColor("CriteriaNotMet"));
Needing help again. How do I hide an assigned price color on the daily chart? Those values need to change. I've declared the Script as Hide_On_Daily yet those and the Chart bubbles continue to show. I was able to remove the Chart bubbles with an If statement however it removes all Assigned Price Colors if done there. I also tried just using AggregationPeriod.Day also to no avail. Not sure why Declare Hide_On_Daily; didn't work for this portion.
 
Solution
I removed the Declare Hide_On_Daily; but it didn't help.

This should disable the assignpricecolor on a Daily chart and greater. Replace this area of code in your script to this:

Ruby:
AssignPriceColor (if getaggregationPeriod() >= aggregationPeriod.DAY
                  then color.current
                  else if StrongBuy
                       then GlobalColor("OpenLongPosition")
                  else if StrongShort
                       then GlobalColor("OpenShortPosition")
                  else if (SoftBuyEmaCross) and (MacdBullish) or
                          (SoftBuyEmaCross) and (MacdBullishStrong) and (close > EMA5) 
                       then GlobalColor("HoldLongPosition")
                  else if...
Code:
def Day = GetAggregationPeriod() >=AggregationPeriod.DAY;

AssignPriceColor(if Day then Double.NaN else if StrongBuy  then GlobalColor("OpenLongPosition") else if StrongShort then GlobalColor("OpenShortPosition") else if (SoftBuyEmaCross) and (MacdBullish) or (SoftBuyEmaCross) and (MacdBullishStrong) and (close > EMA5) then GlobalColor("HoldLongPosition") else if SoftShortMacd or SoftShortEma then GlobalColor("HoldShortPosition") else GlobalColor("CriteriaNotMet"));
Needing help again. How do I hide an assigned price color on the daily chart? Those values need to change. I've declared the Script as Hide_On_Daily yet those and the Chart bubbles continue to show. I was able to remove the Chart bubbles with an If statement however it removes all Assigned Price Colors if done there. I also tried just using AggregationPeriod.Day also to no avail. Not sure why Declare Hide_On_Daily; didn't work for this portion.

hello and welcome

how are people going to help fix your code, if you don't post your complete code?
 

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

hello and welcome

how are people going to help fix your code, if you don't post your complete code?
Didn't think you would need the whole thing my bad.
Code:
Declare Upper;


 
######################################################################
#                         Options                                    #
######################################################################
input TradeSize = 10;
input StopLossPct = -5; #Represents Percent of price loss per share
def StopLossPctFm = (StopLossPct / 100) + .9;
input HideTkPftBubble = No;
input HideOvrExtBubble = No;
input ShowOrders = No;
input ShowSquares = No;
input InverseChart = {default "No", "2x", "3x"};



########################################################################
#                            Colors                                    #
########################################################################
DefineGlobalColor("200EMA", CreateColor (255, 255, 255));
DefineGlobalColor("CloudUp", CreateColor (102, 255, 102));
DefineGlobalColor("CloudDown", CreateColor (255, 102, 102));
DefineGlobalColor("OpenLongPosition", CreateColor (0, 255, 0));
DefineGlobalColor("OpenShortPosition", CreateColor (255, 0, 0));
DefineGlobalColor("HoldLongPosition", CreateColor (120, 255, 120));
DefineGlobalColor("HoldShortPosition", CreateColor (255, 120, 120));
DefineGlobalColor("SellPosition", CreateColor (255, 0, 0));
DefineGlobalColor("TakeProfit", CreateColor (255, 0, 255));
DefineGlobalColor("CriteriaNotMet", CreateColor (102, 102, 102)); #(255, 255, 0)
DefineGlobalColor("EMA", CreateColor (0, 0, 0));
DefineGlobalColor("Up", CreateColor (153, 255, 153));
DefineGlobalColor("Dn", CreateColor (255, 153, 153));

########################################################################
#                                 Times                                #
########################################################################
#START AND END TIMES
input PreMarketStart = 0700; #EST
input PreMarketEnd = 0929; #EST
input RegularDayStart = 0930; # EST
input RegularDayEnd = 1600; # EST
input AfterHoursStarts = 1601; #Est
input AfterHoursEnd = 1800; #EST     
input StartDelay = 0;

def TradingDay = RegularDayStart and RegularDayEnd; #0930EST - 1600EST
def TradingDayExt = AfterHoursStarts and AfterHoursEnd; #1601EST - 1800EST
def SignalStart = PreMarketStart;
def EndDay = AfterHoursEnd;

def Day = GetAggregationPeriod() >=AggregationPeriod.DAY;
def Interday = GetAggregationPeriod() < AggregationPeriod.DAY;
###########################################################################
#                                Indicaors                                #
###########################################################################
#SMA's
input HideSma5 = Yes;
input HideSma5Label = Yes;
input HideSma10 = Yes;
input HideSma20 = No;
input ShowSmaCloud = Yes;
#SMA 5
plot SMA5 = SimpleMovingAvg(HL2, 5);
SMA5.SetPaintingStrategy(PaintingStrategy.LINE);
SMA5.SetDefaultColor(GlobalColor("CloudUp"));
SMA5.SetHiding(HideSma5);
AddLabel(!HideSma5Label, if SMA5 then " 5 SMA" else " ", Color.GREEN);

#SMA10
plot SMA10 = SimpleMovingAvg(HL2, 10);
SMA10.SetPaintingStrategy(PaintingStrategy.LINE);
SMA10.SetDefaultColor(GlobalColor("CloudDown"));
SMA10.SetHiding(HideSma10);

AddCloud(if ShowSmaCloud or Interday then SMA5 else Double.NaN, if ShowSmaCloud then SMA10 else Double.NaN, GlobalColor("CloudUp"), GlobalColor("CloudDown"), yes);
#EMA's

#EMA 5
input SellCrossBelowPct = -0.00; #Should be negetive number
input BuyCrossAbovePct = 0.00;
input HideEma5 = Yes;
input HideEma10 = Yes;
input HideEmaCloud = Yes;
def SellCrossBelowPctFm = (SellCrossBelowPct / 100);
def BuyCrossAbovePctFm = (BuyCrossAbovePct / 100);
input EMA5Label = {default "Yes", "No"};
plot EMA5 = ExpAverage(close, 5);
EMA5.SetPaintingStrategy(PaintingStrategy.LINE);
EMA5.SetDefaultColor(Color.GRAY);
EMA5.SetHiding(HideEma5);
def EMA5Low = ExpAverage(low, 5);
def EMA5High = ExpAverage(high, 5);
      
# EMA 10

plot EMA10 = ExpAverage(close, 10);
EMA10.SetPaintingStrategy(PaintingStrategy.LINE);
EMA10.AssignValueColor(if IsAscending(close, 10) then Color.LIGHT_GREEN else Color.LIGHT_RED);
EMA10.SetLineWeight(1);
EMA10.SetHiding(HideEma10);
def EMA10Low = ExpAverage(low, 10);
def EMA10High = ExpAverage(high, 10);
# EMA 5&10 Color Gradient
def EMA1UpColor =  EMA5 > EMA10;
def EMA1DnColor = EMA5 < EMA10;

AddCloud(if HideEmaCloud or Day then Double.NaN else EMA5, if HideEmaCloud or Day then Double.NaN else EMA10 , Color.LIGHT_GREEN, Color.LIGHT_RED, yes);





    # EMA's Bullish or Bearish
def EMABullish = EMA5 > EMA10;
def EMABearish = EMA5 < EMA10;

        #EMA Percent Seperation
def EMAPctBull = ((EMA5 / EMA10) * 100) - 100; # Distance Between EMA5 and EMA10
def EMAPctBullRound = Round(EMAPctBull, 2);
def EMAPctBear = ((EMA10 / EMA5) * 100) - 100; # Distance Between EMA10 and EMA5
def EMAPctBearRound = Round(EMAPctBear, 2);

        #Fast EMA Percent Seperation Buy Signals
input TimeFrame = {default "5-MIN", "1-MIN", "10-MIN", "15-MIN", "30-MIN", "HOUR"};

def EMASepThrHld;
switch (TimeFrame) {
case "1-MIN":
    EMASepThrHld = 0.1;
case "10-MIN":
    EMASepThrHld = 0.25;
case "15-MIN":
    EMASepThrHld = 0.25;
case "30-MIN":
    EMASepThrHld = 0.3;
case "HOUR":
    EMASepThrHld = 0.3;
default:
    EMASepThrHld = 0.2;
}

def EMAPctBullish = EMAPctBullRound > EMASepThrHld and EMAPctBullRound >= EMAPctBullRound[1];
def EMAPctBearish = EMAPctBearRound > EMASepThrHld and EMAPctBearRound >= EMAPctBearRound[1];

                # EMA Buy / Sell Signals

def EMACrossDown = EMA5 crosses below EMA10;
def EMACrossUP = EMA5 crosses above EMA10;
def ProfitPct;
switch (InverseChart){
case "2x":
    ProfitPct = 1.00625;
case "3x":
    ProfitPct = 1.0125;
default:
    ProfitPct = 1.00417;
}

def OverExtPct;
switch (InverseChart) {
case "2x":
    OverExtPct = .9835;
case "3x":
    OverExtPct = .9725;
default:
    OverExtPct = .995;
}

def TakeProfit = close > (EMA5 * ProfitPct);
def OverExtended = close < (EMA5 * OverExtPct);

AddChartBubble(if HideOvrExtBubble or Day then Double.NaN else OverExtended, close, "Over Ext", GlobalColor("OpenShortPosition"));
AddChartBubble(if HideTkPftBubble or Day then Double.NaN else TakeProfit, close, "Smart Sell", GlobalColor("OpenLongPosition"), yes);

# MACD

input MacdUpPct = 0.5;
input MacdDownPct = 0.5;
input ShowMacdBubble = No;

def fastLength = 12;
def slowLength = 26;
def MACDLength = 9;
def averageType = AverageType.EXPONENTIAL;
def value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, value, MACDLength);
def Diff = value - Avg;
def ZeroLine = 0;

def MacdBullish = IsAscending(close, 5) and (value * 1.009) > Avg;
def MacdBearish = IsDescending(close, 5) and value < (Avg * 0.0875);
def HalfMacdValueHigh = HighestAll(value) / 2;
def HalfMacdAvgHigh = HighestAll (Avg) / 2;
def HalfMacdValueLow = LowestAll (value) / 2;
def HalfMacdAvgLow = LowestAll (Avg) / 2;
def MacdBullishStrong = IsAscending(value) >= (HalfMacdValueLow) and (Avg) >= (HalfMacdAvgLow) and (value) > (Avg + 0.03);
def MacdBearishStrong = IsDescending(close, 9) and (value) <= (HalfMacdValueHigh) and (Avg) <= (HalfMacdAvgHigh) and (value) < (Avg - 0.03);

#AddChartBubble(MacdBullish, close, "MacdBullish", Color.LIGHT_GREEN);
#AddChartBubble(MacdBullishStrong, close, "MacdBullishStrong", Color.GREEN, yes);
#AddChartBubble(MacdBearish, close, "MacdBearish", Color.LIGHT_RED);
#AddChartBubble(MacdBearishStrong, close, "MacdBearishStrong", Color.RED);

##################################################################
#                          PREMARKET                             #
##################################################################
#PREMARKET HIGHS AND LOWS
input ShowPreMarketLabel = Yes;
def PreMarketTimeRange = SecondsFromTime(PreMarketStart) >= 0 and SecondsTillTime(PreMarketEnd) >= 0;
def PreMarket = PreMarketTimeRange and !PreMarketTimeRange[1];
def Pre_Market_High = CompoundValue(1, If((high > Pre_Market_High[1] and PreMarketTimeRange) or PreMarket, high, Pre_Market_High[1]), high);
def Pre_Market_Low = CompoundValue(1, If((low < Pre_Market_Low[1] and PreMarketTimeRange) or PreMarket, low, Pre_Market_Low[1]), low);

plot PreMarketHigh = Pre_Market_High;
PreMarketHigh.SetStyle(Curve.SHORT_DASH);
PreMarketHigh.SetDefaultColor(Color.LIGHT_GRAY);
PreMarketHigh.Hide();

plot PreMarketLow = Pre_Market_Low;
PreMarketLow.SetStyle(Curve.SHORT_DASH);
PreMarketLow.SetDefaultColor(Color.LIGHT_GRAY);
PreMarketLow.Hide();
;

AddLabel(if ShowPreMarketLabel then yes else no, "   ", Color.BLACK);
AddLabel(if ShowPreMarketLabel then yes else no, " PM High - $" + PreMarketHigh + " ", Color.GRAY);
AddLabel(if ShowPreMarketLabel then yes else no, " PM Low - $" + PreMarketLow + " ", Color.GRAY);

##############################################################################
#                       Order & Bar Conditions                               #
##############################################################################

def SoftBuyEmaCross = ((close) > EMA5 ) or (EMA5 > EMA10) ;
def SoftBuyMacd = MacdBullish;
def StrongBuy = (SoftBuyEmaCross) and (MacdBullishStrong) and (MacdBullish);

plot LongBuy = if ShowSquares or day and StrongBuy[1] or ShowSquares or day and StrongBuy[2] then Double.NaN else ShowSquares or day and StrongBuy;
LongBuy.SetDefaultColor(Color.GREEN);
LongBuy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
LongBuy.SetLineWeight(3);
LongBuy.HideBubble();
#LongBuy.Hide();

plot SmartSell = if ShowSquares or day and TakeProfit then close else Double.NaN;
SmartSell.SetDefaultColor(GlobalColor("TakeProfit"));
SmartSell.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
SmartSell.SetLineWeight(3);
SmartSell.HideBubble();
#SmartSell.Hide();

def SoftSell = Close < EMA5Low;
plot SellSoft = if ShowSquares or Day and (SoftSell[2]) or ShowSquares or Day and (SoftSell[1]) then Double.NaN else ShowSquares or Day and (SoftSell) ;
SellSoft.SetDefaultColor(Color.LIGHT_RED);
SellSoft.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
SellSoft.SetLineWeight(3);
SellSoft.HideBubble();
#SellSoft.Hide();

plot SellStrong = If ShowSquares and (close[1] < EMA10Low[1]) or ShowSquares and (Close[2] < EMA10Low[2])then Double.NaN else ShowSquares and (Close < EMA10Low) ;
SellStrong.SetDefaultColor(Color.RED);
SellStrong.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
SellStrong.SetLineWeight(5);
SellStrong.HideBubble();
#SellStrong.Hide();

def StopLoss = (EntryPrice()) * StopLossPctFm;
def SoftShortMacd = MacdBearish;
def SoftShortEma = ((close) < EMA10);
def StrongShort = (SoftShortEma) and (SoftShortMacd)  and (MacdBearishStrong) and (close * .99) < EMA10Low;

#plot SoftShortEntry = SoftShortEma and SoftShortMacd;
#SoftShortEntry.SetDefaultColor(Color.LIGHT_GREEN);
#SoftShortEntry.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#SoftShortEntry.SetLineWeight(5);
#SoftShortEntry.HideBubble();
#SoftShortEntry.Hide();

#AddChartBubble(StopLoss,Open,"Stop",Color.DARK_RED);

##############################################################################
#                                Bars                                        #
##############################################################################
AssignPriceColor (if StrongBuy  then GlobalColor("OpenLongPosition") else if StrongShort then GlobalColor("OpenShortPosition") else if (SoftBuyEmaCross) and (MacdBullish) or (SoftBuyEmaCross) and (MacdBullishStrong) and (close > EMA5) then GlobalColor("HoldLongPosition") else if SoftShortMacd or SoftShortEma then GlobalColor("HoldShortPosition") else GlobalColor("CriteriaNotMet"));


##############################################################################
#                                      Orders                                #
##############################################################################

AddOrder(OrderType.BUY_TO_OPEN, ShowOrders and SoftBuyEmaCross and SoftBuyMacd, open[-1], (TradeSize / 2), Color.LIGHT_GREEN, Color.LIGHT_GREEN);
AddOrder(OrderType.SELL_TO_CLOSE, ShowOrders and SmartSell, open[-1], TradeSize, Color.RED, Color.RED);
AddOrder(OrderType.SELL_TO_CLOSE, ShowOrders and SellStrong, open[-1], TradeSize, Color.RED, Color.RED);
 
I removed the Declare Hide_On_Daily; but it didn't help.

This should disable the assignpricecolor on a Daily chart and greater. Replace this area of code in your script to this:

Ruby:
AssignPriceColor (if getaggregationPeriod() >= aggregationPeriod.DAY
                  then color.current
                  else if StrongBuy
                       then GlobalColor("OpenLongPosition")
                  else if StrongShort
                       then GlobalColor("OpenShortPosition")
                  else if (SoftBuyEmaCross) and (MacdBullish) or
                          (SoftBuyEmaCross) and (MacdBullishStrong) and (close > EMA5) 
                       then GlobalColor("HoldLongPosition")
                  else if SoftShortMacd or SoftShortEma
                       then GlobalColor("HoldShortPosition")
                  else GlobalColor("CriteriaNotMet"));
 
Solution

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
528 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