Of course you can change it, but the code was changing it back to a value from several days ago.

 

--

Terry

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Z.
Sent: Saturday, July 08, 2006 09:06
To: [email protected]
Subject: RE: [amibroker] Re: How do I keep the buyprice while multiple buy signals happen

 

Hello Terry,

 

you can also change the buyprice through afl.

 

 

Best regards

 

Thomas

www.tradingbasis.com

 

 

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Terry
Sent: Friday, July 07, 2006 10:52 PM
To: [email protected]
Subject: RE: [amibroker] Re: How do I keep the buyprice while multiple buy signals happen

Sorry, you can't do what you propose because BuyPrice and Sell Price (and ShortPrice & CoverPrice) are a built-in variables that store the prices you are buying and selling at. These are normally the Open or the Close. If you use them as shown you will get wacko results (because you are shifting the entire array backwards to the Buy date (or the offset of that date).

 

Just use other names (such as MyBuyPrice).

--

Terry

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Z.
Sent: Friday, July 07, 2006 11:37
To: [email protected]
Subject: RE: [amibroker] Re: How do I keep the buyprice while multiple buy signals happen

 

Hi Andre,

 

i have not checked out my code below detailed but it should point you to the right direction. Just a quick modification.

i would also better use the build-in applystop function instead manually stop and profit target.

 

Buy = Cross (MACD(12, 26), Signal(12, 26,9));
BuyPrice = ValueWhen(Ref(Buy,-1),Open);

StopLoss = 0.9*BuyPrice;
ProfitTarget = 1.03*BuyPrice;

Sell = Cross(High,ProfitTarget) OR Cross(StopLoss, Low);
SellPrice = IIf(High>ProfitTarget, ProfitTarget, StopLoss);

Buy
= ExRem(Buy, Sell);
Sell = ExRem
(Sell,Buy);

 

Best regards

 

Thomas

www.tradingbasis.com

 

 

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Andre
Sent: Friday, July 07, 2006 5:24 PM
To: [email protected]
Subject: [amibroker] Re: How do I keep the buyprice while multiple buy signals happen

Thanks Thomas,
I knew about exrem. Thanks to you I realized one new thing: the
recursive nature of the sales signal (which is based on the buy
signal) means that I have to do Exrem several times. I have re-
approached my problem and this code apparently seems to do the trick
I wanted ("buy at MACD crossing, sell at 3% profit or 10% loss"),
but, my gosh it's ugly (3 Exrems)! And I am not sure if logicaly
this is enough. I proved empirically to myself (try stock AXP), that
2 exrems is not enough. Is there a more elegant way to do this?:

-----------------------------------

Buy = Cross (MACD(12, 26), Signal(12, 26,9));
BP = IIf(Buy, Ref(BuyPrice,1), 0);

//Actual BuyPrice [BP] is the Open of the following day

Sell = Cross(High,1.03*ValueWhen(Buy, BP)) OR Cross(0.9*ValueWhen
(Buy , BP), Low);

// NOTE THAT AT THIS POINT I GET FALSE SELL SIGNALS BECAUSE I HAVE
FALSE BUY SIGNALS

Buy = ExRem(Buy, Sell);

// THIS GETS RID OF FIRST WAVE OF FALSE SELLS
// THEN WE RE-CALCULATE ALL BUYS AND SELLS:

BP = IIf(Buy, Ref(BuyPrice,1), 0);
//BuyPrice is the Open of the following day

Sell = Cross(High,1.03*ValueWhen(Buy, BP)) OR Cross(0.9*ValueWhen
(Buy , BP), Low);

Buy = ExRem(Buy, Sell);

// THIS IS NOT ENOUGH. IF THERE HAD BEEN 2 FALSE BUYS BEFORE, SELLS
ARE STILL OFF.

BP = IIf(Buy, Ref(BuyPrice,1), 0);
Sell = Cross(High,1.03*ValueWhen(Buy, BP)) OR Cross(0.9*ValueWhen
(Buy , BP), Low);

Buy = ExRem(Buy, Sell);

// I AM NOT SURE IF I HEREWITH COVERED IT ALL, OR I NEED TO CONTINUE
THIS EXREM GYMNASTICS. IN PRACTICAL TESTS THIS SEEMS TO GIVE ME THE
CORRECT +3% and -10% Trades.

SellPrice = IIf(High>1.03*ValueWhen(Buy, BP), 1.03*ValueWhen(Buy,
BP), 0.9*ValueWhen(Buy, BP));

--- In [EMAIL PROTECTED]ps.com, "Thomas Z." <[EMAIL PROTECTED]> wrote:
>
> Hi Andre,
>
> i think the easiest way would simply be to use the exrem function.
It would
> assure that you only get a new buy after a sell.
>
> SYNTAX exrem( ARRAY1, ARRAY2 )
> RETURNS ARRAY
> FUNCTION removes excessive signals:
> returns 1 on the first occurence of "true" signal in Array1
> then returns 0 until Array2 is true even if there are "true"
signals in
> Array1
> EXAMPLE buy = ExRem( buy, sell );
> sell = ExRem( sell, buy );
>
> Best regards
>
> Thomas
> www.tradingbasis.com <http://www.tradingbasis.com/>
>
>
>
> _____
>
> From: [EMAIL PROTECTED]ps.com [mailto:[EMAIL PROTECTED]ps.com]
On Behalf
> Of Andre
> Sent: Friday, July 07, 2006 9:14 AM
> To: [EMAIL PROTECTED]ps.com
> Subject: [amibroker] How do I keep the buyprice while multiple buy
signals
> happen
>
>
>
> Hello,
>
> This should be the simplest thing and I am simply running in
circles
> with AFL not being able to give me what I want.
> Here's what I want in simple terms:
>
> . Buy on MACD crossing (buy at Open the following day).
> . Sell at 3% profit or at 10% loss.
>
> Period. That's all.
>
> The problem I am having is in "keeping" the purchase price at
hand.
> Yes, I know about "ValueWhen" function, but I can't get it to work
> because I can easily have multiple buy signals before the sell
> occurs and a new Buy gives me a new BuyPrice that throws off all
my
> profit and loss targets.
> Please advise. Thanks,
>
> Andre Perman
>

__._,_.___

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 other support material please check also:
http://www.amibroker.com/support.html






YAHOO! GROUPS LINKS




__,_._,___

Reply via email to