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

RE: [amibroker] Rather Confused Newbie



PureBytes Links

Trading Reference Links

 

Wayne,

 

Cross is true only on a single day. It is NOT a flag that remains True after the day of the Cross. Odds of all 3 crossing same day (or same bar) is low so I wouldn't be surprised if you never get a Buy signal. Better, when you have multiple conditions, is a simple test like this:

 

Buy = RSI(15) > 50 AND MACD() > Signal() AND EMA(C,5) > EMA(C,20);

 

The only trouble with this is you will get multiple continued Buy signals. You can "correct" these if you wish (back tester handles them just fine) using ExRem with an opposite signal if, for example, any of the signals turn down:

 

Sell = RSI(15) < 50 OR MACD() < Signal() OR EMA(C,5) < EMA(C,20);

Buy = ExRem(Buy,Sell); //Removes extra Buy conditions between first Buy and first Sell.

Sell = ExRem(Sell,Buy); //Same for Sell signals.

 

You could also use some form of barssince() if you really want to use Cross(), but this would get overly complex when the above works.

 

Also, be careful with = and == as your following line of code will fail:

 

Buy=SignalTrue=1 AND Cross(RSI(15),50) OR Cross(MACD(),Signal()) OR Cross(EMA(C,5),EMA(C,20));

 

The reason it will fail is you are forcing SignalTrue to ALWAYS be True because you are setting it to True with =1. You should use ==1 to test a value. In fact, for a True test you don't need anything because when a value is True it is equal to 1 and you can simply say:

 

Buy = SignalTrue AND Cross…etc.

 

Note: ANY NON-Zero value is True. So -1, 10000, -3456, 1 are all True while only 0 == False.

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of wlandry01
Sent:
Wednesday, November 30, 2005 15:42
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Rather Confused Newbie

 

Hi,

 

I'm trying to set up a very basic system to determine if a stock

has met the following conditions:

 

1.  The RSI has crossed 50

2.  The MACD has crossed its Signal

3.  The EMA5 has crossed the EMA20

 

The following code will find the dates that all three

signals occur:

 

Buy=Cross(RSI(15),50) AND Cross(MACD(),Signal()) AND

Cross(EMA(C,5),EMA(C,20));

 

I'm not concerned with whether the crossings take place on the

same day, though.  I am interested in knowing the day

that the last of the 3 indicators does cross (assuming that

that the first two have crossed).  Following is

an approach that I've developed, but it seems very clumsy:

 

EMACross=Cross(EMA(C,5),EMA(C,20));

MACDCross=Cross(MACD(12,26),Signal(12,26,9));

RSICross=Cross(RSI(15),50);

 

SignalTrue=IIf(EMACross==MACDCross==RSICross==1,1,0);

 

Buy=SignalTrue=1 AND Cross(RSI(15),50) OR Cross(MACD(),Signal()) OR

Cross(EMA(C,5),EMA(C,20));

 

The first 3 lines set flags for the crossovers.  I believe that

I could simply put the crossover checks in the "IIf" statement

but this format seems easier for me to read.  In any case, I'm not

much of a programmer, and it seems that there must be a more direct

approach.  I've burned myself out looking at other code and such,

however, with no luck, and would appreciate if if someone with a

better programming background could offer some insight.

 

Thanks,

 

 

Wayne

 

 

 

 

 

 

 

 

 

------------------------ Yahoo! Groups Sponsor --------------------~-->

Try Online Currency Trading with GFT. Free 50K Demo. Trade

24 Hours. Commission-Free.

http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM

--------------------------------------------------------------------~->

 

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

 

<*> 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/

 

 



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