Pivot Point Average AFL help

#1
Hi Seniors,

Please can someone help me with afl for pivot point average. I want it to show up a anyother moving average line with ups and downs. In my afl it just shows up as a straight line.
Thanks in advance

Inspiration :http://www.motivewave.com/studies/pivot_point_average.htm

_SECTION_BEGIN("PPAV");


H1=SelectedValue( TimeFrameGetPrice( "H", inHourly, -1 ));
L1=SelectedValue(TimeFrameGetPrice( "L", inHourly, -1 ));
C1=SelectedValue(TimeFrameGetPrice( "C", inHourly, -1 ));
O1=SelectedValue(TimeFrameGetPrice( "O", inHourly, -1 ));

H2=SelectedValue( TimeFrameGetPrice( "H", inHourly, -2 ));
L2=SelectedValue(TimeFrameGetPrice( "L", inHourly, -2 ));
C2=SelectedValue(TimeFrameGetPrice( "C", inHourly, -2 ));
O2=SelectedValue(TimeFrameGetPrice( "O", inHourly, -2 ));

H3=SelectedValue( TimeFrameGetPrice( "H", inHourly, -3 ));
L3=SelectedValue(TimeFrameGetPrice( "L", inHourly, -3 ));
C3=SelectedValue(TimeFrameGetPrice( "C", inHourly, -3 ));
O3=SelectedValue(TimeFrameGetPrice( "O", inHourly, -3 ));

/*PIVOT Calculation*/
p11 = ( H1 + L1 + O1 + H2 + L2 + O2 + H3 + L3 + O3)/900;
p12 = ( H1 + L1 + C1 + H2 + L2 + C2 + H3 + L3 + C3)/900;


ppav1 = EMA(p11,3);
ppav2 = EMA(p12,3);

Plot (p11,"LHOp",colorTurquoise);
Plot (p12,"LHCl",colorTurquoise);
Plot (ppav1,"PPAVO",colorYellow);
Plot (ppav2,"PPAVCl",colorYellow);



Buy=Cross(p11,ppav1) ;
PlotShapes(shapeUpArrow*Buy,colorYellow);
Sell=Cross(ppav1,p11);
PlotShapes(shapeDownArrow*Sell,colorRed);

Buy=Cross(p12,ppav2) ;
PlotShapes(shapeUpArrow*Buy,colorPink);
Sell=Cross(ppav2,p12);
PlotShapes(shapeDownArrow*Sell,colorDarkRed);



_SECTION_END();
 

KelvinHand

Well-Known Member
#2
Hi Seniors,

Please can someone help me with afl for pivot point average. I want it to show up a anyother moving average line with ups and downs. In my afl it just shows up as a straight line.
Thanks in advance

Inspiration :http://www.motivewave.com/studies/pivot_point_average.htm

_SECTION_BEGIN("PPAV");


H1=SelectedValue( TimeFrameGetPrice( "H", inHourly, -1 ));
L1=SelectedValue(TimeFrameGetPrice( "L", inHourly, -1 ));
C1=SelectedValue(TimeFrameGetPrice( "C", inHourly, -1 ));
O1=SelectedValue(TimeFrameGetPrice( "O", inHourly, -1 ));

H2=SelectedValue( TimeFrameGetPrice( "H", inHourly, -2 ));
L2=SelectedValue(TimeFrameGetPrice( "L", inHourly, -2 ));
C2=SelectedValue(TimeFrameGetPrice( "C", inHourly, -2 ));
O2=SelectedValue(TimeFrameGetPrice( "O", inHourly, -2 ));

H3=SelectedValue( TimeFrameGetPrice( "H", inHourly, -3 ));
L3=SelectedValue(TimeFrameGetPrice( "L", inHourly, -3 ));
C3=SelectedValue(TimeFrameGetPrice( "C", inHourly, -3 ));
O3=SelectedValue(TimeFrameGetPrice( "O", inHourly, -3 ));

/*PIVOT Calculation*/
p11 = ( H1 + L1 + O1 + H2 + L2 + O2 + H3 + L3 + O3)/900;
p12 = ( H1 + L1 + C1 + H2 + L2 + C2 + H3 + L3 + C3)/900;


ppav1 = EMA(p11,3);
ppav2 = EMA(p12,3);

Plot (p11,"LHOp",colorTurquoise);
Plot (p12,"LHCl",colorTurquoise);
Plot (ppav1,"PPAVO",colorYellow);
Plot (ppav2,"PPAVCl",colorYellow);



Buy=Cross(p11,ppav1) ;
PlotShapes(shapeUpArrow*Buy,colorYellow);
Sell=Cross(ppav1,p11);
PlotShapes(shapeDownArrow*Sell,colorRed);

Buy=Cross(p12,ppav2) ;
PlotShapes(shapeUpArrow*Buy,colorPink);
Sell=Cross(ppav2,p12);
PlotShapes(shapeDownArrow*Sell,colorDarkRed);



_SECTION_END();
First, did you do the AFL as according to the website given and tested working ?

Simple thing not working and you go and do complex stuff.
 
#3
Kelvin ji,
That website does not give aamibroker afl but only gives underlying formula. The afl I have attempeted shows correct values..it is only that it seems to show up as straight line and not like anyother ma/ema which has peaks and troughs. Is it because of some scaling parameter or something i am missing

Thanks
 

KelvinHand

Well-Known Member
#4
Kelvin ji,
That website does not give aamibroker afl but only gives underlying formula. The afl I have attempeted shows correct values..it is only that it seems to show up as straight line and not like anyother ma/ema which has peaks and troughs. Is it because of some scaling parameter or something i am missing

Thanks
You need to understand the concept right then you can write the right AFL.
Your AFL attempted shows correct values, then where is the AFL ?

The motivewave stated only use MA() not EMA()


PHP:
//-- Pivot Point Average from MotiveWave

prevH = high[index-1];
prevL = low[index-1];
prevC = close[index-1];
pp = (prevH + prevL + prevC) / 3;
if (priceM == 1) pp = (prevH + prevL + prevC) / 3;
if (priceM == 2) pp = (prevH + prevL + prevC + open) / 4;
if (priceM == 3) pp = (prevH + prevL + open) / 3;
plot1: pp;
plot2: ppav = ma(method, period, pp);
//Signals
sell = crossedAbove(PP, PPAV);
buy = crossedBelow(PP, PPAV);
PHP:
//------------- To AmiWave
prevH = Ref(H,-1);
prevL = Ref(L,-1);
prevC = Ref(C,-1);
pp = (prevH + prevL + prevC) / 3;

priceM=1;
period=3;

if (priceM == 1) pp = (prevH + prevL + prevC) / 3;
if (priceM == 2) pp = (prevH + prevL + prevC + open) / 4;
if (priceM == 3) pp = (prevH + prevL + open) / 3;

ppav = ma(pp, period);

Plot(pp, "pp", colorWhite);
Plot(ppav, "ppav", colorRed);

//Signals
sell = cross(PP, PPAV);
buy = cross(PPAV, PP);
PlotShapes(shapeUpArrow*Buy,colorPink);
PlotShapes(shapeDownArrow*Sell,colorDarkRed);

Code:
/*PIVOT Calculation*/
p11 = ( H1 + L1 + O1 + H2 + L2 + O2 + H3 + L3 + O3)/900;
p12 = ( H1 + L1 + C1 + H2 + L2 + C2 + H3 + L3 + C3)/900;
1. Why above Divide by 900 ?
2. Motivewave is using Current Open, not Previous Open.
3. Why use SelectedValue() on all TimeFrameGetPrice() ?
What the purpose of SelectedValue() ? check the help guide from explanation.
This cause your program to select the single value at the cursor pointed to, so 1 value is given to your ema.
so straight line.
 
Last edited:
#7
You need to understand the concept right then you can write the right AFL.
Your AFL attempted shows correct values, then where is the AFL ?

The motivewave stated only use MA() not EMA()


PHP:
//-- Pivot Point Average from MotiveWave

prevH = high[index-1];
prevL = low[index-1];
prevC = close[index-1];
pp = (prevH + prevL + prevC) / 3;
if (priceM == 1) pp = (prevH + prevL + prevC) / 3;
if (priceM == 2) pp = (prevH + prevL + prevC + open) / 4;
if (priceM == 3) pp = (prevH + prevL + open) / 3;
plot1: pp;
plot2: ppav = ma(method, period, pp);
//Signals
sell = crossedAbove(PP, PPAV);
buy = crossedBelow(PP, PPAV);
PHP:
//------------- To AmiWave
prevH = Ref(H,-1);
prevL = Ref(L,-1);
prevC = Ref(C,-1);
pp = (prevH + prevL + prevC) / 3;

priceM=1;
period=3;

if (priceM == 1) pp = (prevH + prevL + prevC) / 3;
if (priceM == 2) pp = (prevH + prevL + prevC + open) / 4;
if (priceM == 3) pp = (prevH + prevL + open) / 3;

ppav = ma(pp, period);

Plot(pp, "pp", colorWhite);
Plot(ppav, "ppav", colorRed);

//Signals
sell = cross(PP, PPAV);
buy = cross(PPAV, PP);
PlotShapes(shapeUpArrow*Buy,colorPink);
PlotShapes(shapeDownArrow*Sell,colorDarkRed);

Code:
/*PIVOT Calculation*/
p11 = ( H1 + L1 + O1 + H2 + L2 + O2 + H3 + L3 + O3)/900;
p12 = ( H1 + L1 + C1 + H2 + L2 + C2 + H3 + L3 + C3)/900;
1. Why above Divide by 900 ?
2. Motivewave is using Current Open, not Previous Open.
3. Why use SelectedValue() on all TimeFrameGetPrice() ?
What the purpose of SelectedValue() ?
THanks Kelvin ji.. Will check ..
 

KelvinHand

Well-Known Member
#8
THanks Kelvin ji.. Will check ..
Once I get the basic worked.
Then will consider the other timeframe.
I will wanted to do minor modification on code to get the lesser error.

xH = TimeFrameGetPrice( H, inHourly, 0);
xL = TimeFrameGetPrice( L, inHourly, 0);
xC = TimeFrameGetPrice( C, inHourly, 0);
xO = TimeFrameGetPrice( H, inHourly, 0);

H1 = Ref(xH,-1);
L1 = Ref(xL,-1);
C1 = Ref(xC,-1);

H2 = Ref(xH,-2);
L2 = Ref(xL,-2);
C2 = Ref(xC,-2);

H3 = Ref(xH,-3);
L3 = Ref(xL,-3);
C3 = Ref(xC,-3);



pp1 = (H1 + L1 + C1) / 3;
pp2 = (H2 + L2 + C2) / 3;
pp3 = (H3 + L3 + C3) / 3;

//priceM=1;
period=3;

//if (priceM == 1) pp1 = (H1 + L1 + C1) / 3;
//if (priceM == 2) pp1 = (H1 + L1 + C1 + open) / 4;
//if (priceM == 3) pp1 = (H1 + L1 + open) / 3;

ppav1 = ma(pp1, period);
ppav2 = ma(pp2, period);
ppav3 = ma(pp3, period);

Plot(pp1, "pp1", colorWhite);
Plot(ppav1, "ppav1", colorRed);

Plot(pp2, "pp2", colorGrey50);
Plot(ppav2, "ppav2", colorLime);


//Signals
sell = cross(PP1, PPAV1);
buy = cross(PPAV1, PP1);
PlotShapes(shapeUpArrow*Buy,colorPink);
PlotShapes(shapeDownArrow*Sell,colorDarkRed);


Then test it on hourly, to make sure you get the same result as motivewave first then other timeframe.

Note:: The above code are conceptual only
 
Last edited:
#9
Once I get the basic worked.
Then will consider the other timeframe.
I will wanted to do minor modification on code to get the lesser error.

xH = TimeFrameGetPrice( H, inHourly, 0);
xL = TimeFrameGetPrice( L, inHourly, 0);
xC = TimeFrameGetPrice( C, inHourly, 0);
xO = TimeFrameGetPrice( H, inHourly, 0);

H1 = Ref(xH,-1);
L1 = Ref(xL,-1);
C1 = Ref(xC,-1);

H2 = Ref(xH,-2);
L2 = Ref(xL,-2);
C2 = Ref(xC,-2);

H3 = Ref(xH,-3);
L3 = Ref(xL,-3);
C3 = Ref(xC,-3);



pp1 = (H1 + L1 + C1) / 3;
pp2 = (H2 + L2 + C2) / 3;
pp3 = (H3 + L3 + C3) / 3;

//priceM=1;
period=3;

//if (priceM == 1) pp1 = (H1 + L1 + C1) / 3;
//if (priceM == 2) pp1 = (H1 + L1 + C1 + open) / 4;
//if (priceM == 3) pp1 = (H1 + L1 + open) / 3;

ppav1 = ma(pp1, period);
ppav2 = ma(pp2, period);
ppav3 = ma(pp3, period);

Plot(pp1, "pp1", colorWhite);
Plot(ppav1, "ppav1", colorRed);

Plot(pp2, "pp2", colorGrey50);
Plot(ppav2, "ppav2", colorLime);


//Signals
sell = cross(PP1, PPAV1);
buy = cross(PPAV1, PP1);
PlotShapes(shapeUpArrow*Buy,colorPink);
PlotShapes(shapeDownArrow*Sell,colorDarkRed);


Then test it on hourly, to make sure you get the same result as motivewave first then other timeframe.

Note:: The above code are conceptual only
Many thanks Kevin ji.. It really works as I want... I will rename my system after you ;-)
 

Similar threads