Count the number of gap up days

STB

Member
Anyone know how to count the number of arrow signals this indicator creates?

I'm looking to see how many times a certain percent gap up occurs without having to actual count the arrows manually.
It would just post a label like below saying 20 gap up arrows.

Thanks for any help!

Code:
input  gapPercent = 1;
def OpenGapPercent = Round((open - close[1]) / close[1] * 100 , 2) ;


AddLabel(yes, Concat("Gap Up " + "% ", OpenGapPercent  ), Color.red );

plot GapUp = open > close[1] && open > high[1] && OpenGapPercent > gapPercent;
GapUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);


p0n8mjU.jpg
 

Pensar

Active member
VIP
@STB Adding this code should give you the count of all arrows currently shown on the chart -
Code:
def count = TotalSum(GapUp);
AddLabel(1,"Gap Count = " + count, color.white);
 
  • Like
Reactions: STB

STB

Member
@Pensar one last question, would you know how to add a label for the last gap up day and the current gap day.
For example if the last gap up day was a week ago it would have that days volume and also the current days gap up volume.

Thanks
 

Welkin

Active member
VIP
@Pensar one last question, would you know how to add a label for the last gap up day and the current gap day.
For example if the last gap up day was a week ago it would have that days volume and also the current days gap up volume.

Thanks
like this?
Code:
input  gapPercent = 1;
def bn = barnumber();
def OpenGapPercent = Round((open - close[1]) / close[1] * 100 , 2) ;
AddLabel(yes, "Gap Up " + "% "+OpenGapPercent, Color.red );
plot GapUp = open > close[1] && open > high[1] && OpenGapPercent > gapPercent;
GapUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
def gapbn = if GapUp then bn else gapbn[1];
def gapvol = if GapUp then volume else gapvol[1];
def gapbn2 = if gapbn != gapbn[1] then gapbn[1] else gapbn2[1];
def gapvol2 = if gapvol != gapvol[1] then gapvol[1] else gapvol2[1];
AddLabel(1,AbsValue(bn-gapbn2)+" Days Ago | "+gapvol2+" Vol", Color.GRAY);
AddLabel(1,AbsValue(bn-gapbn)+" Days Ago | "+gapvol+" Vol", Color.WHITE);
 

Similar threads

Top