midtownsk8rguy

vline() Function for Pine Script v4.0+

It's been a long time coming, but here is a versatile vline() function applicable to PSv4.0+ utilizing line.new(). I decided to finally figure this out at the request of another member recently. I have been waiting myself for months, but it's now time for an idea who's time has come to unleash upon planet Pine Script. It's a handy little function I believe will be very useful in the future. It only requires 4 parameters of BarIndex, Color, LineStyle, and LineWidth. Make sure you place it in an appropriate if() block to use it properly. As displayed above, this plots every 10 bars using a conditional statement employing the rarely used modulus operator.

Use it as you please, this is free code to implement into your new Pine projects. I don't require an credit for any one to use this function. I simply don't want any credit. I would however like to see some great ideas utilizing this when I randomly and accidentally come across them in the public library. I didn't know where to put this script, so I just tossed into the "Trend Analysis" category. I'm pondering we members need a "Miscellaneous" category some time in the future.

The comments section below is solely just for commenting and other remarks, ideas, compliments, etc... regarding only this indicator, not others. If you do have any questions or comments regarding this indicator, I will consider your inquiries, thoughts, and concepts presented below in the comments section, when time provides it. When my indicators achieve more prevalent use by TV members, I will implement more ideas when they present themselves as worthy additions. As always, "Like" it if you simply just like it with a proper thumbs up, and also return to my scripts list occasionally for additional postings. Have a profitable future everyone!
Notes de version: Provided recommended function permutations that might be suitable for study(overlay=true) and study(overlay=false) scenarios. In some situations with the original script release, auto-scaling was affected by line.new() with unintended expectations.
Supprimer des scripts favoris Ajouter aux scripts favoris

Commentaires

hello , how can i plot a single vertical line on chart for specific year , month , day determined by input function ?
Répondre
ahmedsindi ahmedsindi
@ahmedsindi, i mean how to input date like ( 24/3/2020) to make vertical line at that specific date ?
Répondre
This is nice, but it doesn't show how to apply a line to a certain day or hour. How can this be included as an input?
Répondre
@EAML,

//@version=4
study("My Script")

vline(BarIndex, Color, LineStyle, LineWidth) => // Verticle Line, 54 lines maximum allowable per indicator
return = line.new(BarIndex, -1000, BarIndex, 1000, xloc.bar_index, extend.both, Color, LineStyle, LineWidth)

isMonday() => dayofweek==dayofweek.monday

if(isMonday()) // Used on 1Y chart
vline(bar_index, #FF0000ff, line.style_solid, 3) // vline() on Mondays
plot(close)

The condition inside the if() determines if vline() is plotted. Plotting on a certain hour would be more complex logic.
Répondre
Hi, how to modify to change for weekly interval start day of the week?
Répondre
Accueil Screener d'actions Screener Forex Screener Crypto Calendrier économique Comment ça marche Caractéristiques du graphique Prix Parrainer un ami Règles de conduite Centre d'aide Solutions site web & courtier Widgets Solutions de cartographie Bibliothèque de graphiques allégés Blog & News Twitter
Profil Paramètres du Profil Compte et Facturation Parrainer un ami Mes tickets au support Centre d'aide Idées Publiées Followers Suivi(e) Messages privés Chat Se Déconnecter