Hi, I'm trying to create a gap up or gap down scanner for the daily TF to scan each morning at the market opens. Below is my first draft of this script. The calculations i use don't seem correct; like gap = 2% and the offset 0.5%. If anyone has a better idea what gap percentage to use or how my calculation could be better calculated, i would really appreciate your help! Thanks.
I searched our forum and couldn't find a gapper script. The only one close is the Blastoff script by @BenTen.
I searched our forum and couldn't find a gapper script. The only one close is the Blastoff script by @BenTen.
Code:
# # Gap and offset in percent
input gap = 2;
input offset = 0.5;
def dailyOpen = open(period = AggregationPeriod.DAY);
def gapUpCondition = (dailyOpen - high(period = AggregationPeriod.DAY)[1]) / dailyOpen * 100 > gap;
def gapDownCondition = (low(period = AggregationPeriod.DAY)[1] - dailyOpen) / low(period = AggregationPeriod.DAY)[1] * 100 > gap;
#AddChartBubble(dailyOpen, high, "O " + round(dailyOpen,1), Color.WHITE);
#AddChartBubble(gapUpCondition, high, "G " + gapUpCondition, Color.WHITE);
plot UpArrow = gapUpCondition and high > dailyOpen + offset;
UpArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
UpArrow.SetDefaultColor(Color.YELLOW);
UpArrow.SetLineWeight(3);
#AddChartBubble(dailyOpen, low, "O " + round(dailyOpen,1), Color.WHITE);
#AddChartBubble(gapDownCondition, low, "G " + gapDownCondition, Color.WHITE);
plot DownArrow = gapDownCondition and low < dailyOpen + offset;
DownArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
DownArrow.SetDefaultColor(Color.YELLOW);
DownArrow.SetLineWeight(3);