[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Can be coded without loop?



PureBytes Links

Trading Reference Links

hi 
I think this may do what you are after or at least give you some 
other ideas, I have copied it straight from the AFL library so can 
claim no credit for it 
Hope it helps
Mark

/* SUPPORT AND RESISTANCE */
/* AFL Code - Prakash Shenoi */

LB= Param("Look Back Periods",10,1,30,1);
R=ValueWhen(Cross(MA(C,LB),C),HHV(H,LB),1);
S=ValueWhen(Cross(C,MA(C,LB)),LLV(L,LB),1);
Color=IIf(O>C,colorBlack,colorYellow);
Plot (R,"Resz",22,8+16);
Plot (s,"Supp",19,8+16);
Plot (C,"Close",color,64,32);
GraphXSpace=4;



--- In amibroker@xxxxxxxxxxxxxxx, "John R" <jr-ta@xxx> wrote:
>
> Hi
> 
> I wanted to plot some horizontal lines extending from successive 
hi and lo
> pivot points. The code below illustrates the intention but does 
not work as
> I guess IIF is evaluating the argument arrays prior to execution.
> 
> Wondering if there is a way to do this without looping? Basically 
need
> method to propagate same value thru array until condition changes 
then
> propagate next value...
> 
> John
> 
> 8<
> /* draw horizontal lines at hi & lo pivot points*/
> //P = ParamField("Price field",-1);
> p=Close;
> Hipiv = IIf(P<Ref(P,-1) AND (Ref(P,-1)>Ref(P,-2)),1,0);
> Lopiv = IIf(P>Ref(P,-1) AND (Ref(P,-1)<Ref(P,-2)),1,0);
> Hline=0;
> hline=IIf(hipiv==1,Ref(p,-1),Ref(hline,-1));
> Plot (C,"close",colorBlack);
> Plot (Hline,"hline",colorRed);
> 8<
> /
>