Here is a smart idea for an indicator to detect range, as it compares 2 bollinger bandwidth spread as an hint for current price contraction.
When the oscillator is set to 1, price is ranging and “NoTrade” would be initiated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
a = BollingerUp[40](close) b = BollingerDown[40](close) B1Range = a - b c = BollingerUp[20](close) d = BollingerDown[20](close) B2Range = c - d if B2Range < (B1Range/2) then NoTrade = 1 else NoTrade = 0 endif return NoTrade AS "No Trade" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :
Filename : download the ITF files
How to import ITF files into ProRealTime platform?
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hello, what does it mean the 20 and 40 number on this code ?
Thank you !
I modified it to make parameters customizable and to Draw a Grey candlestick when a range is detected (sorry for the code, but the “Add PRT code” button didn’t work):
// Bollinger Band range setection
//
DEFPARAM CalculateOnLastBars = 1000
// BB1 = 40
// BB2 = 20
// RangeDivisor = 2.0
//
a = BollingerUp[BB1](close)
b = BollingerDown[BB1](close)
B1Range = a – b
c = BollingerUp[BB2](close)
d = BollingerDown[BB2](close)
B2Range = c – d
if B2Range < (B1Range/RangeDivisor) then
DRAWCANDLE(Open,High,Low,Close) COLOURED(230,230,250,255) bordercolor(0,255,255,50) //Cyan border
//NoTrade = 1
else
//NoTrade = 0
endif
return // NoTrade AS "No Trade"