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

[amibroker] Re: What is wrong with these 3 lines of code?



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "nunopires2001" <nunopires2001@xxx> 
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!
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/