TradingView
millerrh
4 Ara 2019 22:40

Swing High/Low 

Bitcoin / United States DollarCoinbase

Açıklama

Plots the swing high and low points based on user configurable look back settings. Also allows you to plot the most recent swing low as a horizontal line for obvious stop point on long setups.
Yorumlar
Rise_of_Skywalker
Thank you for your good work.
Could you share add additional Arrow Up when current Close higher than Swing High?
millerrh
@Rise_of_Skywalker, Thanks for your comment. I actually do not want to do this...I use this script personally and want to keep it clean. I don't really find a value in that because you can easily see if the body of the candle is above the line without an arrow. I think it would just clutter it without more additional useful information. The code is freely available to copy if you would like to make another script out of it and do this though.
Rise_of_Skywalker
@millerrh, Thank you for your reply.
I actually want to have an alarm when the 1st candle close above the Swing High.
I am not very familiar with the coding.
Is the Swing High is "pvthi_"
c > pvthi_

Thanks
millerrh
@Rise_of_Skywalker, Check out my script "Breakout Trend Follower" it basically does this, but instead of waiting for the candle to close, it notates it as soon as the level is breached. I actually backtested both waiting for the candle to close and market buying right when the level is broken and the immediate buy approach gave better results.
IAMABUNDANCE2021
hey there this thing is great i changed the inputs all the way to one and its perfect i love details and this could very beneficial for alot of people thanks for your work not a big indicators fan but this was pretty well crafted cheers
candleLighter99
Thank you for the contribution millerrh! I am new to pinescript is it possible to broadcast the event of Swing High or Swing low to another indicator or strategy? What I am looking to do is create a strategy that uses event signals from multiple indicators. So for example, an event is broadcast if a swing high or swing low was created in the last 2 bars. Any suggestions on how I can achieve this? Thanks in advance.
millerrh
@candleLighter99, You can do this by taking the coding for my script and putting it inside of another script that combines multiple ideas into one script. It does require learning Pine coding to do this, but this is actually how I started coding. By copying other's code you can figure out how it works and make adjustments and additions to it to create your own version of what you are thinking of.
candleLighter99
@millerrh, thanks. I will keep learning :)
rishiwick
I didn't understand the role of "maxLvlLen" variable , as its value is never changed from 0. Could you please elaborate why have you used this variable?
millerrh
@rishiwick, It's been awhile since I created this and at the time was way less versed in Pine Script. It's likely a function of me experimenting with values and leveraging stuff I found written elsewhere that I didn't understand completely. I've since re-written this code in other scripts and got rid of that, so I likely realized what you did:

//Removes color when there is a change to ensure only the levels are shown (i.e. no diagonal lines connecting the levels)
pvthis = fixnan(ph)
pvtlos = fixnan(pl)
hipc = ta.change(pvthis) != 0 ? na : color.new(color.maroon, 0)
lopc = ta.change(pvtlos) != 0 ? na : color.new(color.green, 0)

// Display Pivot lines
plot(showPivotPoints ? pvthis : na, color=hipc, linewidth=1, offset=-lbHigh, title="Top Levels")
plot(showPivotPoints ? pvthis : na, color=hipc, linewidth=1, offset=0, title="Top Levels 2")
plot(showPivotPoints ? pvtlos : na, color=lopc, linewidth=1, offset=-lbLow, title="Bottom Levels")
plot(showPivotPoints ? pvtlos : na, color=lopc, linewidth=1, offset=0, title="Bottom Levels 2")
Daha Fazla