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

Re: [amibroker] Sigma Bands



PureBytes Links

Trading Reference Links

Hello,

You should simply use max loss stop.

Buy = Cross(C,bbandtop(c,20,2));
sell= 0;

ApplyStop(stoptypeprofit,stopmodepercent,5,true);
ApplyStop(stoptypeloss, stopmodepoint, BuyPrice - L, true ); // stop is at the level of LOW price of buy bar

If you don't want to use ApplyStop (for some strange reason :-)) you can loop
to implement your own stops directly in the code as shown in the bottom of
http://www.amibroker.com/guide/whatsnew.html

/* a sample low-level implementation of Profit-target stop in AFL: */
Buy = Cross( MACD(), Signal() );

priceatbuy=0;

for( i = 0; i < BarCount; i++ )
{
     if( priceatbuy == 0 && Buy[ i ] ) 
     priceatbuy = BuyPrice[ i ];

     if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy )
     {
       Sell[ i ] = 1;
       SellPrice[ i ] = 1.1 * priceatbuy;
       priceatbuy = 0;
     }
     else
       Sell[ i ] = 0;
}


Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "marmal417" <marmal@xxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, February 12, 2004 1:01 PM
Subject: [amibroker] Re: Reference first signal


> Thanks. With this method I get a new buy signal every time the close 
> is inside the bands and then outside again.
> So how would I write if I want no new buy signal until either a sell 
> signal OR a profitstop exit? Something like this?
> 
> Buy = Cross(C,bbandtop(c,20,2));
> sell= L<valuewhen(buy,low,1);
> 
> applystop(stoptypeprofit,stopmodepercent,5,true);
> 
> And then how do I write no new buy signals until sell is true OR 
> profitstop exit is true using ExRem? In other words how can I 
> reference a stop using exrem?
> 
> Regards,
> Martin
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> wrote:
> > Why not use this to get a unique signal instead of >
> > 
> > Buy = Cross(C,bbandtop(c,20,2));
> > 
> > Cheers,
> > Graham
> > http://e-wire.net.au/~eb_kavan/
> > 
> > -----Original Message-----
> > From: marmal417 [mailto:marmal@x...] 
> > Sent: Thursday, 12 February 2004 4:44 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Reference first signal
> > 
> > 
> > Hi,
> > 
> > I want to refrence the low of the bar where the first buy signal 
> > occurs. For example:
> > 
> > Buy=C>bbandtop(c,20,2);
> > 
> > I want the low of the first bar where buy is true after a sell 
> > signal. But I can't write:
> > 
> > valuewhen(buy,low,1)
> > 
> > because there may be a bar after the initial buy signal that also 
> > closes above the bollingerband, and then that bar would be 
> > referenced. But I want the FIRST bar when a buy signal occurs, the 
> > one where a position is taken. Hope you understand.
> > 
> > Best regards,
> > Martin
> > 
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > 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
> 
> 
> 
> 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
> 
> 
> 
>  
> 
> 


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/