| 
 PureBytes Links 
Trading Reference Links 
 | 
Thank you Graham and Tomasz,
The idea of the array shifting all at once explains my dificculty. In 
general, does this mean that if there is an interdependency between 2 
arrays, that is each relies on the other, you would have to use for-
loops to set their values properly? Tomasz, I did read the docs you 
suggested. Any other pointers are greatly appreciated!
Rick
--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
wrote:
> Graham is perfectly correct.
> 
> Rick - you should read:
> http://www.amibroker.com/guide/h_understandafl.html
> 
> Ref shifts entire array at once instead of accessing since array 
elements.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "Graham" <gkavanagh@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Friday, May 07, 2004 3:50 AM
> Subject: RE: [amibroker] Improper code behavior
> 
> 
> > Not certain what you are trying to do, but just looking at your 
code
> > Posopen is 0 to start with, then you assign buy==1 when previous 
posopen is
> > 0. ie buy=1 at second bar. You then tell it that posopen = buy 
which was
> > last determined to be 1, but buy is held back by the original
> > ref(posopen,-1) which was 0. Unless you have another condition to 
break the
> > original buy statement it will always stay at buy1 as you kept 
posopen at 0.
> > I think you would be better with a loop for this
> > posOpen[0] = 0;
> > for(i=1;i<BarCount;i++)
> > { if(posopen[i-1]==0)
> > { Buy[i]=1; posOpen[i]=1;}
> > else
> > { Buy[i]=0; posOpen[i]=0;}
> > }
> > Sell = 0; 
> > Filter=1;
> > AddColumn(BarIndex(), "BarIndex");
> > AddColumn(posOpen, "posOpen");
> > AddColumn(Ref(posOpen, -1), "Ref(posOpen -1)");
> > AddColumn(Sell, "sell");
> > AddColumn(Buy, "buy");
> > 
> > This will give alternating buy values of 0 and 1
> > 
> > But there is another easier way of doing this if you are trying 
to determine
> > if you have an open trade. I just used the buy and sell 
conditions of
> > barindex as a means to test it.
> > 
> > Buy = BarIndex()==BarCount-10;//buy conditions
> > Sell = BarIndex()==BarCount-5;//sell conditions
> > Buy = Flip(Buy,Sell);//holds buy=1 until sell signal
> > 
> > Filter=1;
> > AddColumn(Buy,"B",1);
> > AddColumn(Sell,"S",1);
> > 
> > Hope this is some help, as it was hard to determine what you were 
intending
> > to do.
> > 
> > Cheers,
> > Graham
> > http://e-wire.net.au/~eb_kavan/
> > 
> > -----Original Message-----
> > From: Rick Charon [mailto:rickcharon@x...] 
> > Sent: Friday, May 07, 2004 9:15 AM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Improper code behavior
> > 
> > The following code doesn't work as expected. What am I missing? 
> > Thanks. (The buy flips once, then stays 1, even though Ref
(posOpen, -
> > 1) is 1. 
> > 
> > Filter = 1;
> > 
> > posOpen[0] = 0;
> > 
> > Buy = (Ref(posOpen, -1) == 0); 
> > 
> > posOpen = Buy;
> > 
> > Sell = 0; 
> > 
> > AddColumn(BarIndex(), "BarIndex");
> > 
> > AddColumn(posOpen, "posOpen");
> > 
> > AddColumn(Ref(posOpen, -1), "Ref(posOpen -1)");
> > 
> > AddColumn(Sell, "sell");
> > 
> > AddColumn(Buy, "buy");
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at: 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> >
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links
<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/amibroker/
<*> 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/
 
 |