Try this, assuming you do not get another buy signal within the number of bars to hold, you may need to add exremspan function as well to remove any axcess buy signals

DayBought = valuewhen(Buy, Day());

another way would be to use Hold function


--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com


On 02/11/06, Ara Kaloustian <[EMAIL PROTECTED]> wrote:
use static variables.

search help on "static"

----- Original Message -----
From: "gosub283" <[EMAIL PROTECTED]>
To: < [email protected]>
Sent: Wednesday, November 01, 2006 8:41 AM
Subject: [amibroker] Please help - Probelm with variables


> Hi All,
>
> I have a variable named "Days_Till_Sell" that I want to set every time
> a BUY
> is triggered.
>
> PROBLEM: I need that variable to stay the same value until it is set
> again at the next BUY signal. I use this variable to compute "days
> until sell".
>
> //*********************************************
>
> //Buy logic: Short term trend cross and within first 5 days of the month
> Buy = cross(Ma(c,10),ma(c,30)) and day() < 6
>
> //Save the date value when a BUY is trggered...
> DayBought = Buy * Day()
>
> // Set how many days to hold before selling
> Days_Till_Sell = ((DayBought==1) * 10) + //if bought onday 1, hold for 10
> ((DayBought==2) * 9) +   //if bought onday 2, hold for 9
> ((DayBought==3) * 8) +   //if bought onday 3, hold for 8
> ((DayBought==4) * 7) +   //if bought onday 4, hold for 7
> ((DayBought==5) * 6);    //if bought onday 5, hold for 6
>
> //Sell only on Time based stop ( Further Below)
> Sell = 0;
>
>
> //Sell after n Bars
> ApplyStop(StopTypeNBar, StopModeBars, DaysToSell);
>
>
> //********************************************
>
>
> Problem is that "DayBought" and "DaysToSell" become 'zero' for every day
> other than the BUY day. I need to maintain these arrays with the same
> values
> until I change them at the next BUY.
>
> Struggled for many hours with this :-(
> Any ideas ?
> Any Help is appreciated,
>
> Gosub283
> Calgary
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get 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
>
>
>


Please note that this group is for discussion between users only.

To get 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:[EMAIL PROTECTED]
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

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





__._,_.___

Please note that this group is for discussion between users only.

To get 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





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to