Dear All
I have make a trend line between HHV and pev HHV, and it works, but when I click the mouse to select bar diffrent from the inititial bar (the second bar from the right in programming), the trend line don't redraw according to the selected bar, but if we check from the text that I use for checking the HHV,HHVbars, all change to the new bar position, so how to refresh and repaint the new trendline to draw/paint with the new HHV and HHV bars changed ?
the code :
// this trendline period not include the most right bar
// the HHVBars1 and HHVBars2 count using zero base, it means count from 0, then 1, then 2 and so on
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} {{OHLCX}} Vol %.0f {{VALUES}}", V ));
HHVPrd1 = Param("Period for HHV1",5,1,100,1);
HHVPrd2 = Param("Period for HHV2",5,1,100,1);
HHV1= Ref(HHV(H,HHVPrd1),-1);
HHVBars1 = Ref(HHVBars(H,HHVPrd1),-1);
CountStart= (HHVBars1+1)* (-1);
HHV2 = Ref(HHV(H,HHVPrd2),-1);
HHV2 = Ref(HHV2,CountStart);
HHVBars2 = Ref(HHVBars(H,HHVPrd2),-1);
HHVBars2 = Ref(HHVBars2,CountStart);
totalbar1=HHVBars1+1;
totalbar2=totalbar1+HHVBars2+1;
text1 = " HHV1: "+ WriteVal(HHV1,1.2)+", HHV2: "+ WriteVal(HHV2,1.2)+", HHVBars1 :"+WriteVal(HHVBars1,1.0)+
", HHVBars2 : "+WriteVal(HHVBars2,1.0)+", HHV_period1 :"+WriteVal(HHVPrd1,1.0)+", HHV_period2 :"+WriteVal(HHVPrd2,1.0);
Plot( Close, "Close", colorDefault, styleBar );
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/32);
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorRGB( 200, 200, 200 ) );
GfxSetBkMode(1); // transparent
GfxTextOut(text1, Status("pxwidth")/2, Status("pxheight")/12 );
x1 = LastValue(barindex()-HHVBars1-1); // BAR KE
y1 = LastValue(HHV1); // NILAI HARGA
x0 = LastValue(BarIndex()-totalbar2); // BAR KE
y0 = LastValue(HHV2); // NILAI KE
Plot( LineArray( x0,y0,x1,y1 ), "Trend line", colorYELLOW, styleThick );
Thanks for helping me to increase my skill programming in Amibroker
Rgds Bob Tanujaya