Balance line for 1 to 10 days for Amibroker (AFL)
Copy & Paste Friendly
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} \nOpen %g \nHigh %g
\nLow %g \nClose %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )
) ) );
Plot( C, "", colorWhite , styleCandle );
Bal_Days = Param("Days for Balance Point", 3, 2, 10, 1);
Period_High = HHV(H, Bal_Days);
Period_Low = LLV(L, Bal_Days);
Balance_Point= Period_High - (Period_High - Period_Low)/Bal_Days;
Current_BP = Ref(Balance_Point, -1);
trendcolor = IIf(Balance_Point > Current_BP, colorBrightGreen, colorRed);
Plot(Current_BP, "", trendcolor,styleStaircase|styleNoRescale|styleNoLabel);
Centre=Current_BP;
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = -10;
PlotText("Centre=" + WriteVal(Current_BP,fraction),
SelectedValue(BarIndex()+1)-(numbars/hts),SelectedValue(Current_BP),styleStaircase,styleCloud);
//Visit market<no space>logy.com for unique AFL codes and strategy//