The Top and Bottom indicator is using the breakout of the most recent tops and bottoms of the last x periods to start counting the number of bars elapsed since the events.
- When the bars count of the last bearish breakout is higher than the bars count of the last bullish breakout, a buy signal is generated.
- When the bars count of the last bullish breakout is higher than the bars count of the last bearish breakout, a sell signal is generated.
Code converted from another trading platform programming language, as per a request in the indicators forum.
//PRC_Top Bottom | indicator
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- settings
per = 14 //Bottom Period
per2 = 14 //Top Period
// --- end of settings
loc = low < lowest[per](low) and low <= lowest[per](low[per])
if loc then
bottom = barindex-locstart
loc2 = high > highest[per2](high) and high >= highest[per2](high[per2])
if loc2 then
top = barindex-loc2start
iBuy = bottom crosses over top
iSell = bottom crosses under top
if iBuy then
if iSell then
drawtext("Sell",barindex,top-4, dialog,bold,20) coloured(255,0,0)
if top<bottom then
return bottom coloured(0,0,255) style(line,2) as "bottom", top coloured(255,0,0) style(line,2) as "top"
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 :