MP432
Member
Code:
input numBars = 5;
input showLines = yes;
input ShowZigZag = no;
input showValues = yes;
input ShowSignals = no;
input showBarNumbers = no;
input ShowLastPivotTracer = no;
input TrendResistanceStart = 0;
input TrendResistanceEnd = 0;
input TrendSupportStart = 0;
input TrendSupportEnd = 0;
def UserSetResistance = TrendResistanceStart > 0 and TrendResistanceEnd > 0;
def UserSetSupport = TrendSupportStart > 0 and TrendSupportEnd > 0;
def currentHigh = high;
def currentLow = low;
def currentBar = BarNumber();
def PH;
def PL;
def isHigherThanNextBars = fold i = 1 to numBars + 1 with p = 1
while p do currentHigh > GetValue(high, -i);
PH = if UserSetResistance and ( currentBar == TrendResistanceStart or currentBar == TrendResistanceEnd ) then currentHigh else if !UserSetResistance and (currentBar > numBars and currentHigh == Highest(currentHigh, numBars) and isHigherThanNextBars) then currentHigh else Double.NaN;
def isLowerThanNextBars = fold j = 1 to numBars + 1 with q = 1
while q do currentLow < GetValue(low, -j);
PL = if UserSetSupport and ( currentBar == TrendSupportStart or currentBar == TrendSupportEnd ) then currentLow else if !UserSetSupport and (currentBar > numBars and currentLow == Lowest(currentLow, numBars) and isLowerThanNextBars) then currentLow else Double.NaN;
rec PHBar = if UserSetResistance then TrendResistanceEnd else if !IsNaN(PH) then currentBar else PHBar[1];
rec PLBar = if UserSetSupport then TrendSupportEnd else if !IsNaN(PL) then currentBar else PLBar[1];
rec PHL = if !IsNaN(PH) then PH else PHL[1];
rec priorPHBar = if UserSetResistance then TrendResistanceStart else if PHL != PHL[1] then PHBar[1] else priorPHBar[1];
rec PLL = if !IsNaN(PL) then PL else PLL[1];
rec priorPLBar = if UserSetSupport then TrendSupportStart else if PLL != PLL[1] then PLBar[1] else priorPLBar[1];
def isFinalTwoHighPivots = currentBar >= HighestAll(priorPHBar);
def isFinalTwoLowPivots = currentBar >= HighestAll(priorPLBar);
def ResistanceFinishOffset = if isFinalTwoHighPivots then currentBar - PHBar else 0;
def ResistanceStartOffset = if isFinalTwoHighPivots then currentBar - priorPHBar else 0;
def ResistanceSlope = (GetValue(PH, ResistanceFinishOffset) - GetValue(PH, ResistanceStartOffset)) / (PHBar - priorPHBar);
def SupportFinishOffset = if isFinalTwoLowPivots then currentBar - PLBar else 0;
def SupportStartOffset = if isFinalTwoLowPivots then currentBar - priorPLBar else 0;
def SupportSlope = (GetValue(PL, SupportFinishOffset) - GetValue(PL, SupportStartOffset)) / (PLBar - priorPLBar);
rec ResistanceExtend = if currentBar == HighestAll(PHBar) then 1 else ResistanceExtend[1];
rec SupportExtend = if currentBar == HighestAll(PLBar) then 1 else SupportExtend[1];
plot pivotHigh = if
#isFinalTwoHighPivots
ph>0 then PH else Double.NaN;
plot pivotHighLine = if PHL > 0 and isFinalTwoHighPivots then PHL else Double.NaN;
plot ResistanceLine = pivotHigh;
plot ResistanceExtension = if ResistanceExtend then (currentBar - PHBar) * ResistanceSlope + PHL else Double.NaN;
plot pivotLow = if
#isFinalTwoLowPivots
pl>0 then PL else Double.NaN;
plot pivotLowLine = if PLL > 0 and isFinalTwoLowPivots then PLL else Double.NaN;
plot SupportLine = pivotLow;
plot SupportExtension = if SupportExtend then (currentBar - PLBar) * SupportSlope + PLL else Double.NaN;
plot BN = currentBar;
plot PivotDot = if !IsNaN(pivotHigh) then pivotHigh else if !IsNaN(pivotLow) then pivotLow else Double.NaN;
plot BisectLine = if !isNaN(pivotHigh) then pivotHigh else if !isNaN(pivotLow) then pivotLow else double.NaN;
pivotHigh.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
pivotHigh.SetHiding(!showValues);
PivotHigh.SetDefaultColor(Color.Dark_gray);
pivotLow.SetDefaultColor(Color.Dark_gray);
pivotLow.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
pivotLow.SetHiding(!showValues);
ResistanceLine.EnableApproximation();
ResistanceLine.SetDefaultColor(GetColor(7));
ResistanceLine.SetStyle(Curve.SHORT_DASH);
ResistanceExtension.SetStyle(Curve.SHORT_DASH);
ResistanceExtension.SetDefaultColor(GetColor(7));
SupportLine.EnableApproximation();
SupportLine.SetDefaultColor(GetColor(7));
SupportLine.SetStyle(Curve.SHORT_DASH);
SupportExtension.SetDefaultColor(GetColor(7));
SupportExtension.SetStyle(Curve.SHORT_DASH);
pivotHighLine.SetPaintingStrategy(PaintingStrategy.DASHES);
pivotHighLine.SetHiding(!showLines);
pivotLowLine.SetPaintingStrategy(PaintingStrategy.DASHES);
pivotLowLine.SetHiding(!showLines);
BisectLine.EnableApproximation();
BisectLine.SetLineWeight(2);
BisectLine.Sethiding(!ShowZigZag);
BisectLine.setDefaultColor(Color.Dark_Gray);
PivotDot.SetDefaultColor(GetColor(7));
PivotDot.SetPaintingStrategy(PaintingStrategy.POINTS);
PivotDot.SetLineWeight(3);
BN.SetDefaultColor(GetColor(0));
BN.SetHiding(!showBarNumbers);
BN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
Hello All,
I'd Like to simply have a signal where there is an indication of The current pivot high being less than the previous pivot high, and less than the pivot high before that. Vice versa for the the Lows.
example:
Pivothigh[0] < Pivothigh[1] and Pivothigh[0] < Pivothigh[2].
PivotLow[0] > PivotLow[1] and Pivotlow[0] > Pivotlow[2].
For some reason I am hitting a wall trying to simply put an arrow on when these conditions are met.
Any help would be appreciated.