MultiCharts Easter Sale has jumped in! Up to 50% off Explore offers
+1 888 340 6572 GET STARTED

PivotHighVSBar

Article/Author: Omega Research Inc., 1995

Download: FUNCTION-PIVOTHIGHVSBAR.ELA

File Includes: Function - PivotHighVSBar

Description: Works just like the "SwingHighBar" Function, returning the number of bars ago of the Swing or Pivot bar, except it allows you to specify a Strengh for both the Right and Left side of the Swing or Pivot Bar.
INPUTS:
Price - specifies which price of the asset of interest is to be used.
LStren - specifies the required number of bars to the Left of the Pivot bar.
RStren - specifies the required number of bars to the Right of the Pivot bar.
Length - specifies the number of trailing bars to consider.

EasyLanguage Code:
INPUTS:  PRICE(NUMERICSERIES), LSTREN(NUMERICSIMPLE), RSTREN(NUMERICSIMPLE), LENGTH(NUMERIC);

VARS: SHBAR(0), MAINLOOP(0), PREPVT(0), PVTBAR(0);

PREPVT = 0;
FOR MAINLOOP = LENGTH-1 DOWNTO RSTREN BEGIN
CONDITION1 = TRUE;
CONDITION2 = TRUE;
SHBAR = PRICE[MAINLOOP];
FOR VALUE1 = MAINLOOP - RSTREN TO MAINLOOP -1 BEGIN
IF SHBAR <= PRICE[VALUE1] THEN
CONDITION1 = FALSE;
END;
IF CONDITION1 THEN BEGIN
FOR VALUE1 = MAINLOOP + 1 TO MAINLOOP + LSTREN BEGIN
IF SHBAR < PRICE[VALUE1] THEN
CONDITION2 = FALSE;
END;
END;
IF CONDITION1 AND CONDITION2 THEN BEGIN
PREPVT = MAINLOOP;
PVTBAR = CURRENTBAR - MAINLOOP;
END;
END;
IF PREPVT <> 0 THEN
PIVOTHIGHVSBAR = CURRENTBAR - PVTBAR
ELSE
PIVOTHIGHVSBAR = -1;