Divergence Indicator

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Divergence Indicator

Postby isamegrelo » Wed Aug 09, 2017 4:50 pm

Divergence indicator's formula from TradingView:



study(title="Divergence Indicator")

osc = rsi(close, 14)

// Bullish
bullishPrice = low
priceMins = bullishPrice > bullishPrice[1] and bullishPrice[1] < bullishPrice[2]

priceRightMin = valuewhen(priceMins, bullishPrice[1], 0)
priceLeftMin = valuewhen(priceMins, bullishPrice[1], 1)

oscRightMin = valuewhen(priceMins, osc[1], 0)
oscLeftMin = valuewhen(priceMins, osc[1], 1)

bullishNDiv = priceLeftMin > priceRightMin and oscLeftMin < oscRightMin
bullishHDiv = priceLeftMin < priceRightMin and oscLeftMin > oscRightMin

bullishNSig = bullishNDiv and not bullishNDiv[1] and bullishPrice[1] < bullishPrice
bullishHSig = bullishHDiv and not bullishHDiv[1] and bullishPrice[1] > bullishPrice

plot(bullishNSig, title="Normal Bullish Divergence", style=histogram, linewidth=3, color=green)
plot(bullishHSig, title="Hidden Bullish Divergence", style=histogram, linewidth=1, color=green)

// Bearish
bearishPrice = high
priceMaxs = bearishPrice < bearishPrice[1] and bearishPrice[1] > bearishPrice[2]

priceRightMax = valuewhen(priceMaxs, bearishPrice[1], 0)
priceLeftMax = valuewhen(priceMaxs, bearishPrice[1], 1)

oscRightMax = valuewhen(priceMaxs, osc[1], 0)
oscLeftMax = valuewhen(priceMaxs, osc[1], 1)

bearishNDiv = priceLeftMax < priceRightMax and oscLeftMax > oscRightMax
bearishHDiv = priceLeftMax > priceRightMax and oscLeftMax < oscRightMax

bearishNSig = bearishNDiv and not bearishNDiv[1] and bearishPrice[1] < bearishPrice
bearishHSig = bearishHDiv and not bearishHDiv[1] and bearishPrice[1] > bearishPrice

plot(bearishNSig, title="Normal Bearish Divergence", style=histogram, linewidth=3, color=red)
plot(bearishHSig, title="Hidden Bearish Divergence", style=histogram, linewidth=1, color=red)
isamegrelo
FXCodeBase: Initiate
 
Posts: 114
Joined: Mon May 29, 2017 3:36 pm

Re: Divergence Indicator

Postby Apprentice » Sun Aug 13, 2017 4:20 am

Your request is added to the development list, Under Id Number 3850
If someone is interested to do this task, please contact me.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36476
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia



Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Majestic-12 [Bot] and 20 guests