PureBytes Links
Trading Reference Links
|
Terry,
Thanks very much for that comprehensive suggestion.
I will experiment with you ideas.
Will advise....
Gosu283
Gary
--- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxx> wrote:
>
> Gosub283,
>
> Amibroker is an array processing system. This means the ENTIRE ARRAY is
> determined "all-at-once" and processed just ONCE. There is the loop code
> feature to get around this when/if necessary.
>
> This means you cannot "go back" and change the Buy conditions based upon
> follow-on arrays...because Buy has already been processed from the first
> bar of data to the last. One way around this is to "pre-process" your
> Buy and Sell conditions with dummy arrays and/or some loop code.
>
> However, in your case it might be easier than that. Use the code you
> have, delete the ApplyStop() and simply trigger the Sell condition based
> on how many days since you bought. Since you are using Cross for your
> Buy signal there should not be any duplicate signals...unless the dual
> MA cross you are testing would fall back and re-cross in the 1st 6 days.
>
> //Sell "Days_Till_Sell" since a Buy
> Sell = Ref(Buy,-Days_Till_Sell);
>
> You should test my idea to be sure it works.
>
> Also note: Buy-Sell-Short-Cover are special variables that trigger an
> internal backtest with code that you cannot "see". You can control this
> backtest procedure by writing a "custom backtest procedure", but that is
> often not necessary and overcomplicates things with lower level code.
> However, the feature is there for those that really need it.
>
> PS: I don't see how a staticVar can help this situation. You can set it
> and it will stay the same value until you change it, but it is NOT an
> array (it is a "number", a single value) and it will simply end up with
> the final value of "Days_Till_Sell" all the time...unless you use loop
> code in which case you can use a normal array to store when you are "on
> a buy".
> --
> Terry
>
> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
> Behalf Of gosub283
> Sent: Wednesday, November 01, 2006 09:41
> To: amibroker@xxxxxxxxxxxxxxx
> 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
|