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

Re: [amibroker] Please help - Probelm with variables



PureBytes Links

Trading Reference Links

use static variables.

search help on "static"

----- Original Message ----- 
From: "gosub283" <gosub283@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
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
> 
> 
> 

Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.27/517 - Release Date: 11/3/2006