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

Re: holdtill() problem with flip()



PureBytes Links

Trading Reference Links

Hi,
I appologise that my previous example may have been misleading 
because the valuewhen() statement looks as if it could do the job.

I wont bore you with all the reasons but one problem is that the 
second value may be coincidentally the same as the first and I still 
need to know that its related to a new condition. I dont have a 
second array to use in FLIP(). The condition is only 1 on the day it 
occurs and reverts to 0 for other days.

Tomasz's FLIP()example would be fine if it worked on one array but 
not two eg

array1 000000010000100000
result 000000011111000000

Using cum()can work in some cases but not for my purpose because I 
want to reset to 0 or 1 each time condition occurs. 
result 00000001111122222222333




--- In amibroker@xxxx, "farriners2002" <dre@xxxx> wrote:
> Hi,
> Just returned to find all those great suggestions which I will work 
on. many thanks for all the help.
> 
> I looked at flip(array1,array2) but in my case I want it to work 
with the same array not a different one.ie I want to hold a value 
from the first occurence until the second occurence of the same 
condition.



> 
> eg 
> 
> Cond=high>ref(high,-1); /* the condition being monitored is high 
today greater than high yesterday */
> val=valuewhen(cond,high,1); /* the value of high when condition 
occurs */
> then something like flip(cond,cond); or holdtill(cond,val); /* a 
way to keep the last value of high constant until the condition 
occurs again, then change to the new value and hold again until etc */
> 
> Maybe I'm missing an obvious way to do this.
> Ps to the person who suggested I learn AFL, this is what I am 
trying to do with all your help.
> Regards Don.