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

RE: [amibroker] Only long or short and no repeated signals



PureBytes Links

Trading Reference Links

Hi Steve,

 

now it works fine, i have added the bar condition. The first signal is now a buy or short signal.

 

yestWrsi = Ref(RSI(5),-1);

wrsi = RSI(5);

 

Buy = WRSI > 40 AND yestWRSI < 40;

Sell = Cross(70,WRSI);

Short = WRSI < 60 AND yestWRSI > 60;

Cover = Cross(WRSI,30);

 

inLong = Ref(Flip(Buy,Sell),-1); inShort = Ref(Flip(Short,Cover),-1);

inNothing = inLong==0 AND inShort==0;

 

 

Buy = Buy AND NOT inlong AND NOT inshort;

Short = Short AND NOT inlong AND NOT inshort;

Sell = Sell AND BarsSince(Buy)>BarsSince(Sell);

Cover = Cover AND BarsSince(Short)>BarsSince(Cover);

 

 

Buy = ExRem( Buy, Sell );

Sell = ExRem( Sell, Buy );

Short = ExRem( Short, Cover );

Cover = ExRem( Cover, Short );

 

 

 

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

Best regards

 

Thomas

www.tradingbasis.com

support@xxxxxxxxxxxxxxxx

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

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Steve Dugas
Sent: Tuesday, January 10, 2006 6:13 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Only long or short and no repeated signals

 

Well, I can see that code will give an "undefined" error - try this one instead:

 

Cover = Cross(WRSI,30);

Sell = Cross(70,WRSI);

Buy = WRSI > 40 AND yestWRSI < 40;

Short = WRSI < 60 AND yestWRSI > 60;

Buy = Buy AND BarsSince( Cover) < BarsSince( Short );

Short = Short AND BarsSince( Sell ) < BarsSince( Buy );

Buy = ExRem( Buy, Sell );

 

Sell = ExRem( Sell, Buy );

 

Short = ExRem( Short, Cover );

 

Cover = ExRem( Cover, Short );

 

Another thought might be to try running the code through the Equity() function - it will modify Buy/Sell/Short/Cover arrays similar to backtester does but I guess you would have to inspect them to see if results are what you want. Just throwing out ideas here...

 

Steve

 

 

----- Original Message -----

From: Steve Dugas

Sent: Tuesday, January 10, 2006 11:24 AM

Subject: Re: [amibroker] Only long or short and no repeated signals

 

Hi Thomas,

 

OK, I get it now - I guess your problem would arise if:

 

1. You were long, and then got a short sig before a sell sig, or

2. You were short, and then got a buy sig before a cover sig.

 

Off the top of my head, you could try something like:

 

Cover = Cross(WRSI,30);

Sell = Cross(70,WRSI);

Buy = WRSI > 40 AND yestWRSI < 40

 AND BarsSince( Cover) < BarsSince( Short );

Short = WRSI < 60 AND yestWRSI > 60

 AND BarsSince( Sell ) < BarsSince( Buy );

Buy = ExRem( Buy, Sell );

 

Sell = ExRem( Sell, Buy );

 

Short = ExRem( Short, Cover );

 

Cover = ExRem( Cover, Short );

 

Steve

 

----- Original Message -----

From: Tradingbasis

Sent: Tuesday, January 10, 2006 5:12 AM

Subject: RE: [amibroker] Only long or short and no repeated signals

 

Hi Steve,

 

i have tried, but it doesn’t work, because i have different buy, cover, sell, short rules. Buy and cover is not the same on my system.

 

You can view it by using your modified code on the price chart.

Probably i have to write it into my loop. L

 

 

WRSI = RSI( 14);

 

yestWRSI = Ref( WRSI, -1 );

 

Buy = WRSI > 40 AND yestWRSI < 40;

Short = WRSI < 60 AND yestWRSI > 60;

Cover = Cross(WRSI,30);

Sell = Cross(70,WRSI);

 

Buy = ExRem( Buy, Sell );

 

Sell = ExRem( Sell, Buy );

 

Short = ExRem( Short, Cover );

 

Cover = ExRem( Cover, Short );

 

// make short/cover negative so not hidden behind buy/sell

 

Short = IIf( Short, -1, 0 );

Cover = IIf( Cover, -1, 0 );

 

 

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

Best regards

 

Thomas

www.tradingbasis.com

support@xxxxxxxxxxxxxxxx

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

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Steve Dugas
Sent: Monday, January 09, 2006 11:32 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Only long or short and no repeated signals

 

Hi Thomas,

 

This seems to work fine - plot code as is, then uncomment "exrem" lines and plot in seperate pane below original - you can see how all redundant signals were removed by exrem.

 

Steve

 

WRSI = RSI( 14);

yestWRSI = Ref( WRSI, -1 );

Buy = Cover = WRSI > 40 AND yestWRSI < 40;

Short = Sell = WRSI < 60 AND yestWRSI > 60;

//Buy = ExRem( Buy, Sell );

//Sell = ExRem( Sell, Buy );

//Short = ExRem( Short, Cover );

//Cover = ExRem( Cover, Short );

// make short/cover negative so not hidden behind buy/sell

Short = IIf( Short, -1, 0 );

Cover = IIf( Cover, -1, 0 );

Plot( Buy, "buy", colorBrightGreen, styleLine );

Plot( Sell, "sell", colorRose, styleLine );

Plot( Short, "short", colorRed, styleLine );

Plot( Cover, "cover", colorGreen, styleLine );

----- Original Message -----

From: Tradingbasis

Sent: Monday, January 09, 2006 3:52 PM

Subject: [amibroker] Only long or short and no repeated signals

 

Hello,

 

i have some troubles to build a system that goes only long or short (not both at the same time) and only

goes long when no long position is opened and only short if no short position is open.

Can someone help ?

I have tried with the exrem but have not got it to work successfully. I want to display the signals graphically.

 

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

Best regards

 

Thomas

www.tradingbasis.com

support@xxxxxxxxxxxxxxxx

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

 



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





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS