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

RE: [amibroker] AFL - Params



PureBytes Links

Trading Reference Links

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@xxxxxxxxx] 
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@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



 



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/