NexusFi: Find Your Edge


Home Menu

 





Divergence detection algorithm


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 6 posts (11 thanks)
    2. looks_two cunparis with 5 posts (0 thanks)
    3. looks_3 max-td with 4 posts (4 thanks)
    4. looks_4 shodson with 3 posts (2 thanks)
      Best Posters
    1. looks_one cory with 5 thanks per post
    2. looks_two Fat Tails with 1.8 thanks per post
    3. looks_3 max-td with 1 thanks per post
    4. looks_4 shodson with 0.7 thanks per post
    1. trending_up 25,004 views
    2. thumb_up 24 thanks given
    3. group 7 followers
    1. forum 24 posts
    2. attach_file 9 attachments




 
Search this Thread

Divergence detection algorithm

  #1 (permalink)
 
cunparis's Avatar
 cunparis 
Paris, France
 
Experience: Advanced
Platform: Market Delta & Ninjatrader
Trading: ES
Posts: 2,565 since Jun 2009
Thanks Given: 1,162
Thanks Received: 2,093

I've been trying to code a divergence detection but it's really hard. I'm curious if anyone has already tried to do it.

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
25 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


There are two indicators available in the NinjaTrader Forum, which you will find below

- D3Spotter
- DivergenceSpotter

For me the problem would not be coding any such indicator, but what to do with it.

Divergence basically is a sort of first derivative, so it indicates a slowdown of price, when a new high or low is made. The danger with following divergences is that it lures you into early countertrades with a rather bad return-to-risk ratio. A triple divergence is a failed divergence, and this occurs frequently. Actually any trending move that leads into a longer congestion will produce a divergence, and usually congestions that follow trending moves are continuation patterns.

A three-push pattern usually produces a triple divergence, if it is a wedge. If the last high or low overshoots the opposite trendline to stop at one of the fibonacci ratios, you might take that trade without a prior trendline break.

Otherwise, I only use a signal that creates a divergence within a divergence, that means a smaller timeframe divergence within a larger timeframe divergence, if a clear trendline break in the larger timeframe has already occured.

Attached Files
Elite Membership required to download: DivergenceSpotter.zip
Elite Membership required to download: D3Spotter.zip
Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,610


cunparis View Post
I've been trying to code a divergence detection but it's really hard. I'm curious if anyone has already tried to do it.

You'll need to be more specific.

It can be as simple as:

 
Code
                            


myema 
XAverage(C20);
mycci CCI(14);

if 
myema myema[1] and mycci mycci[1then divergence true
etc. Then just draw the trendline, init it first then track the ID, and then extend it each bar the divergence continues. TL_New_self for tl's in panel 2, or if you want it on price panel just use TL_New.

It will all depend on what you call divergence.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 
cunparis's Avatar
 cunparis 
Paris, France
 
Experience: Advanced
Platform: Market Delta & Ninjatrader
Trading: ES
Posts: 2,565 since Jun 2009
Thanks Given: 1,162
Thanks Received: 2,093


Big Mike View Post
It will all depend on what you call divergence.

YOu're right, I should have been more specific.

I'm looking for one data series to make a HH and another to make a LH. I'd like the HH to be relatively close to the previous H, meaning the HH must be a consecutive peak. I don't want them to have smaller highs in between because that gets really complicated.

I started approaching it just from a pattern perspective. 3 bar pattern, 4 bars, 5 bars but it gets complicated cause there are different possibilities when you get to 5 for the bars in between.

I'm wondering if I should continue that or if there is a better way.

I don't really like the moving average approach, I want the divergence on the raw data and since it can be 3 bars I can't have any lag.

Follow me on Twitter Started this thread Reply With Quote
  #6 (permalink)
 
cunparis's Avatar
 cunparis 
Paris, France
 
Experience: Advanced
Platform: Market Delta & Ninjatrader
Trading: ES
Posts: 2,565 since Jun 2009
Thanks Given: 1,162
Thanks Received: 2,093


Fat Tails View Post
For me the problem would not be coding any such indicator, but what to with it.

Divergence basically is a sort of first derivative, so it indicates a slowdown of price, when a new high or low is made. The danger with following divergences is that it lures you into early countertrades with a rather bad return-to-risk ratio.

Who said anything about price???

I agree entering based on a divergence is not a good idea. For me it's just another piece of the puzzle. Gives me a warm fuzzy.

I'll look at those indicators. now I feel stupid cause I searched the forum discussions but I didn't think of searching the file downloads. it'd be nice if the forum search did both.

Thanks

Follow me on Twitter Started this thread Reply With Quote
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,610


cunparis View Post
I don't really like the moving average approach, I want the divergence on the raw data and since it can be 3 bars I can't have any lag.

Good luck

I would suggest using Alexander ZigZag or similar, but there is always lag in detection of the formation of the new zigzag.

If you are looking for a breakout or breakdown of a prior HH or LL, you'll first have to have a working method for identifying those HH and LL's (ZigZag for instance, or your own).

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

also take a look at ninja candle finder indicator they use a strength value to filter out some weak divergence (weak trend).

ps. if you are in looking for some new idea here is one;

This review is for: Value in Time: Better Trading through Effective Volume (Wiley Trading) (Hardcover)

The author uses inexpensive off-the-shelf software to slice each trading day of a stock into one-minute segments. He finds the average one-minute volume for the day and separates the minutes into those with above or below average volume. In each group, he adds up the volume of minutes with rising prices and subtracts the volume of minutes with falling prices. This gives him two cumulative volume lines: one for the minutes with above average and the other for below average volume. He named them Large and Small Effective Volume.

The minutes with above average volume reflect the impact of the big money and often have predictive value. When you find a condition in which the big money starts pushing up a stock, while the small money remains negative or neutral, an upside reversal is in the cards. When the big money starts pushing the stock down while the small money is flat or buying, a downside reversal is more likely.

Reply With Quote
  #9 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

hi cunparis,
i also looked for a good diver-indie some weeks ago.

i found interesting + good working ones for MT4 but havent translated them - thats far below of my skills.
but what they show looks like a clear + sensemaking definition + calculation.

let me know if you are interested that i post / send you / the MT4 scripts to have a look at it.

-

max-td
Reply With Quote
  #10 (permalink)
 
cunparis's Avatar
 cunparis 
Paris, France
 
Experience: Advanced
Platform: Market Delta & Ninjatrader
Trading: ES
Posts: 2,565 since Jun 2009
Thanks Given: 1,162
Thanks Received: 2,093



max-td View Post
hi cunparis,
i also looked for a good diver-indie some weeks ago.

i found interesting + good working ones for MT4 but havent translated them - thats far below of my skills.
but what they show looks like a clear + sensemaking definition + calculation.

let me know if you are interested that i post / send you / the MT4 scripts to have a look at it.

-

I haven't seen MT4's code so i don't know what it looks like but if you have a few examples of the indicator on a chart that would help to see how it works and then I could look at the code to see if I can translate it to easylanguage or C#.

Follow me on Twitter Started this thread Reply With Quote




Last Updated on April 29, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts