To build a screener for any time frames using structure breaks
Forums › ProRealTime English forum › ProScreener support › To build a screener for any time frames using structure breaks
- This topic has 3 replies, 2 voices, and was last updated 9 months ago by Iván.
-
-
03/18/2024 at 7:35 PM #229976
Hi Nicolas or Anyone,
Can you please help me build this below logic into a screener for pro real time. I want the screener to give me if triangle appears on current or previous candle for any timeframes. Mostly I will using it on Weekly timeframes. Can anyone please help. Many thanks!
———————————-
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © VenugopalAru//@version=5indicator(“Structural breaks”, overlay = true, max_boxes_count=500, max_lines_count=500)pivotLookup = input.int(defval=1, minval=1, maxval=5,title=’Pivot Lookup’, group=’Pivots’, tooltip=’Minimum = 1, Maximum = 5′)plotPPDD = input.bool(defval=true, title=”Plot PPDD OB’s”, group=’Qualitative indicators’, tooltip=’Premium Premium Discount Discount (PPDD) is an OB formed after liquidity sweep. It will show up by default as a triangle (Bull ▲ / Bear ▼). Also PPDD1 (by deafult maked with a x-cross ⨯) which is a weak OB formed after liquidity sweep, that fails to completely engulf the high/low, but closes beyond the trapped candles open price.’)ppddBullColor = input.color(defval=color.new(color.green, 0), title=”Bullish PPDD OB’s Color”, group=’Qualitative indicators’, inline=’PPDD Color’)ppddBearColor = input.color(defval=color.new(color.red, 0), title=”Bearish PPDD OB’s Color”, group=’Qualitative indicators’, inline=’PPDD Color’)//FunctionsisUp(index) =>close[index] > open[index]isDown(index) =>close[index] < open[index]isObUp(index) =>isDown(index + 1) and isUp(index) and close[index] > high[index + 1]isObDown(index) =>isUp(index + 1) and isDown(index) and close[index] < low[index + 1]//////////////////// Pivots ////////////////////hih = ta.pivothigh(high, pivotLookup, pivotLookup)lol = ta.pivotlow(low , pivotLookup, pivotLookup)top = ta.valuewhen(hih, high[pivotLookup], 0)bottom = ta.valuewhen(lol, low [pivotLookup], 0)//////////////////// Premium Premium & Discount Discount //////////////////brearishTriangle = plotPPDD and isObDown(0) and ((math.max(high, high[1]) > top and close < top) or (math.max(high, high[1]) > top[1] and close < top[1]))bullishTriangle = plotPPDD and isObUp(0) and ((math.min(low, low[1]) < bottom and close > bottom) or (math.min(low, low[1]) < bottom[1] and close > bottom[1]))plotshape(brearishTriangle, “Bearish PPDD OB”, style=shape.triangledown , location=location.abovebar, color=ppddBearColor, size=size.tiny)plotshape(bullishTriangle, “Bullish PPDD OB”, style=shape.triangleup , location=location.belowbar, color=ppddBullColor, size=size.tiny)================================================Regards,Venu03/19/2024 at 1:25 PM #230026Here is the code:
12345678910111213141516171819202122232425262728293031//////////////////////////////////////////////////////////////////PRC_Structural Breaks Screener//version = 0//19.03.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//////////////////////////////////////////////////////////////////------------Inputs-----------------------------------------//prd = 1 //pivot length//------------Bullish and bearish conditions-----------------//isObUp = close[1]<open[1] and close>open and close > high[1]isObDown = close[1]>open[1] and close < open and close < low[1]//------------Pivots low-------------------------------------//if low > low[prd] and lowest[prd](low) > low[prd] and low[prd] < lowest[prd](low)[prd+1] then$pl[z+1] = low[prd]$plx[z+1] = barindex[prd]z = z + 1endif//------------Pivots high------------------------------------//if high < high[prd] and highest[prd](high)<high[prd] and high[prd]>highest[prd](high)[prd+1] then$ph[t+1]=high[prd]$phx[t+1]=barindex[prd]t=t+1endif//----------Bearish Signal-----------------------------------//bearishTriangle = isObDown and ((max(high, high[1]) > $ph[t] and close < $ph[t]) or (max(high, high[1]) > $ph[t][1] and close < $ph[t][1]))//----------Bullish Signal-----------------------------------//bullishTriangle = isObUp and ((min(low, low[1]) < $pl[z] and close > $pl[z]) or (min(low, low[1]) < $pl[z][1] and close > $pl[z][1]))//----------Screener condition-------------------------------//screener[bearishTriangle or bullishTriangle]03/19/2024 at 1:48 PM #230027Here is the code:
12345678910111213141516171819202122232425262728293031//////////////////////////////////////////////////////////////////PRC_Structural Breaks Screener//version = 0//19.03.24//Iván González @ http://www.prorealcode.com//Sharing ProRealTime knowledge//////////////////////////////////////////////////////////////////————Inputs—————————————–//prd = 1 //pivot length//————Bullish and bearish conditions—————–//isObUp = close[1]<open[1] and close>open and close > high[1]isObDown = close[1]>open[1] and close < open and close < low[1]//————Pivots low————————————-//if low > low[prd] and lowest[prd](low) > low[prd] and low[prd] < lowest[prd](low)[prd+1] then$pl[z+1] = low[prd]$plx[z+1] = barindex[prd]z = z + 1endif//————Pivots high————————————//if high < high[prd] and highest[prd](high)<high[prd] and high[prd]>highest[prd](high)[prd+1] then$ph[t+1]=high[prd]$phx[t+1]=barindex[prd]t=t+1endif//———-Bearish Signal———————————–//bearishTriangle = isObDown and ((max(high, high[1]) > $ph[t] and close < $ph[t]) or (max(high, high[1]) > $ph[t][1] and close < $ph[t][1]))//———-Bullish Signal———————————–//bullishTriangle = isObUp and ((min(low, low[1]) < $pl[z] and close > $pl[z]) or (min(low, low[1]) < $pl[z][1] and close > $pl[z][1]))//———-Screener condition——————————-//screener[bearishTriangle or bullishTriangle]Hi Ivan, thanks for responding. I tried running this screener looks like its not working, it is not returning me any stocks both on weekly or daily. Can you please check it.
Regards,
Venu
03/19/2024 at 3:12 PM #230039Hi
The code works properly.
You can see in this post https://www.prorealcode.com/prorealtime-market-screeners/structural-breaks-screener/ the results in USA Tech 600. -
AuthorPosts
Find exclusive trading pro-tools on