50 EMA Cross


0
0

Hi Pete,

I’m was looking for a study for a 50 EMA cross with alert.  If the candlestick is trading below the 50 EMA  and then the next bar closed above the 50 and alert is triggered….I was love to see it in both directions.

Marked as spam
Posted by (Questions: 49, Answers: 42)
Asked on December 29, 2018 9:21 am
193 views
2
Private answer

I appreciate Nick jumping in there and providing an answer. However his code does not include the alerts which were a core component of the request. Here is my solution which also provides user inputs for the length and type of moving average.

input length = 50;
input averageType = AverageType.EXPONENTIAL;
plot ma = MovingAverage(averageType, close, length);
plot crossAbove = close[1] < ma[1] and close > ma;
crossAbove.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
crossAbove.SetDefaultColor(Color.CYAN);
crossAbove.SetLineWeight(3);
plot crossBelow = close[1] > ma[1] and close < ma;
crossBelow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
crossBelow.SetDefaultColor(Color.MAGENTA);
crossBelow.SetLineWeight(3);
Alert(crossAbove, "Cross Above", Alert.BAR, Sound.RING);
Alert(crossBelow, "Cross Below", Alert.BAR, Sound.RING);

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on December 29, 2018 12:12 pm
1
Private answer

Simply create new study and paste this in

#####

plot EMA50UP = MovAvgExponential(“length” = 50).”AvgExp” crosses above close;
plot EMA50DOWN= MovAvgExponential(“length”= 50).”AvgExp”
crosses below close;
EMA50DOWN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_up);
EMA50DOWN.SetDefaultColor(GetColor(4));
EMA50DOWN.SetLineWeight(3);
EMA50UP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
EMA50UP.SetDefaultColor(GetColor(5));
EMA50UP.SetLineWeight(3);

 

 

Marked as spam
Posted by (Questions: 7, Answers: 13)
Answered on December 29, 2018 10:27 am
0

Pete,
Looks great could you add the alert for a full candle cross confirmation and close and not just a cross of part of the candle. Also could you change the arrow alert to the words LONG/SHORT

( at December 29, 2018 1:01 pm)