logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
nakedkurt  
#1 Posted : Monday, February 7, 2011 8:08:51 PM(UTC)
nakedkurt

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/23/2010(UTC)
Posts: 8

I want to set: MACD cross happens within the latest 8 days...

I tried the following:
Cross(MACD(), Mov(MACD(),9,EXPONENTIAL))
AND BarsSince(MACD()>Mov(MACD(),9,EXPONENTIAL))<=8

OR
Cross(MACD(), Mov(MACD(),9,EXPONENTIAL))
AND BarsSince(Cross(MACD(), Mov(MACD(),9,EXPONENTIAL)))<=8

I tested them on a stock with a MACD cross happening in the past 5 days...But the explorer says it can't find a stock with + result...

Can somebody help me?

Thanks a lot!
mstt  
#2 Posted : Monday, February 7, 2011 11:54:30 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Kurt The code appears to work fine for me. If you've only tested one or two charts against the explorer for results but not loaded a substantial number of bars for the exploration there's a very good chance that what you get from the explorer will differ from what you see on a chart. There are a couple of reasons for this. The first reason is that the MACD() function needs 100-150 bars loaded to generate a truly accurate result. Why? Because MACD is the difference between two exponential moving averages and EMAs need as much as five times as much data as the Periods parameter of the longer EMA (as a rule of thumb a 26 period EMA needs around 125 periods to deliver the kind of accuracy you probably expect). The second reason you could run into a problem is because of the BarsSince() function in the code. Many MS functions force the Explorer to load sufficient data, as indicated by the longest Period parameter, to get the job done. As I've already said, EMAs don't force sufficient records to load, and this "defect" carries over into RSI(), ADX() and 25 or so other common functions. Then there's another group of functions that don't even use either a regular or a hidden Periods parameter, and BarsSince() falls into this category. Others in the same category are Alert() and any finction using an Nth parameter - ValueWhen(), HighestSince() and so on. My guess is that your problems will simply vanish once you stipulate the loading of at least 150-200 records. For the most part the columns or filter of an exploration function exactly the same as an indicator. What's different is that the reported result only tells you the state of your code as at the last bar of data, and the all-too-frequent failure to load sufficient data for the code to function as intended. Hope this helps. Roy
nakedkurt  
#3 Posted : Tuesday, February 8, 2011 7:41:46 AM(UTC)
nakedkurt

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/23/2010(UTC)
Posts: 8

Thanks for your sage advice!
I will try your way, thanks a lot!
nakedkurt  
#4 Posted : Tuesday, February 8, 2011 8:51:36 AM(UTC)
nakedkurt

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/23/2010(UTC)
Posts: 8

I tried your way, but still failed even 1000 record bars were loaded...
Please help!
mstt  
#5 Posted : Tuesday, February 8, 2011 1:30:27 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Kurt By ANDing the Cross() function with the BarsSince() function you are negating the intention of extending each Cross() for up to 8 bars. Is it possible that you wanted something like this below? Alert(Cross(MACD(),Mov(M,9,E)),8) OR Alert(Cross(Mov(M,9,E),MACD()),8); Assuming I'm reading your intentions correctly this code below would also work - it uses only one Alert() function. Alert(Cross(MACD(),Mov(M,9,E)) OR Cross(Mov(M,9,E),MACD()),8); To separate the different crossovers put each expression into a different column. {colA} Alert(Cross(MACD(),Mov(M,9,E)),8) {colB} Alert(Cross(Mov(M,9,E),MACD()),8); Hope this helps. Roy
nakedkurt  
#6 Posted : Tuesday, February 8, 2011 5:22:07 PM(UTC)
nakedkurt

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/23/2010(UTC)
Posts: 8

I am quite busy, so I can't explore the market everyday... And my preference is to buy the stocks with MACD crossover. So, I want to find the stocks with MACD crossover within the latest 8 days in order to avoid missing any stocks with MACD crossover recently.
wabbit  
#7 Posted : Wednesday, February 9, 2011 1:59:48 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Alert()


wabbit [:D]

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.