Hi,
Are you trying use "...OR Ref(CrossedIntermed,-1);" to get the cross 
to persist in CrossedIntermed? In other words, if the cross occurs at 
11:45, the following 15 elements of Crossintermed should be "1" until 
12:01, when they should then all have "666" in them?

In which case, the problem lies with the "circular" nature of:
>>CrossedIntermed=auxCrossedIntermed OR Ref(CrossedIntermed,-1);

auxCrossedIntermed will have a combination of 1s & 0s in it, but 
these aren't actually "moved" to Crossedintermed until the statement 
hase been fully evaluated. Therefore Ref(Crossedintermed, -1) will 
always evaluate to 0 at the time it's executed, even though the 1 
appears in the array element representing the cross event after the 
statement has been executed.

This is something that drove me mad before I cottoned onto it.
maybe this would work:

// initialise final values
CrossedIntermed=IIf(TimeNum()>120000, 666, 0);
// set cross events
auxCrossedIntermed=IIf(Low< Intermed AND High> Intermed, 1, 0);
// cross persists for whole day after it occurs once
auxCrossedIntermed = Flip(auxCrossedIntermed, True==False);
// finalise values
CrossedIntermed=IIf(TimeNum()>120000, 666, auxCrossedIntermed);

If you want the "1" to persist after midday, change the last 
statement to:
CrossedIntermed=IIf(auxCrossedIntermed, auxCrossedIntermed, 
CrossedIntermed);


--- In [email protected], "nunopires2001" <[EMAIL PROTECTED]> 
wrote:
>
> Hello,
> 
> After a encouraging start with Amibroker, i am realizing that 
writing
> code on AFL is not all that simple...
> 
> Anyone can explain me what is wrong with these lines of code?
> 
>     CrossedIntermed=0;
>     auxCrossedIntermed=IIf(Low< Intermed AND High> Intermed,1,0);
>     CrossedIntermed=auxCrossedIntermed OR Ref(CrossedIntermed,-1);
>     CrossedIntermed=IIf(TimeNum()>120000,666,CrossedIntermed);
> 
> I am working with intraday, 1min data. The market opens at 110000 
and
> closes at 193000.
> 
> I just want to check the CrossedIntermed Value after 12.00h, and the
> value returned should be:
> -> 1: If the security crossed Intermed
> -> 0: Otherwise
> -> 666: If TimeNum()>120000
> 
> 
> Thanks alot!
>


Reply via email to