Indicator for candle color green/red if close above/below EMA
Forums › ProRealTime English forum › ProBuilder support › Indicator for candle color green/red if close above/below EMA
- This topic has 7 replies, 3 voices, and was last updated 1 year ago by robertogozzi.
-
-
11/06/2022 at 3:31 PM #203640
Hi, Is there an indicator in prorealtime (as shown in below picture)?
It print green candles when close above EMA line, and red candles when close below EMA line. All candles will be either green or red.
EMA line also changes color green/red, depending on bar close above/below EMA line.
Does anyone have this indicator please? I use this on Tradingview charts, seems simple, but can’t find on prorealtime.
Thanks
11/06/2022 at 4:40 PM #203666There you go:
123456789101112r = 0g = 255b = 0t = 255MyMA = average[Periods,Type](close)IF close <= MyMA THENr = 255g = 0t = 255ENDIFDrawCandle(Open,High,Low,Close) coloured(r,g,b,t)RETURN MyMA coloured(r,g,b,t) AS "My Moving Average"1 user thanked author for this post.
11/07/2022 at 4:17 AM #203709There you go:
123456789101112r = 0g = 255b = 0t = 255MyMA = average[Periods,Type](close)IF close <= MyMA THENr= 255g= 0t= 255ENDIFDrawCandle(Open,High,Low,Close) coloured(r,g,b,t)RETURN MyMA coloured(r,g,b,t) AS “My Moving Average”Thanks for reply. The above code is showing error “The following variable is undefined: Periods, Type”
11/07/2022 at 5:07 AM #203711There you go:
123456789101112r = 0g = 255b = 0t = 255MyMA = average[Periods,Type](close)IF close <= MyMA THENr= 255g= 0t= 255ENDIFDrawCandle(Open,High,Low,Close) coloured(r,g,b,t)RETURN MyMA coloured(r,g,b,t) AS “My Moving Average”Thanks for reply. The above code is showing error “The following variable is undefined: Periods, Type”
Thanks a lot @robertogozzi, it works now.
11/07/2022 at 7:11 AM #203714Sorry, I forgot to post a couple of lines with the two settings:
12Periods = 20 //any number greater than 0Type = 1 //0-8 as from https://www.prorealcode.com/documentation/average/I’m glad you could find a solution.
1 user thanked author for this post.
11/07/2022 at 8:29 AM #203734Sorry, I forgot to post a couple of lines with the two settings:
12Periods = 20 //any number greater than 0I’m glad you could find a solution.
Thanks again robertgozzi. It works good, I appreciate your reply.
04/11/2023 at 9:41 AM #213091How can i draw a green candle if the indicator condition is true and red when indicator condition is fale. Its based on Weekly and daily data, and I intend to load it in 15m chart.
here is the code,
Candle Color123456789101112131415161718192021222324r = 0g = 0b = 0t = 0Timeframe (Weekly)indicator1w, indicator2w, ignored, ignored = CALL DTOSC[1, 0](close)cx1=(indicator1w >= indicator2w)Rem STU Exit Conditions, trail stop when Daily DT > 75 or DT BearTimeframe (Daily)indicator1d, indicator2d, ignored, ignored = CALL DTOSC[1, 0](close)cx2=((indicator1d >= indicator2d) )timeframe (15 minute)If cx1=1 and cx2=1 thenr = 255g = 0t = 255EndifDrawcandle(open,high,low,close) bordercolor(r,g,b,t)return04/11/2023 at 6:51 PM #213128I tested this slightly modified version, which works like a charm:
123456789101112131415161718192021222324252627Timeframe (Weekly,UpdateOnClose)//indicator1w, indicator2w, ignored, ignored = CALL DTOSC[1, 0](close)indicator1w = average[5,0](close)indicator2w = average[10,0](close)cx1=(indicator1w >= indicator2w)Rem STU Exit Conditions, trail stop when Daily DT > 75 or DT BearTimeframe (Daily,UpdateOnClose)//indicator1d, indicator2d, ignored, ignored = CALL DTOSC[1, 0](close)indicator1d = average[5,0](close)indicator2d = average[10,0](close)cx2=(indicator1d >= indicator2d)timeframe (15 minute)r = 255g = 0b = 0t = 255If cx1=1 and cx2=1 thenr = 0g = 255EndifDrawcandle(open,high,low,close) coloured(r,g,b,t) bordercolor(r,g,b,t)returnI replaced DTOSC with SMAs, as I don’t have it installed.
-
AuthorPosts
Find exclusive trading pro-tools on