# *done* Alligator/Price Angulation - pls help me fix

198

Hi,

I´m coding just another  chaos indicator  based on "Trading Chaos - 2nd Edition".

Actually I want to draw some Angulation Lines (Jaw+Teeth)/2 from where the price crosses/peaks the alligator to divergence bars (and store the corresponding deviation as points/bar in a buffer)

```      int angbars=0;
double angpnow=0.0,angppast=0.0,anganow=0.0,angapast=0.0;

// bullish divergent bar under alligator and red AO
if(low[bar] < low[bar+1] && close[bar] > (high[bar]+low[bar])/2
&& high[bar] < allimin && AOBuffer[bar] < AOBuffer[bar+1]){

//count bars until price crosses alligator
while(high[bar+angbars] < MathMax(JawsBuffer[bar+angbars],MathMax(LipsBuffer[bar+angbars],TeethBuffer[bar+angbars]))) angbars++;

//get basevalues for angulation of price and alligator
angppast=low[bar+angbars];
angpnow=low[bar];
angapast=(JawsBuffer[bar+angbars]+TeethBuffer[bar+angbars])/2;
anganow=(JawsBuffer[bar]+TeethBuffer[bar])/2;

string patmp="PriceAngle"+string(bar), aatmp="AlligatorAngle"+string(bar);
ObjectCreate(0,patmp,OBJ_TREND,0,time[bar+angbars],angppast,time[bar],angpnow);
ObjectSetInteger(0,patmp,OBJPROP_COLOR,clrYellow);
ObjectCreate(0,aatmp,OBJ_TREND,0,time[bar+angbars],angapast,time[bar],anganow);
ObjectSetInteger(0,aatmp,OBJPROP_COLOR,clrYellow);

AngulationBuffer[bar]=(anganow-angpnow-(angapast-angppast))/angbars;

}```

This is what it looks like

The yellow lines are from the code, but I expected them where I inserted the turquoise ones.

Whats wrong?

edit: forgot the shift, this will do it

```         angapast=NormalizeDouble((JawsBuffer[bar+angbars+InpJawsShift]+TeethBuffer[bar+angbars+InpTeethShift])/2, Digits());
anganow=NormalizeDouble((JawsBuffer[bar+InpJawsShift]+TeethBuffer[bar+InpTeethShift])/2, Digits());```