NexusFi: Find Your Edge


Home Menu

 





Recreate "Precision Divergence Finder Indicator"?


Discussion in Traders Hideout

Updated
      Top Posters
    1. looks_one tdaman with 5 posts (0 thanks)
    2. looks_two gordo with 4 posts (9 thanks)
    3. looks_3 wccktrader with 4 posts (3 thanks)
    4. looks_4 Fat Tails with 2 posts (10 thanks)
      Best Posters
    1. looks_one Fat Tails with 5 thanks per post
    2. looks_two TheWizard with 3 thanks per post
    3. looks_3 gordo with 2.3 thanks per post
    4. looks_4 wccktrader with 0.8 thanks per post
    1. trending_up 25,089 views
    2. thumb_up 32 thanks given
    3. group 11 followers
    1. forum 28 posts
    2. attach_file 3 attachments




 
Search this Thread

Recreate "Precision Divergence Finder Indicator"?

  #11 (permalink)
 
wccktrader's Avatar
 wccktrader 
Singapore
 
Experience: Intermediate
Platform: NinjaTrader, Sierra Charts
Broker: Thinkorswim, IQFeed
Trading: Options of SPY, IWM, QQQ
Posts: 47 since Nov 2010
Thanks Given: 54
Thanks Received: 149


Fat Tails View Post
The divergence finder is based on the Demand Index by James Sibbet.

As far as I know, there is no version of the Demand Index for NinjaTrader, so the first step would be to code the Demand Index. Below is a link with the code and some explanations.

Re: Sibbet's Demand Index, Omega TradeStation Email Archive | PureBytes.Com

Further information on the Demand Index can be found in.

Robert W. Colby: The Encyclopedia of Technical Market Indicators
Thomas E.Aspray: Fine-Tuning the Demand Index in TASC Vol. 4:4, pp 141-143

V.4:4 (141-143): Fine-tuning the demand index by Thomas E. Aspray

Once you got the Demand Index you need to look for divergences. The divergence finder possibly scans for divergences, using different periods for the Demand Index and then adds them up.

The idea is not bad at all. Divergence stands for a weakening = loss of momentum of a prevailing trend, not yet its reversal. If the trend is weakening across various timeframes a reversal might be imminent.

However, I believe that the indicator also will produce a significant number of false signals, as is usually the case with unfiltered divergences.


Perhaps another way to scan for divergences is to have a correlation indicator that shows the correlation for a certain lookback period between the Demand Index and closing price. If the correlation falls below 0.4, we have a divergence and if it falls below 0, we have a negative divergence. I could find a correlation indicator in NT that shows correlation between 2 instruments but not between an indicator and price. If someone could code such a correlation indicator, if could flag out divergences between price and any momentum indicators (e.g. Demand Index, RSI, MACD Histogram, CCI, etc).

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
21 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #12 (permalink)
 
wccktrader's Avatar
 wccktrader 
Singapore
 
Experience: Intermediate
Platform: NinjaTrader, Sierra Charts
Broker: Thinkorswim, IQFeed
Trading: Options of SPY, IWM, QQQ
Posts: 47 since Nov 2010
Thanks Given: 54
Thanks Received: 149

Managed to code the indie to show the correlation between Demand Index and price in the Thinkorswim platform. When the indie drops below 0.4, we have divergences between the Demand Index and price. A possible trading strategy would be trade in the direction of prevailing trend whenever the indie crosses back above 0.4. The Thinkscript code are given below:

#hint:<b>Demand Index</b>\nDeveloped by James Sibbet, the Demand Index is a market strength study that calculates a ratio of buying to selling pressure. It incorporates price and volume to indicate a change in price trend.
#hint length: The number of bars used to calculate the Demand Index. <b>(Default is 5)</b>

declare lower;

input length = 5;

def wClose = (high + low + 2 * close) * 0.25;
def wCRatio = (wClose - wClose[1]) / Min(wClose, wClose[1]);
def closeRatio = 3 * wClose / Average(Highest(High, 2) - Lowest(Low, 2), length) * AbsValue(wCRatio);
def volumeRatio = Volume / Average(Volume, length);
def volumePerClose = volumeRatio / exp(Min(88, closeRatio));
def buyP;
def sellP;
if (wCRatio > 0) {
buyP = volumeRatio;
sellP = volumePerClose;
} else {
buyP = volumePerClose;
sellP = volumeRatio;
}
rec buyPres = if IsNaN(buyPres[1]) then 0 else ((buyPres[1] * (length - 1)) + buyP) / length;
rec sellPres = if IsNaN(sellPres[1]) then 0 else ((sellPres[1] * (length - 1)) + sellP) / length;
def tempDI;
if ((((sellPres[1] * (length - 1)) + sellP) / length - ((buyPres[1] * (length - 1)) + buyP) / length) > 0) {
tempDI = - if (sellPres != 0) then buyPres / sellPres else 1;
} else {
tempDI = if (buyPres != 0) then sellPres / buyPres else 1;
}
def DMIndx = if IsNaN(close) then Double.NaN else if tempDI < 0 then -1 - tempDI else 1 - tempDI;
plot ZeroLine = 0;
plot DivergenceLine = 0.4;

input LookbackPeriod = 20;

plot Corr = correlation(close,DMIndx, LookbackPeriod);

Corr.setDefaultColor(GetColor(1));
ZeroLine.SetDefaultColor(GetColor(5));

DivergenceLine.setDefaultColor(GetColor(2));

Attached Thumbnails
Click image for larger version

Name:	SPY.jpg
Views:	735
Size:	210.0 KB
ID:	29129  
Reply With Quote
Thanked by:
  #13 (permalink)
 
Slipknot511's Avatar
 Slipknot511 
Springfield,Missouri, USA
 
Experience: Advanced
Platform: NinjaTrader (It's a love/hate relationship)
Trading: CL, TF, 6E
Posts: 169 since May 2010
Thanks Given: 60
Thanks Received: 314


Better Momentum for NT7 from Emini-Watch has a divergence indicator built in. If you purchase it, you also get a version that allows you to apply the divergence function to any other indicator of your choosing. For example, you can apply the divergence dots to RSI or Stochastic if that suits you. Pretty reasonable at $170.

Reply With Quote
Thanked by:
  #14 (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


wccktrader View Post
Managed to code the indie to show the correlation between Demand Index and price in the Thinkorswim platform. When the indie drops below 0.4, we have divergences between the Demand Index and price. A possible trading strategy would be trade in the direction of prevailing trend whenever the indie crosses back above 0.4. The Thinkscript code are given below:

Thanks for posting the code. But at first sight I have some difficulty to imagine a trading strategy using this indicator, but then I have no experience with the Demand Index.

Divergences have me gotten in trouble quite often, so I believe that you need additional filters.

Reply With Quote
Thanked by:
  #15 (permalink)
 
monpere's Avatar
 monpere 
Bala, PA, USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,371


Fat Tails View Post
Thanks for posting the code. But at first sight I have some difficulty to imagine a trading strategy using this indicator, but then I have no experience with the Demand Index.

Divergences have me gotten in trouble quite often, so I believe that you need additional filters.

I you don't make sure you are very intimate with divergence produced by your particular indicator, you will loose your shirt... and probably your pants!

Reply With Quote
Thanked by:
  #16 (permalink)
 
wccktrader's Avatar
 wccktrader 
Singapore
 
Experience: Intermediate
Platform: NinjaTrader, Sierra Charts
Broker: Thinkorswim, IQFeed
Trading: Options of SPY, IWM, QQQ
Posts: 47 since Nov 2010
Thanks Given: 54
Thanks Received: 149


monpere View Post
I you don't make sure you are very intimate with divergence produced by your particular indicator, you will loose your shirt... and probably your pants!

Thanks monpere. I have just backtested the divergence indicator with another trend following indicator for entry, and exit using an ATR trailing stop indicator. The backtesting results looks good but walk forward analysis results is not good. This confirms that I will loose my shirt trading divergence in real time. Nonetheless, I think divergence may serve as a tool to alert me to have a second look at price actions.

Reply With Quote
  #17 (permalink)
kk240
Europe,Nomad
 
Posts: 84 since Nov 2010
Thanks Given: 25
Thanks Received: 30

Removed text somebody allready sent info here.

Reply With Quote
  #18 (permalink)
 
monpere's Avatar
 monpere 
Bala, PA, USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,371


wccktrader View Post
Thanks monpere. I have just backtested the divergence indicator with another trend following indicator for entry, and exit using an ATR trailing stop indicator. The backtesting results looks good but walk forward analysis results is not good. This confirms that I will loose my shirt trading divergence in real time. Nonetheless, I think divergence may serve as a tool to alert me to have a second look at price actions.

What do you use to do walk forward testing?

Reply With Quote
  #19 (permalink)
 
wccktrader's Avatar
 wccktrader 
Singapore
 
Experience: Intermediate
Platform: NinjaTrader, Sierra Charts
Broker: Thinkorswim, IQFeed
Trading: Options of SPY, IWM, QQQ
Posts: 47 since Nov 2010
Thanks Given: 54
Thanks Received: 149


monpere View Post
What do you use to do walk forward testing?

Ninjatrader 7. Optimization with genetic optimizer using 6 months of hourly data and walk forward for the next 6 months.

Reply With Quote
  #20 (permalink)
 
gordo's Avatar
 gordo 
Tonganoxie, Kansas
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: CL,6E
Posts: 160 since Nov 2009
Thanks Given: 129
Thanks Received: 401



Fat Tails View Post
The divergence finder is based on the Demand Index by James Sibbet.

As far as I know, there is no version of the Demand Index for NinjaTrader, so the first step would be to code the Demand Index. Below is a link with the code and some explanations.

Re: Sibbet's Demand Index, Omega TradeStation Email Archive | PureBytes.Com

Further information on the Demand Index can be found in.

Robert W. Colby: The Encyclopedia of Technical Market Indicators
Thomas E.Aspray: Fine-Tuning the Demand Index in TASC Vol. 4:4, pp 141-143

V.4:4 (141-143): Fine-tuning the demand index by Thomas E. Aspray

Once you got the Demand Index you need to look for divergences. The divergence finder possibly scans for divergences, using different periods for the Demand Index and then adds them up.

The idea is not bad at all. Divergence stands for a weakening = loss of momentum of a prevailing trend, not yet its reversal. If the trend is weakening across various timeframes a reversal might be imminent.

However, I believe that the indicator also will produce a significant number of false signals, as is usually the case with unfiltered divergences.

I looked at these sites and did a Google search on James Sibbet and Demand Index. The best I could do was find some code developed by eSignal and some in Trader's Laboratory.

I was unable to find any in Ninja. More interesting, I could not find any of James' original work. I did, however, find this same quote in several places:

The Demand Index, developed by James Sibbet, combines price and volume in such a way that it is often a leading indicator of price change. The Demand Index calculations are too complex, however, for this text. The calculations require 21-column accounting paper to calculate manually.
  • There are six "rules" to the Demand Index:
  • A divergence between the Demand Index and the price trend suggests an approaching weakness in price.
  • One more rally to new highs usually follows an extreme peak in the Demand Index (the Index is performing as a leading indicator).
  • Higher prices with a lower Demand Index peak usually coincides with an important top (the Index is performing as a coincidental indicator).
  • The Demand Index penetrates the level of zero indicating a change in trend (the Index is performing as a lagging indicator).
  • When the Demand Index stays near the level of zero for any period of time, a weak price movement that will not last long is indicated.
  • A large long-term divergence between prices and the Demand Index indicates a major top or bottom.
The reason I think everyone is quoting each other is they use the same line:

The Demand Index calculations are too complex, however, for this text. The calculations require 21-column accounting paper to calculate manually.

I'm not sure, but can you even buy 21-column accounting paper anymore?

So although I have this code in Language 'X', I am not sure when I get done moving it to Ninja if I have the right logic. Code isn't worth much if the logic is wrong from the get go.

Anybody have any thoughts on where to find James Sibbet's original logic?

Gordo

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on December 16, 2014


© 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