I am trying to create a scan for stocks that are in a "squeeze"; as defined by John Carter, this occurs when the Bolinger Bands are so narrow that they are within the Keltner Channel bands. The idea being that a lot of energy is building in these stocks, and a good move could follow.
Here is the code that I have so far. I copied the BB code from another scan, but could not find a similar one for Keltner Channels so I used the code for Keltner Channels that is used to draw it on a graph, however, this creates some errors related to FACTOR and LENGTH not existing in that context.
Shift := FACTOR * ATR(Length);
Avg := EMA(C, Length);
KC_Upper := Avg + Shift;
KC_Lower := Avg - Shift;
BB_LOWER:= "BB(N,P)[LOWER]";
BB_UPPER:= "BB(N,P)[LOWER]";
Cond1:= BB_UPPER < KC_UPPER;
Cond2:= BB_LOWER > KC_LOWER;
Event: Cond1 & Cond2;
Can you help me with this code, please? Thanks!
