Requesting help with alert on custom indicator

T

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:
BenTen

BenTen

Administrative
Staff
VIP
The mobile app is very limited, some features won't be supported via the app.
 
Thread starter Similar threads Forum Replies Date
A Requesting momentum bar scanner on 5m timeframe Questions 0
T Help me Add Chart Bubble on previous candle Questions 3
L Need help with Volume index indicator Questions 9
VladMad Need help with array variables Questions 1
M Help Please With Dynamic color Settings Questions 2

Similar threads

Top