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

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



PureBytes Links

Trading Reference Links

It is easy to understand, if only you READ THE
tutorial section of the guide:

http://www.amibroker.com/guide/h_understandafl.html

All tutorial is must-read.
=================

People are crying for help while in fact
everything you need to read is in the TUTORIAL section
of the guide.
This single short section of the tutorial
http://www.amibroker.com/guide/h_understandafl.html

is absolute must-read and should be read and repeated.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "ian_rosbif" <ian_rosbif@xxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, November 18, 2008 6:52 PM
Subject: [amibroker] Re: What is wrong with these 3 lines of code?


> You're not dumb, it is rather difficult to understand! Using your 
> example and assuming 11 bars in each array:
> Before the 1st statement, auxCrossedIntermed = "00000000000",
> After the 1st statement, auxCrossedIntermed = "00000000010"
> 
> Before the 2nd statement, CrossedIntermed = "00000000000",
> and Ref(CrossedIntermed, -1) = "0000000000"... Amibroker effectivley 
> treats the Ref... part of the statement as if it was a temporary copy 
> of the CrossedIntermed statement taken before the 2nd statement began 
> execution (note that there are only 10 elements in this copy array).
> Changes made to CrossIntermed during the 2nd statement by moving 
> values from AuxCrossedIntermed are not reflected in the copy array. 
> therefore the Ref... clause always copies zero in this scenario.
> 
> I hope this clarifies it, but as I said before, the same thing got me 
> when I first started out with AB...took me a couple of weeks to 
> finally realise what was going on.
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "nunopires2001" <nunopires2001@xxx> 
> wrote:
>>
>> Thanks for the answer.
>> 
>> To be honest, i am feeling really dumb, since i didn't understand 
> the
>> explanation.
>> 
>> Please suppose the following scenario:
>> 
>> Low[9]=950
>> Intermed[9]=970
>> High[9]=1000
>> 
>> auxCrossedIntermed=IIf(Low< Intermed AND High> Intermed,1,0);
>> CrossedIntermed=auxCrossedIntermed OR Ref(CrossedIntermed,-1);
>> 
>> On the bar #10, how will Amibroker evaluate the second formula?
>> During the evaluation, what will be the values for 
> auxCrossedIntermed
>>  and Ref(CrossedIntermed,-1) ?
>> 
>> 
>> Best Regards!
>> 
>> 
>> --- In amibroker@xxxxxxxxxxxxxxx, "ian_rosbif" <ian_rosbif@> wrote:
>> >
>> > 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@> 
>> > 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
> 
> 
> 

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

**** 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/