RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



Scanning for Divergence Expand / Collapse
Message
Posted 2/13/2010 05:00:04 Post #10845
 

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member
Hi Guys,

Looking for any help on how would I write the code to scan for a divergence between price and an indicator.

i.e Bullish divergence when the price makes two lower lows but the indicator make two higher highs.

See screen shot for a clear picture.

Any ideas?

Thanks.

  Post Attachments 
divergance.JPG (57 views, 60.27 KB)
Posted 2/13/2010 08:42:52 Post #10850
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
In principle this would seem to work(?): Under NewBar, test whether current is new low in your time frame (see BarUtils.LowestLow maybe). On each subsequent NewBar keep a count that 'ages' that previous new low. Check whether this new current is lower (within the time frame (before aging out)) to see if you have two successively in the time frame. Note that the value of 'local' variables are preserved from one NewBar to the next, so keeping a bit of history is easy.

-Pete
(See also rightedge-ats Yahoo group )

Posted 2/13/2010 21:15:15 Post #10862
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
Small nitpick: Technically "local" variables are those declared inside of a method body, and those aren't preserved from one NewBar to the next. I think you are referring to class variables, which are preserved.



Daniel
Posted 2/14/2010 05:49:11 Post #10863
 

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member
Thanks would the way PHG mentioned be the best?

I know in other packages you can specify peak and trough but couldn't see it in RE
Posted 2/14/2010 07:00:25 Post #10865
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
Thanks Daniel. Precision counts, and that keeps me on my learning curve.

-Pete
(See also rightedge-ats Yahoo group )

Posted 2/14/2010 11:39:51 Post #10869
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
Yes, I would recommend doing something like PHG's method.

To code this you need to define what you are looking for more precisely. Do the new high/lows you are looking for have to be all-time high or lows, or do you only want to look back a certain number of bars? How close together do you want to require the highs/lows to be.

Also, looking at the screenshot, it looks like the indicator isn't actually making two new highs. So I'm not sure if you want something different or if the chart isn't a good example of what you're looking for.

Daniel
Posted 2/16/2010 05:07:13 Post #10884
 

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member
The indicator is making a higher swing low is what It should have said.
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: billb, young, dplaisted

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 1:02am

2005-2007 © RightEdge Systems