Hi All,
I'm having a strange issue when I want to combine 2 very simple conditions. In logical terms I want "show me the highest bar number of this pattern but not past xxx bar number. Each condition works fine on its own but when I combine the two conditions, nada. I included troubleshooting bubbles which shows everything is working as it should yet the combined condition def DispLowBN = bn == highestall(DispLow) and !BnPastCross ; just won't work. Odd. Any thoughts for you super smart folks?
I'm having a strange issue when I want to combine 2 very simple conditions. In logical terms I want "show me the highest bar number of this pattern but not past xxx bar number. Each condition works fine on its own but when I combine the two conditions, nada. I included troubleshooting bubbles which shows everything is working as it should yet the combined condition def DispLowBN = bn == highestall(DispLow) and !BnPastCross ; just won't work. Odd. Any thoughts for you super smart folks?
Code:
def bn = BarNumber();
def TimeFrame = getaggregationperiod();
def DayOpen = open(period=aggregationperiod.day);
def DayClose = close(period=aggregationperiod.day);
def IsRed = DayClose < DayOpen;
#######################################################################################################
#PIVOT SECTION
input LBPeriod = 10;
#--------------------------------------------------------------
def HH = Highest(high(Period = TimeFrame), LBPeriod);
def marketHigh1 = if HH > HH[-LBPeriod] then HH else HH[-LBPeriod];
def markedHigh1 = high(Period = TimeFrame) == marketHigh1;
def PivotHigh = CompoundValue(1, if IsNaN( markedHigh1) then PivotHigh[1] else if markedHigh1 then high(Period = TimeFrame) else PivotHigh[1], high(Period = TimeFrame));
def LastPivotHigh = if PivotHigh != PivotHigh[1] then PivotHigh[1] else LastPivotHigh[1];
plot PH = PivotHigh;
#--------------------------------------------------------------
def LL = Lowest(low(Period = TimeFrame), LBPeriod);
def marketLow1 = if LL < LL[-LBPeriod] then LL else LL[-LBPeriod];
def markedLow1 = low(Period = TimeFrame) == marketLow1;
def PivotLow = CompoundValue(1, if IsNaN(markedLow1) then PivotLow[1] else if markedLow1 then low(Period = TimeFrame) else PivotLow[1], low(Period = TimeFrame));
plot PL = PivotLow ;
#--------------------------------------------------------------
PH.SetPaintingStrategy(PaintingStrategy.DASHES);
PH.SetDefaultColor(Color.GREEN);
#--------------------------------------------------------------
PL.SetPaintingStrategy(PaintingStrategy.DASHES);
PL.SetDefaultColor(Color.RED);
#######################################################################################################
#PATTERN SECTION
def PHCount = if bn == 1 then 0 else if high == ph then PHCount[1] +1 else PHCount[1];
def PHCountMax = highestall(PHCount);
def PHRevCount = PHCountMax-PHCount +1;
def PHBN = if PHRevCount==1 and PHRevCount[1]==2 then bn else PHBN[1];
def PHCrossbn = if PHRevCount==1 and high crosses above PH then bn else PHCrossbn[1];
def PHPrice = PH;
def LastPHBN = if PHRevCount==2 and PHRevCount[1]==3 then bn else LastPhBN[1];
def LastPHPrice = if bn == LastPHBN then High else LastPHPrice[1];
def LastPHCross = if PHRevCount==2 and high crosses above LastPHPrice then bn else LastPHCross[1];
AddChartBubble(bn==LastPHCross, high, LastPHCross, Color.green,yes);
#Find the pattern
def DispLow = if low < low[1] and low < low[-1] then bn else 0 ;
AddChartBubble(DispLow, low, DispLow, Color.red);
#Exclude bar numbers above xxx
def BnPastCross = BN >= LastPHCross;
AddChartBubble(BnPastCross, low, BnPastCross, Color.white);
#show be the highest DispLow but not past the BN from LastPHCross
def DispLowBN = bn == highestall(DispLow) and !BnPastCross ;
AddChartBubble(DispLowBN, low, DispLowBN, Color.cyan);