Conversion TradingView to ProRealtime – Higher Highs and Lower Lows
Forums › ProRealTime English forum › ProBuilder support › Conversion TradingView to ProRealtime – Higher Highs and Lower Lows
- This topic has 9 replies, 1 voice, and was last updated 2 years ago by josetiagosoares.
Tagged: hhll, higher highs, lower lows, swing
-
-
03/19/2019 at 9:00 AM #93990
Hallo,
I want to use ProRealtime in the near future for my trading. Therefore, I need help to convert some scripts from Tradingview to ProRealtime. I tried to code this in ProRealtime, but it’s very hard with no experience. The first script contains Higher High/Lower Low detection.
Tradingview code:
//@version=3
study(“HHLL”, overlay=true)Fractal(mode) =>
ret = mode == 1 ? high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0] : mode == -1 ? low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0] : falsetopf = Fractal(1)
botf = Fractal(-1)higherhigh = topf == false ? false : (valuewhen(topf == true, high[2], 1) < valuewhen(topf == true, high[2], 0))
lowerlow = botf == false ? false : (valuewhen(botf == true, low[2], 1) > valuewhen(botf == true, low[2], 0))plotshape(higherhigh, title=’Higher High’, style=shape.triangledown, location=location.abovebar, color=black, text=”HH”, offset=-2)
plotshape(lowerlow, title=’Lower Low’, style=shape.triangleup, location=location.belowbar, color=black, text=”LL”, offset=-2)Questions:
Can anyone provide an exact conversion to ProRealtime?
What would be the corresponding screener? I want to screen for LL or HH ONLY two days (maybe also variable selection) after their occurency. The selection to screen for HH or LL should be possible.
Considerations:
The HH/LL show up in the chart after the second day of their occurency. See the picture in the attachment – the last HH shows up today and remains if the todays close is below the HH. If todays close will be higher then the HH will disappear. It is also important to consider that the plot needs to be shifted by 2. In Tradingview this can be done by oofset=-2.
The HHLL should work for every timeframe depending on the timeframe of the chart.
Thanks for your help and best regards.
03/19/2019 at 10:13 AM #94005Here is the code for the higher high / lower low indicator translated to ProRealTime:
1234567891011121314151617181920212223242526272829topf = high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0]botf = low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0]if topf then//if high[2]>higherhigh or lastsig=-1 thenhigherhigh=high[2]//lastsig=1//endifendifif botf then//if low[2]<lowerlow or lowerlow=0 or lastsig=1 thenlowerlow=low[2]//lastsig=-1//endifendifatr=averagetruerange[14]if higherhigh>higherhigh[1] thendrawtext("▼",barindex[2],higherhigh,dialog,bold,15)drawtext("HH",barindex[2],higherhigh+atr*0.2,dialog,bold,15)endifif lowerlow<lowerlow[1] thendrawtext("▲",barindex[2],lowerlow,dialog,bold,15)drawtext("LL",barindex[2],lowerlow-atr*0.2,dialog,bold,15)endifreturnIf you think that it is the exact conversion, then I will help you making the screener.
1 user thanked author for this post.
03/19/2019 at 2:12 PM #94025Thanks for the quick reply, Nicolas!
At first glance, the code looks good and should do the same like in Tradingview. Therefore, it would be great if you could help with the screener. It should be possible to switch the scan between LL and HH. Since a LL/HH remains only after the 2nd bar close, also the lookback period for the scan should be switchable – e.g. scan for LL with a lokback period of 2 bars. Interesting would be a range for the lookback period of 2 to 10 bars. If I define a lookback period of 2, the screener shouldn’t show stocks with LL at 3 bars in the past.
Best regards!
03/19/2019 at 2:36 PM #94027Here is the stock screener code to find higher highs and lower lows in the last “lookback” periods:
1234567891011121314151617181920lookback = 3scantype = 2 //1=HH ; 2=LLtopf = high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0]botf = low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0]if topf thenhigherhigh=high[2]endifif botf thenlowerlow=low[2]endifif scantype=1 thenscan = summation[lookback] (higherhigh>higherhigh[1])>0elsescan = summation[lookback] (lowerlow<lowerlow[1])>0endifscreener[scan](scantype)03/19/2019 at 7:11 PM #9407009/24/2019 at 12:15 AM #108298Hello, I’ve the same problem, I need help to convert some scripts from Tradingview to ProRealtime.
Here is the code in Pine Editor:
//@version=2
//Credit to https://www.tradingview.com/script/p3oqCa56-Pekipek-s-PPO-Divergence-BETA/ (I just changed the visuals and added alerts)
study(“PPO Divergence Alerts”, overlay=false)source = open
long_term_div = input(true, title=”Use long term Divergences?”)
div_lookback_period = input(55, minval=1, title=”Lookback Period”)
fastLength = input(12, minval=1), slowLength=input(26,minval=1)
signalLength=input(9,minval=1)
smoother = input(2,minval=1)
fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)
macd = fastMA – slowMA
macd2=(macd/slowMA)*100
d = sma(macd2, smoother) // smoothing PPObullishPrice = low
priceMins = bullishPrice > bullishPrice[1] and bullishPrice[1] < bullishPrice[2] or low[1] == low[2] and low[1] < low and low[1] < low[3] or low[1] == low[2] and low[1] == low[3] and low[1] < low and low[1] < low[4] or low[1] == low[2] and low[1] == low[3] and low[1] and low[1] == low[4] and low[1] < low and low[1] < low[5] // this line identifies bottoms and plateaus in the price
oscMins= d > d[1] and d[1] < d[2] // this line identifies bottoms in the PPOBottomPointsInPPO = oscMins
bearishPrice = high
priceMax = bearishPrice < bearishPrice[1] and bearishPrice[1] > bearishPrice[2] or high[1] == high[2] and high[1] > high and high[1] > high[3] or high[1] == high[2] and high[1] == high[3] and high[1] > high and high[1] > high[4] or high[1] == high[2] and high[1] == high[3] and high[1] and high[1] == high[4] and high[1] > high and high[1] > high[5] // this line identifies tops in the price
oscMax = d < d[1] and d[1] > d[2] // this line identifies tops in the PPOTopPointsInPPO = oscMax
currenttrough4=valuewhen (oscMins, d[1], 0) // identifies the value of PPO at the most recent BOTTOM in the PPO
lasttrough4=valuewhen (oscMins, d[1], 1) // NOT USED identifies the value of PPO at the second most recent BOTTOM in the PPO
currenttrough5=valuewhen (oscMax, d[1], 0) // identifies the value of PPO at the most recent TOP in the PPO
lasttrough5=valuewhen (oscMax, d[1], 1) // NOT USED identifies the value of PPO at the second most recent TOP in the PPOcurrenttrough6=valuewhen (priceMins, low[1], 0) // this line identifies the low (price) at the most recent bottom in the Price
lasttrough6=valuewhen (priceMins, low[1], 1) // NOT USED this line identifies the low (price) at the second most recent bottom in the Price
currenttrough7=valuewhen (priceMax, high[1], 0) // this line identifies the high (price) at the most recent top in the Price
lasttrough7=valuewhen (priceMax, high[1], 1) // NOT USED this line identifies the high (price) at the second most recent top in the Pricedelayedlow = priceMins and barssince(oscMins) < 3 ? low[1] : na
delayedhigh = priceMax and barssince(oscMax) < 3 ? high[1] : na// only take tops/bottoms in price when tops/bottoms are less than 5 bars away
filter = barssince(priceMins) < 5 ? lowest(currenttrough6, 4) : na
filter2 = barssince(priceMax) < 5 ? highest(currenttrough7, 4) : na//delayedbottom/top when oscillator bottom/top is earlier than price bottom/top
y11 = valuewhen(oscMins, delayedlow, 0)
y12 = valuewhen(oscMax, delayedhigh, 0)// only take tops/bottoms in price when tops/bottoms are less than 5 bars away, since 2nd most recent top/bottom in osc
y2=valuewhen(oscMax, filter2, 1) // identifies the highest high in the tops of price with 5 bar lookback period SINCE the SECOND most recent top in PPO
y6=valuewhen(oscMins, filter, 1) // identifies the lowest low in the bottoms of price with 5 bar lookback period SINCE the SECOND most recent bottom in PPOlong_term_bull_filt = valuewhen(priceMins, lowest(div_lookback_period), 1)
long_term_bear_filt = valuewhen(priceMax, highest(div_lookback_period), 1)y3=valuewhen(oscMax, currenttrough5, 0) // identifies the value of PPO in the most recent top of PPO
y4=valuewhen(oscMax, currenttrough5, 1) // identifies the value of PPO in the second most recent top of PPOy7=valuewhen(oscMins, currenttrough4, 0) // identifies the value of PPO in the most recent bottom of PPO
y8=valuewhen(oscMins, currenttrough4, 1) // identifies the value of PPO in the SECOND most recent bottom of PPOy9=valuewhen(oscMins, currenttrough6, 0)
y10=valuewhen(oscMax, currenttrough7, 0)bulldiv= BottomPointsInPPO ? d[1] : na // plots dots at bottoms in the PPO
beardiv= TopPointsInPPO ? d[1]: na // plots dots at tops in the PPOi = currenttrough5 < highest(d, div_lookback_period) // long term bearish oscilator divergence
i2 = y10 > long_term_bear_filt // long term bearish top divergence
i3 = delayedhigh > long_term_bear_filt // long term bearish delayedhigh divergencei4 = currenttrough4 > lowest(d, div_lookback_period) // long term bullish osc divergence
i5 = y9 < long_term_bull_filt // long term bullish bottom div
i6 = delayedlow < long_term_bull_filt // long term bullish delayedbottom divplot(0, color=gray)
plot(d, color=black)
plot(bulldiv, title = “Bottoms”, color=maroon, style=circles, linewidth=3, offset= -1)
plot(beardiv, title = “Tops”, color=green, style=circles, linewidth=3, offset= -1)bearishdiv1 = (y10 > y2 and oscMax and y3 < y4) ? true : false
bearishdiv2 = (delayedhigh > y2 and y3 < y4) ? true : false
bearishdiv3 = (long_term_div and oscMax and i and i2) ? true : false
bearishdiv4 = (long_term_div and i and i3) ? true : falsebullishdiv1 = (y9 < y6 and oscMins and y7 > y8) ? true : false
bullishdiv2 = (delayedlow < y6 and y7 > y8) ? true : false
bullishdiv3 = (long_term_div and oscMins and i4 and i5) ? true : false
bullishdiv4 = (long_term_div and i4 and i6) ? true : falsebearish = bearishdiv1 or bearishdiv2 or bearishdiv3 or bearishdiv4
bullish = bullishdiv1 or bullishdiv2 or bullishdiv3 or bullishdiv4greendot = beardiv != 0 ? true : false
reddot = bulldiv != 0 ? true : falsealertcondition( bearish, title=”Bearish Signal (Orange Circle)”, message=”Orange & Bearish: Short ” )
alertcondition( bullish, title=”Bullish Signal (Purple Circle)”, message=”Purple & Bullish: Long ” )
alertcondition( greendot, title=”PPO High (Green Dot)”, message=”Green High Point: Short ” )
alertcondition( reddot, title=”PPO Low (Red Dot)”, message=”Red Low Point: Long ” )plot(y10>y2 and oscMax and y3 < y4 ? d :na, title = “Bearish Divergence1”, color=orange, style= circles, linewidth=6)
plot(y9<y6 and oscMins and y7 > y8 ? d :na, title = “Bullish Divergence1”, color=purple, style=circles, linewidth=6)
plot(delayedhigh>y2 and y3 < y4 ? d :na, title = “Bearish Divergence2”, color=orange, style= circles, linewidth=6)
plot(delayedlow<y6 and y7 > y8 ? d :na, title = “Bullish Divergence2”, color=purple, style=circles, linewidth=6)plot(long_term_div and oscMax and i and i2 ? d :na, title = “Bearish Divergence3”, color=orange, style= circles, linewidth=6)
plot(long_term_div and oscMins and i4 and i5 ? d : na, title = “Bullish Divergence3”, color=purple, style=circles, linewidth=6)
plot(long_term_div and i and i3 ? d :na, title = “Bearish Divergence4”, color=orange, style= circles, linewidth=6)
plot(long_term_div and oscMins and i5 and i6 ? d : na, title = “Bullish Divergence4”, color=purple, style=circles, linewidth=6)Thanks for your help and best regards!!
Mattia
09/24/2019 at 7:25 AM #108302The PPO divergences indicator has already been converted, look at this post: https://www.prorealcode.com/topic/ppk-tradingview/
Please update your country flag and use the appropriate page to ask for code conversion next time: Ask for a free code conversion
1 user thanked author for this post.
09/29/2019 at 1:08 PM #108747Hallo Nicolas,
Thank you for your post. Great help.
It would be even greater if this indicator also contains the codes for Higher Low and Lower High.
Is it possible for you to add this to his indicator or make an additional one?Thank you in advance.
09/30/2019 at 8:46 AM #108855You can try this one: https://www.prorealcode.com/topic/help-with-higher-high-lower-low-price-swing-indicator-and-segment-drawings/#post-80673
It has all points: HH LL HL LH
04/21/2022 at 3:55 PM #192025Hello, I’ve the same problem, I need help to convert some scripts from Tradingview to ProRealtime.
Here is the code :
//@version=4
study(title=”14/30 SMA Split Divergence”, overlay=false)
fourteen = sma(close, 14)
thirty = sma(close, 30)
//plot(short, color = color.red)
//plot(long, color = color.green)
float divergence = fourteen / thirty -1
plot(divergence, style = plot.style_columns, color = divergence >= 0 ? #59FF00 : #FF0000)
band2 = hline(0, color = color.gray, linewidth = 1, linestyle=hline.style_solid) -
AuthorPosts
Find exclusive trading pro-tools on