9 EMA Cross over change candle color


Category:
0
0

Hi Pete,

I was looking at for study which can change candle color to white and arrow pops up or down, when 9 EMA cross 20EMA, 50EMA, 100EMA, and 200EMA. Here is the screenshot attached.

 

Thanks,

Harry

Attachments:
Marked as spam
Posted by Harinder Singh (Questions: 4, Answers: 7)
Asked on August 22, 2018 7:41 pm
442 views
0
Private answer

This should do the trick:

input lengthOne = 9;
input lengthTwo = 20;
input lengthThree = 50;
input lengthFour = 100;
input lengthFive = 200;
input averageType = AverageType.EXPONENTIAL;
plot emaOne = MovingAverage(averageType, close, lengthOne);
plot emaTwo = MovingAverage(averageType, close, lengthTwo);
plot emaThree = MovingAverage(averageType, close, lengthThree);
plot emaFour = MovingAverage(averageType, close, lengthFour);
plot emaFive = MovingAverage(averageType, close, lengthFive);
plot crossingAbove = (emaOne[1] < emaTwo[1] and emaOne > emaTwo) or (emaOne[1] < emaThree[1] and emaOne > emaThree) or (emaOne[1] < emaFour[1] and emaOne > emaFour) or (emaOne[1] < emaFive[1] and emaOne > emaFive);
crossingAbove.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot crossingBelow = (emaone[1] > emaTwo[1] and emaOne < emaTwo) or (emaone[1] > emaThree[1] and emaOne < emaThree) or (emaone[1] > emaFour[1] and emaOne < emaFour) or (emaone[1] > emaFive[1] and emaOne < emaFive);
crossingBelow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
AssignPriceColor(if crossingAbove or crossingBelow then Color.WHITE else Color.CURRENT);

Attachments:
Marked as spam
Posted by Pete Hahn (Questions: 37, Answers: 4153)
Answered on August 23, 2018 9:37 am
0
Thx Hahn works good, is there a way to make BOOLEAN_ARROW_DOWN Large or excel? and change the colour of arrow to red and green and if possible can we make that intraday, not Pre Market or after Market. Thx
(Harinder Singh at August 23, 2018 10:05 am)
0

All of those things you just mentioned are a simple matter of adjusting settings that are common to all chart studies. There is no need to write any code to achieve any of that.

(Pete Hahn at August 23, 2018 10:46 am)
0

Thx, just found how can change color and size of an arrow. But there is no option of just intraday study. Thx

(Harinder Singh at August 23, 2018 10:59 am)
0

Perhaps I don’t understand your request about “just intraday study”. Simply change the time frame on the chart to anything measured in minutes. What am I missing? And you mentioned something about not premarket and not aftermarket. These are chart settings. Are you brand new to this platform? Those are very fundamental adjustments.

(Pete Hahn at August 23, 2018 11:05 am)
0

is there a way to have audio alert during the crossover?

(Shaishav Patel at September 8, 2018 11:04 pm)
0

Yes, alerts can be included by adding these two lines to the bottom of the code:

Alert(crossingAbove, “Cross Above”, Alert.BAR, Sound.RING);
Alert(crossingBelow, “Cross Below”, Alert.BAR, Sound.RING);

(Pete Hahn at September 9, 2018 7:53 am)
0

Hi Pete. I have the other code for the ema crossing, but I have a question about the SoundRing. TOS rings for about 2-3 hours and then it stops ringing. I still get the flash at the top of the watchlist area, but no sound.   Any thoughts?

(CAROL W PFARR at September 26, 2018 1:56 pm)
0

I can’t imagine anything that would make it work sometimes but not others. For that, I am going to have to refer you to TDA support. There is nothing we can do with code to address that.

(Pete Hahn at September 26, 2018 2:13 pm)