Requesting help with alert on custom indicator

tabla

New member
VIP
This custom indicator gives intraday bullish and bearish signals.

But there are two issues
1. if Alerts are set up by doing a 'create alert' by right clicking on the indicator) the mobile push alerts don't fire correctly. They seem to be triggering off seemingly randomly and don't align with the visual onscreen up/down arrows the visuals work fine on the chart (i.e. up/down arrows). Interestingly - the on-screen alerts work fine (by using createalert thinkscript statements work fine too)

2. the indicator and arrows doesn't display on a mobile device (when debugging, it seems to fail to render on the lindev statement)

Would really appreciate your feedback and a fix to the above two issues! I am pasting the custom indicator thinkscript below
Use on a 2 min chart for SPY -->

Thanks in advance for your help!!

Code:
input avg1Length = 10;
input avg1Type = AverageType.SIMPLE;
input avg1PriceType = FundamentalType.CLOSE;
input avg1TimeframeType = {default Chart, Custom};
input avg1CustomTimeframe = AggregationPeriod.THREE_MIN;
def avg1tf = if avg1TimeframeType == avg1TimeframeType.Chart then GetAggregationPeriod() else avg1CustomTimeframe;
input avg1Displace = 0;
input avg2Length = 30;
input avg2Type = AverageType.SIMPLE;
input avg2PriceType = FundamentalType.CLOSE;
input avg2TimeframeType = {default Chart, Custom};
input avg2CustomTimeframe = AggregationPeriod.FOUR_MIN;
def avg2tf = if avg1TimeframeType == avg1TimeframeType.Chart then GetAggregationPeriod() else avg2CustomTimeframe;
input avg2Displace = 0;
input showMaCrossovers = yes;
input useMaCrossoverAlerts = yes;

plot MA1 = MovingAverage(averagetype = avg1Type, data = Fundamental(period = avg1tf, fundamentalType = avg1PriceType)[-avg1Displace], length = avg1Length);
plot MA2 = MovingAverage(averagetype = avg2Type, data = Fundamental(period = avg2tf, fundamentalType = avg2PriceType)[-avg2Displace], length = avg2Length);

MA1.SetDefaultColor(GetColor(6));
MA1.SetPaintingStrategy(PaintingStrategy.LINE);
MA2.SetDefaultColor(GetColor(5));
MA2.SetPaintingStrategy(PaintingStrategy.LINE);

# signal is > 0 if MACD is bullish is < 0 if MACD is bearish
def signal = MACD("fast length" = 8, "slow length" = 21, "average type" = "WILDERS").Value - MACD("fast length" = 8, "slow length" = 21, "average type" = "WILDERS").Avg;


def upsig = Crosses(MA1, MA2, CrossingDirection.ABOVE)
and signal >=0;
def dnsig = Crosses(MA1, MA2, CrossingDirection.BELOW)
and signal <= 0;

#def conf=reference MACD(8,21,7,'Wilders',no).avg;
#plot bullishX = showMaCrossovers and upsig;
#plot bearishX = showMaCrossovers and dnsig;
#bullishX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#bearishX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#bullishX.SetDefaultColor(Color.GREEN);
#bearishX.SetDefaultColor(Color.RED);

#======================================
# Now CCI
#======================================

input timeframe = AggregationPeriod.TWENTY_MIN;
#hint timeframe: Choose the higher timeframe that you want to use for signals. Must be a higher or equal time frame than the current chart's timeframe, cannot be smaller.
input length = 4;
#hint length: Choose the CCI length setting. 14 by default.
input over_sold = -50;
#hint over_sold: Choose the oversold threshold level. -100 by default.
input over_bought = 50;
#hint over_bought: Choose the overbought threshold level. 100 by default.
input showBreakoutSignals = yes;
#hint showBreakoutSignals: Choose whether or not to display breakout and breakdown entry signals.
input breakoutLevel = 50.0;
#hint breakoutLevel: Choose the breakout signal level. When CCI crosses above this level an entry signal will be triggered.
input breakdownLevel = -50.0;
#hint breakdownLevel: Choose the breakdown signal level. When CCI crosses below this level an entry signal will be triggered.
input showColoredClouds = yes;
#hint showColoredClouds: Choose whether or not to paint the colored backgrounds above the overbought level and below the oversold level.

# logic
def price = close(period = timeframe) + low(period = timeframe) + high(period = timeframe);



def linDev = LinDev(price, length);
# plots
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def OverBought = over_bought;
def ZeroLine = 0;
def OverSold = over_sold;
def UpSignal = if Crosses(CCI, breakoutLevel, CrossingDirection.ABOVE) then high else Double.Nan;
def DownSignal = if Crosses(CCI, breakdownLevel, CrossingDirection.BELOW) then low else Double.Nan;


#UpSignal.SetDefaultColor(Color.GREEN);
#UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

plot bullishX = showMaCrossovers and UpSignal;
plot bearishX = showMaCrossovers and DownSignal;
bullishX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bearishX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bullishX.SetDefaultColor(Color.GREEN);
bearishX.SetDefaultColor(Color.RED);

def MF=MoneyFlowIndex("over sold" = 25, "over bought" = 75, "moving avg length" = 8);

def MFUpSignal = if Crosses(MF, 25, CrossingDirection.BELOW) then low else Double.Nan;
def MFDownSignal = if Crosses(MF, 75, CrossingDirection.BELOW) then low else Double.Nan;

plot MFbullishX = showMaCrossovers and MFUpSignal;
plot MFbearishX = showMaCrossovers and MFDownSignal;
MFbullishX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
MFbearishX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
MFbullishX.SetDefaultColor(Color.DARK_GREEN);
MFbearishX.SetDefaultColor(Color.PINK);
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
510 Online
Create Post

Similar threads

Similar threads

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