rfresh1011
New member
My script is below. I guess I don't understand how the 'within 3 bars' actually works.
I'm trying to use this script in Scan to display stocks whose MACD().value crosses up MACD().avg within the last 3 bars with MACD().value below 0. The script just isn't catching those parameters. I see the cross over above 0 and within the last 10 or 20 bars. I just don't know what I am doing wrong. Thanks for any help.
I'm trying to use this script in Scan to display stocks whose MACD().value crosses up MACD().avg within the last 3 bars with MACD().value below 0. The script just isn't catching those parameters. I see the cross over above 0 and within the last 10 or 20 bars. I just don't know what I am doing wrong. Thanks for any help.
Code:
def MACDHighest = Highest(MACD().value);
def MACDLowest = Lowest(MACD().value);
def MACDRangeWidth = MACDHighest - MACDLowest;
def RangeTenthChunks = MACDRangeWidth/10;
def NearZeroZoneUpper = 0 + RangeTenthChunks;
def NearZeroZoneLower = 0 - RangeTenthChunks;
plot bullishCrossover = if MACD().value crosses above MACD().avg within 5 bars
#and MACD().value < NearZeroZoneUpper
#and MACD().value > NearZeroZoneLower within 3 bars
and MACD().value < 0 within 5 bars
then 1 else 0;
#plot bearishCrossover = if MACD().value crosses below MACD().avg and MACD().value <= NearZeroZoneUpper and MACD().value >= NearZeroZoneLower then 1 else 0;