Rolling pivot afl needed

amitrandive

Well-Known Member
#1
Dear All

Need an AFL for 3 day rolling pivots.

Three-day rolling pivot price = (three-day high + three-day low + close) / 3
Second number = (three-day high + three-day low) / 2
Pivot differential = daily pivot price – second number
Three-day rolling pivot range high = daily pivot price + pivot differential
Three-day rolling pivot range low = daily pivot price – pivot differential

Plotting Three-day rolling pivot range high and Three-day rolling pivot range low.

Thanks in advance for help.
 

sr114

Well-Known Member
#2
Dear All

Need an AFL for 3 day rolling pivots.

Three-day rolling pivot price = (three-day high + three-day low + close) / 3
Second number = (three-day high + three-day low) / 2
Pivot differential = daily pivot price – second number
Three-day rolling pivot range high = daily pivot price + pivot differential
Three-day rolling pivot range low = daily pivot price – pivot differential

Plotting Three-day rolling pivot range high and Three-day rolling pivot range low.

Thanks in advance for help.
what is this 3 day hi and 3 day lo?

average of 3 day hi or the hi recorded in last 3rd day? same for the lo
 

mastermind007

Well-Known Member
#3
Dear All

Need an AFL for 3 day rolling pivots.

Three-day rolling pivot price = (three-day high + three-day low + close) / 3
Second number = (three-day high + three-day low) / 2
Pivot differential = daily pivot price – second number
Three-day rolling pivot range high = daily pivot price + pivot differential
Three-day rolling pivot range low = daily pivot price – pivot differential

Plotting Three-day rolling pivot range high and Three-day rolling pivot range low.

Thanks in advance for help.
Whats this pivot's importance.... I sincerely feel that you, amitrandive, could have written this on your own...

Here is line 1 and line 2 to set the ball rolling, just in case

pvt = (HHV(High, 3) + LLV(L, 3) + Close) / 3;
num = (((HHV(High, 3) + LLV(L, 3)) / 2 );
....

whole thing was easy to start with and remainng few lines are even easier
 
Last edited:

amitrandive

Well-Known Member
#8
Whats this pivot's importance.... I sincerely feel that you, amitrandive, could have written this on your own...

Here is line 1 and line 2 to set the ball rolling, just in case

pvt = (HHV(High, 3) +LLV(L, 3) + Close) / 3;
num = (((HHV(High, 3) + LLV(L, 3)) / 2 );

whole thing was easy to start with and remainng few lines are even easier
MM

Thanks for giving the clue.Seems like a typo in your snippet.

The entire code,

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
TimeFrameSet(inDaily);
H3=HHV(High,3);
L3=LLV(Low,3);
C3=Ref(C,-1);
H1= Ref(H,-1) ;
L1=Ref(L,-1);
C1= Ref(C,-1);
P3=(H3+L3+C3)/3;
P1=(H1+L1+C1)/3;
Num=(H3+L3)/2;
PD=abs(P1-Num);
RPH=P1+PD;
RPL=abs(P1-PD);
TimeFrameRestore();
Plot(TimeFrameExpand(P1,inDaily,expandFirst),"Daily Pivot",colorPink,styleDots);
Plot(TimeFrameExpand(P3,inDaily,expandFirst),"Rolling 3 Daily Pivot",colorAqua,styleDots);
Plot(TimeFrameExpand(RPH,inDaily,expandFirst),"Rolling Pivot High",colorGreen,styleDots);
Plot(TimeFrameExpand(RPL,inDaily,expandFirst),"Rolling Pivot Low",colorRed,styleDots);
Plot(TimeFrameExpand(Num,inDaily,expandFirst),"Rolling Pivot Low",colorYellow,styleDots);


_SECTION_END();
 

mastermind007

Well-Known Member
#9
MM

Thanks for giving the clue.Seems like a typo in your snippet.

The entire code,

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
TimeFrameSet(inDaily);

H3=HHV(High,3);
L3=LLV(Low,3);
[COLOR="Red"]C3=Ref(C,-1);[/COLOR]

H1= Ref(H,-1) ;
L1=Ref(L,-1);
C1= Ref(C,-1);

P3=(H3+L3+C3)/3;
P1=(H1+L1+C1)/3;

Num=(H3+L3)/2;

[COLOR="red"]PD=abs(P1-Num);
RPH=P1+PD;
RPL=abs(P1-PD);[/COLOR]

TimeFrameRestore();

Plot(TimeFrameExpand(P1,inDaily,expandFirst),"Daily Pivot",colorPink,styleDots);
Plot(TimeFrameExpand(P3,inDaily,[COLOR="red"]expandFirst[/COLOR]),"Rolling 3 Daily Pivot",colorAqua,styleDots);
Plot(TimeFrameExpand(RPH,inDaily,[COLOR="red"]expandFirst[/COLOR]),"Rolling Pivot High",colorGreen,styleDots);
Plot(TimeFrameExpand(RPL,inDaily,[COLOR="red"]expandFirst[/COLOR]),"Rolling Pivot Low",colorRed,styleDots);
Plot(TimeFrameExpand(Num,inDaily,[COLOR="red"]expandFirst[/COLOR]),"Rolling Pivot Low",colorYellow,styleDots);

_SECTION_END();
amit,

Yes, you are right. The snippet I had given you did have typo and had HHV instead of LLV. I've corrected my earlier post.

The attempt made by you was very good. Strictly based on the requirements as they were written down in English in post 1, I am pinpointing the erroneous lines by marking them in red with correction is show below in Blue lines...

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
TimeFrameSet(inDaily);

H3=HHV(High,3);
L3=LLV(Low,3);
[COLOR="blue"]C3=Close; /// Not previous Clause [/COLOR]

H1= Ref(H,-1) ;
L1= Ref(L,-1);
C1= Ref(C,-1);

P3=(H3+L3+C3)/3;
P1=(H1+L1+C1)/3;

Num=(H3+L3)/2;

[COLOR="blue"]PD=P1-Num; /// no absolutes
RPH=P1+PD;
RPL=P1-PD; /// no absolutes [/COLOR]

TimeFrameRestore();

Plot(TimeFrameExpand(P1,inDaily,expandFirst),"Daily Pivot",colorPink,styleDots);
Plot(TimeFrameExpand(P3,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling 3 Daily Pivot",colorAqua,styleDots);
Plot(TimeFrameExpand(RPH,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling Pivot High",colorGreen,styleDots);
Plot(TimeFrameExpand(RPL,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling Pivot Low",colorRed,styleDots);
Plot(TimeFrameExpand(Num,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling Pivot Low",colorYellow,styleDots);

_SECTION_END();
 
Last edited:

amitrandive

Well-Known Member
#10
amit,

Yes, you are right. The snippet I had given you did have typo and had HHV instead of LLV. I've corrected my earlier post.

The attempt made by you was very good. Strictly based on the requirements as they were written down in English in post 1, I am pinpointing the erroneous lines by marking them in red with correction is show below in Blue lines...

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
TimeFrameSet(inDaily);

H3=HHV(High,3);
L3=LLV(Low,3);
[COLOR="blue"]C3=Close; /// Not previous Clause [/COLOR]

H1= Ref(H,-1) ;
L1= Ref(L,-1);
C1= Ref(C,-1);

P3=(H3+L3+C3)/3;
P1=(H1+L1+C1)/3;

Num=(H3+L3)/2;

[COLOR="blue"]PD=P3-Num; /// P3 (not P1) and no absolutes
RPH=P3+PD; /// P3 (not P1)  
RPL=P3-PD; /// P3 (not P1) and no absolutes [/COLOR]

TimeFrameRestore();

Plot(TimeFrameExpand(P1,inDaily,expandFirst),"Daily Pivot",colorPink,styleDots);
Plot(TimeFrameExpand(P3,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling 3 Daily Pivot",colorAqua,styleDots);
Plot(TimeFrameExpand(RPH,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling Pivot High",colorGreen,styleDots);
Plot(TimeFrameExpand(RPL,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling Pivot Low",colorRed,styleDots);
Plot(TimeFrameExpand(Num,inDaily,[COLOR="blue"]expandLast[/COLOR]),"Rolling Pivot Low",colorYellow,styleDots);

_SECTION_END();
Here is my version that I had written last night. I did have wrong HHV here so chart was not plotting as expected and hence I kept
fiddling with various time frames ....

Code:
tf = inDaily; // in15Minute * 2
TimeFrameSet(tf);
pvt = (HHV(High, 3) + LLV(Low, 3) + Close) / 3;
num = ((HHV(High, 3) + LLV(Low, 3)) / 2 );
TimeFrameRestore();

pvt = TimeFrameExpand(pvt, tf, expandLast);
num = TimeFrameExpand(num, tf, expandLast);

diff = pvt - num;
pvtHigh = pvt + diff;
pvtLow  = pvt - diff;
Plot(pvt, "3RP", colorBlack, styleThick);
Plot(pvtHigh, "3RH", colorBlue, styleDashed);
Plot(pvtLow , "3RL", colorRed, styleDashed);
MM

I have put absolute value on PD, as the difference comes negative,
With negative values , the Pivot high and pivot low values are reversed.
Also if you check the original formula, RPH and RPL are with respect to Daily Pivot ,hence P1.

Also please explain what is the difference between "Expandfirst" and "Expandlast".
 

Similar threads