Dear Members of the Forum,
I want to highlight Morning Star Patterns in my chart by changing the background behind the Morning Star Pattern to green. However, with the BACKGROUNDCOLOUR(r,g,b,<o>) command, I can only highlight the most recent candle’s background of the pattern that satisfies my conditions.
What I want to do is to highlight also the 2 previous candles that belong to the pattern in the same colour.
Do you have a solution for this problem.
My Code so far: (I have attached a screenshort of the result of my code):
REM MORNING STAR & MORNING DOJI STAR
MorningS1 = OPEN[2] > CLOSE[2] REM C0 is black
MorningS2 = OPEN < CLOSE REM C2 is white
MorningS3 = CLOSE > CLOSE[2] REM close of C2 above close of C0
MorningS4 = (CLOSE - CLOSE[2]) >= ((OPEN[2] - CLOSE[2]) / 2) REM C2 penetrates more than halfway into C0's real body
MorningS5 = CLOSE[1] <= (((OPEN[2] - CLOSE[2]) / 5) + CLOSE[2]) REM C2 is not above 1/5 of the lower end of C0's real body
MorningS7 = OPEN[1] = CLOSE[1] REM C1 is doji
MorningS8 = (OPEN[2] - CLOSE[2]) > Average[20](RANGE[2]) * 0.5 REM black candle has significant real body
IF MorningS1 AND MorningS2 AND MorningS3 AND MorningS4 AND MorningS5 AND MorningS8 THEN
IF MorningS7 THEN
BACKGROUNDCOLOR(0, 0, 255, 100)
DRAWTEXT("Morning\nStar\nDoji", BARINDEX, (HIGH * 1.05))
ELSE
BACKGROUNDCOLOR(0, 0, 255, 100)
DRAWTEXT("Morning\nStar", BARINDEX, (HIGH * 1.05))
ENDIF
ENDIF
RETURN
Thank you so much!
PS: If your solution involves arrays, I would be very thankful if you could provide some sample code, because I am not yet the most comfortable with implementing arrays.
Greetings,
Nils
To color the background in the history, a simple trick is to use an infinite rectangle, example:
Couleur du background (fond d’ecran)
use any barindex in the past to locate your background color where it is needed.
Dear Nicolas,
Thank you for the workaround!