ONCE AvgCross = 0
ONCE DayCount = 0
ONCE Offset = 20 * pipsize //Distance from High/Low to display arrows
ONCE FastSma = 20
ONCE SlowSma = 50
ONCE AvgType = 0 //0 = sma (see table at https://www.prorealcode.com/documentation/average/)
ONCE MaxDays = 5 //Display arrows for max 5 consecutive days
FastAvg = average[FastSma,AvgType]
SlowAvg = average[SlowSma,AvgType]
IF FastAvg CROSSES OVER SlowAvg THEN
AvgCross = 1 //1 = bullish crossing
DayCount = 0
ELSIF FastAvg CROSSES UNDER SlowAvg THEN
AvgCross = -1 //-1 = Bearish crossing
DayCount = 0
ENDIF
IF AvgCross = 1 THEN
DayCount = DayCount + 1 //Increment counter at each new bullish candlestick
DRAWARROWUP(barindex, high + Offset) COLOURED(50,205,50)
IF DayCount = MaxDays THEN //Stop counting and drawing arrows after MAXDAYS have elapsed
DayCount = 0
AvgCross = 0
ENDIF
ELSIF AvgCross = -1 THEN
DayCount = DayCount + 1 //Increment counter at each new bearish candlestick
DRAWARROWDOWN(barindex, low - Offset) COLOURED(255,0,0)
IF DayCount = MaxDays THEN //Stop counting and drawing arrows after MAXDAYS have elapsed
DayCount = 0
AvgCross = 0
ENDIF
ENDIF
RETURN