Showing posts with label this. Show all posts
Showing posts with label this. Show all posts

Sunday, 20 October 2024

Pine Scripters Network • Join Our PINE SCRIPT COMMUNITY!

hi traders in this video i'm excited to introduce you to the pine scriptures network the pine scriptures network is a new online forum i've set up and it's intended to be a community where pine scriptures such as yourself can communicate with each other share your scripts share your code and help each other with your own scripts and today i just want to introduce you to the website show you how to sign up and give you an idea of what to expect so if you go to pinescripters.net that will bring you to this page here and there's not a lot happening here yet because i'm the only user of this website but hopefully soon we'll have a bunch of active members here helping each other out with their scripts so the first thing you want to do is get rid of this cookies notification you want to come up here and click on register and here is the agreement registration agreement there's nothing hidden here this is just a disclaimer about trading and the just generic forum rules nothing too complicated i don't want your firstborn child or anything crazy like that you want to agree to these terms and then fill out this information with whatever relevant information you want to include so you need to input a username an email address password and down here this is optional this is your trading view profile you don't have to put this in if you don't want to and then finally this is the important part this is the registration code box so depending what code you put into this box will determine what group you added to when you sign up to the forum so at the moment there are three groups there's the pinescript mastery students group there's the pinescript mastery course graduates group and there is the pinescript mastery mentorship group so anyone can sign up to this website it's completely free to access but there are a handful of private forums that are only accessible by certain groups of people so anyone who signs up to the basics course or finds this website over google or from my youtube channel they can sign up for free and they get access to their own forum and this will be easier if i just show you what i'm talking about so everyone has access to these forums here you need to be registered in order to post in these forums but these forms are accessible by anyone same with these ones here and the feedback and support section but there are a handful of private forums so first there's the pine script scholars forum this is only for people who are enrolled in the pine script mastery course this is for you guys to talk among each other and you won't get any random trolls or anyone that's um that's not on your level of pine script expertise coming in to contribute to your conversations the next one is the pinescript masters forum now this forum is restricted only to people who have graduated the pinescript mastery course finished all the lessons in the course so this is for people who want to have a little bit more of a sophisticated conversation about pine script with each other and they know that the only other people who can comment on their discussions are people who are at the same level as them in their pine script education or even more educated and then finally there's another form here that you can't see unless you're signed in as a mentorship student but there's a pine script mentorship section as well so anyway let's go back to the register page and i'll explain what you do down here so because this is on youtube and it's open to everyone unless you're enrolled in the mastery course in which case you'll get an email with a code to sign up with then you can only sign up as a free user and you can just ignore this box here and don't put anything into it you just create a free account and you can communicate with other free users on the network if you want to access any of those restricted forms that i just mentioned you'll need to upgrade to the mastery course or graduate the mastery course if you want to talk to other mastery course graduates so if you have access to a code once you put it in here and you click submit you'll be automatically enrolled in the relevant group and once you confirm your email you can come in and access the form and start sharing your thoughts with the community now if you've already created an account on this forum and then you receive a new code so for example let's say you purchased a mastery course and you sign up as a mastery course student and then eventually you graduate the course and you complete all the lessons and you want to change your membership group type to the graduate group you need to come up here to your user control panel so click on your profile picture click on user control panel and come up to user groups and then in here you can type in the registration code that you receive and the codes here are exactly the same as they are on the other registration page other than that it just operates as a normal forum so there's a few guidelines and information here so i encourage you to read through this when you first sign up but there's nothing really fancy here it's just you know don't spam be kind to each other keep all topics relevant to pine script coding and don't advertise anything on the forum without asking me first so that i can verify that it's not something malicious or or low quality of course you are absolutely welcome to advertise your own scripts your own projects even your own websites but if you're going to advertise anything external to this platform other than a trading view script please let me know first so that i can just ok it and vet anything that goes through here because i don't want any scammy stuff happening or any spamming to occur i want to keep this as clean as possible and as useful as possible to everyone who signs up other than that there is also this forum here the show-and-tell slash request so you can share your scripts here with the community everyone has access to this forum and same with request scripts you can request scripts from other people in the community and so if you're a student say you're a pine script mastery core student and you want to test your skills i'd encourage you to come and check out if anyone requests a script in here maybe you can help them out and maybe you can test yourself and see what you're capable of there's also a forum for general trading discussions so i prefer if everyone can keep their trading related discussions that don't involve panscript in this forum and then there's a feedback and support section as well so i definitely want to hear your feedback if there's something you feel is missing from the site or something that's not working as you would like it to just let me know and this is supposed to be community effort and i really hope you guys will get involved and help me make this community as useful and engaging as possible this is for your benefit not for my benefit i created this for the pine scripting community so that when you guys have questions if you shoot them to me and i don't have time to answer them maybe you can throw them up in this form as well we can all benefit from the answers and maybe you guys can help each other solve each other's problems i plan to expand this in the future i'd like to have like some sort of store for people to sell their own scripts on here or just some sort of script library would be great so that you guys can get the most out of this but for now this is just a community for you to talk amongst each other help each other out and i hope you like it i hope you find it valuable that's it for this video i hope to see you over there if not that's fine there's no pressure to join this community this is just for fun and it's purely optional if you guys want to join up and help each other out so that's it for this video i'll see you in the next one take care guys [Music] you

Pine Script [OUTDATED V4] Tutorial Lesson 5 TradingView Script Alerts

hey guys this is Matt welcome back to
zen and the art of trading today's video
is gonna be extremely short I'm just
going to explain to you guys how to add
alerts to your scripts so you can add
this alert functionality to scripts that
you create or scripts that you download
from other people say you find a script
on tradingview that you like they look
off but it doesn't generate alerts by
adding this functionality to the script
you can basically turn any script out
there into an alert generating script so
I'm gonna be building off lesson 4 so if
you haven't watched that video I'll
leave a link in the video description
and go back and watch how we did this
the script just generates RSI signal so
when the RSI goes overboard or oversold
it just plots as visual signals to the
chart so I'm just gonna rename this to
lesson 5 now this is going to be
extremely simple we're just adding one
line of code here and this is going to
send out an alert if this particular
candle meets our conditions so all you
need to type here is alert condition
open parenthesis and now this function
here takes three inputs takes a boolean
input which is the trigger for the alert
if the boolean is true then the alert is
sent out it takes a title which is for
the pop-up box and the email heading and
it takes a message which is like the
body the text body of the alert so I'll
explain all this as I go first of all
the bully and we're going to combine
these two boolean values here into one
so what we're going to do here is were
going to say if the RSI is overbought or
the RSI is oversold , this alert will be
triggered now the title of the alert is
going to be RSI signal and then we'll
put another comma and then the message
is going to be set to RSI signal
detected for and now trading view added
this
this new cool alert functionality here
where you can use these placeholders
special placeholders in order to inject
certain information from the chart so
you can inject the closing price at a
time etc if you hit the question mark
here it'll do it have a whole list of
things so what we're going to use here
is probably just the ticker the ticker
will do so you can see here that if you
were to use all of this text this is
what it would replace as so you can
reference the exchange or the in forex
this case the broker you can list the
ticker symbol the currency pair in our
case you could have the price on there
and volume and there's a whole bunch of
things you can choose from so I'll leave
that for you to look through in today's
example we're just going to be using
ticker so if I just throw that in there
hit save that's literally it this script
is now ready to generate email and pop
up alerts SMS alerts push notifications
all of that stuff straight to your phone
whenever one of these signals is
generated so it's amazingly simple it's
what my fit one of my favorite things
about trading view is how simple they
make this stuff and just quickly before
I move on I just thought I should better
point out the fact that if you hover
your mouse over a function did you run
familiar with it'll tell you exactly
what inputs it takes so you can see here
it takes a condition a title and a
message and if you hold down ctrl or
command on a Mac and you click on the
function it will pop up this help box
which will explain in great detail what
the function does so now if you hit the
create alert button the way that you
would set an alert for the script is you
just come down here and click the name
of your script and that's it it's ready
to go you select your options here
notify an app show pop-up etc you can
play a sound whatever you like and you
can change the message down here so yeah
that's up to you that's personal all of
this is personal preference but up here
in under options you can set how the
alert is triggered so you can set set it
trigger only once and that means that if
the signal shows up on your chart you
get one alert and then the alert will
disable itself once per bar means that
it will repeat every time there's a new
bar so if you get multiple signals like
this it'll send out an alert on this one
then you won't get an alert for these
this to these two candles here but then
you get another one here another one
another one all in a row so that's
pretty helpful for day trading but if
you are trading in the higher time
frames it just gets annoying so you
probably don't want to have that set my
favorite one to use is once per bar
closed so this will only trigger see
once per bar will trigger even before
the candle closes so if you get an alert
here say that this next candle went
overboard and then you got an alert st.
was overbought but then the candle
closed and the signal was invalidated
you still get an alert even though the
setup didn't really occur so once per
bar closed is my personal favorite
setting to use that means it will only
send out alerts for confirmed signals
and once per minute it's
self-explanatory
and that's it all you do is hit create
it'll be added to your list of alerts
let me clear out some of these inactive
alerts and there you go done simple as
that so if I just quickly change these
settings to the traditional RSI values
just for this example hit OK and create
a new alert
I'll take show pop-up so we'll get an
actual pop-up to my screen I'll change
this to that change it to once per bar
closed and hit create then once this
candle closes here we should get an
alert sent to our charting platform and
my phone so let's wait and see what
happens
three two one dawn and there we go
there's our alert and I can hear my
screen beeping in the background she's
probably gonna wake my girlfriend up
it's a bit early here in the morning so
whoops forgot about that but anyway
that's it done so that's the end of this
lesson
good luck with your trading good luck
with your coding and I'll see you in the
next lesson where we'll go over how to
detect
patterns see there have a great day
goodbye
[Music]

Pine Script [OUTDATED V4] Tutorial Lesson 1 Introduction Hello World!

a little hey guys this is Matt and
welcome to my trading view pine script
guide for beginners in this video series
I'm gonna cover topics regarding pine
script which is a trading view
programming language it's a very basic
programming language but it can allow
you to achieve some pretty powerful
stuff I've been using the scripting
language for a couple of years now I use
it to create trading tools that assist
in my trading process now pine script
doesn't allow you to automate your trade
execution or trade management unlike a
language like MQL but what it does allow
you to do is automate a significant part
of your trading process such as analysis
stop-loss sizes trailing stops setup
detection all kinds of things and so
basically the way I treat pine script is
I use it to be my second pair of eyes on
the market for the most part I either
use it to create scripts that send me
alerts so I can stay on top of the
market I use it to create tools to help
in my back testing process that's a big
one and overall I've just found that if
you can master the basics of pine script
you can dramatically increase your edge
over the markets we live in a world
where technological prowess and
understanding technology and and
computers and programming languages is a
very valuable skill to have now when I
first started learning how to code I was
probably 16 or 17 I used to make
computer games I'm embarrassed to admit
this but I used to make runescape
private server right up until the
creator of that game try to sue me and
shut down everything I was working on
but I had a lot of fun with that and
I've always had a passion for computer
programming
I started out learning Java which is an
intermediate programming language and I
got quite good at it but over the years
I've lost that skill because I haven't
practiced it enough but thankfully I've
moved over to Pine script now which
is very similar to a lot of programming
languages that are out there but it's
also very lightweight it's very simple
very easy to pick up very easy to learn
you don't need to be an expert in
programming to learn this stuff and I'm
excited to show you what's possible with
Pyne script in this guide so without any
further ado let's get into this stuff
I'm going to assume you have zero
experience with programming or and
specifically Pyne scripts so if you're a
little bit ahead of the beginner stages
you might want to skip this video and go
into more advanced topics but if you're
new to this stuff this is going to be
really important to learn so first of
all you want to take this mouth of yours
come all the way down here and click on
the pine editor this will open the pine
script editor and this is where the
magic happens now this is the default
script everyone will get this when you
open this for the first time and I'm
gonna run you through each line of code
here and just tell you what it does so
that you have a basic understanding of
what you're looking at so this first
line here is just a bit of legal jargon
it associates the Mozilla public license
with any code you create and basically
that's just like an open-source license
I'll go into detail about your options
later down the track in terms of keeping
your scripts private and protecting your
source code if that's something you you
want to do but for the most part if
you're anything like me you'll want to
release most of the things you create to
the public and so this this license here
will just protect you from nefarious
actors on the Internet that's just a
standard tradingview precaution and here
you'll get a little copyright symbol and
then your training view username these
these two lines here are what is
referred to as comments you see these
two forward slashes at the start of this
line what that is saying is it's telling
pine script it's telling the interpreter
or the compiler which is a fancy word
for a computer translator so all of this
English language code needs to be
translated into a language that the
computer understands that's all done for
you that's the magic of being a program
in the modern day is you don't have to
know what's going on behind the scenes
in order to code many years ago you had
to write in what's called assembly code
and it was an absolute nut you had to be
a NASA level intelligence in order to
achieve anything meaningful with that
language but today
even a monkey can create if I can create
some of the scripts I've created with
this then you'll be amazed of what
you'll be able to achieve because I'm
hardly a rocket scientist I come from a
music background I was a musician before
I became a traitor and I was a dabbler
in programming languages but now I have
a pretty firm grasp on this stuff and if
I can learn it you guys can too so I
hope that's encouraging to you but
anyway these two lines here it's telling
the computer interpreter to ignore these
lines these aren't relevant to the
script this is for human eyes only you
can use these comments to say whatever
you want for the most part it's used to
either explain what your code does or to
leave notes for yourself or you can
comment out certain lines of code that
you don't want to delete because they
might be valuable later down the line
but maybe you're dealing with some bugs
and you want to isolate what's going on
you can just comment out a couple of
lines of code and using this in there
and the script will you just ignore
those lines but for the most part you'll
be using comments to leave yourself
notes or leave notes for others so you
could say something like the script is
for teaching beginners how to use pie in
script simple as that the interpreter
the compiler will ignore this line but
you know exactly what it means and
that's very valuable when you start
creating extremely complex scripts I
have a bunch of scripts that I've
written in the past that I have no idea
what they do anymore because I didn't
comment them heavily enough so this is
something this is a good habit to get
into in the beginning this third line
here even though it starts with two
forward slashes it's technically not a
meaningless comment it's not it's not a
comment that's ignored by the compiler
but it's also not a part of my own
script code what this does is it tells
the compiler what version of Pyne script
to target so the best example I can give
is is the English language we have Old
English from many centuries ago which
you know Shakespearean type English
which isn't appropriate for today's day
and age and if you were to talk that way
you wouldn't make friends very easily
and so that's an old version of English
of the English language and today's
version is for 2.0 English 2.0 and it is
colloquial it's easy to understand
there's a lot of slang that sort of
thing
and so you could think of Old English as
version one and if you were to speak in
that language hardly anyone would
understand you but there's times where
that's appropriate because maybe you're
studying Old English or you're trying to
write something in that context
but for the most part you'd want to use
the latest version obviously and it's
the same at pine Script so pine script
has version one two three and now it has
version for each variation of these pine
script versions have different features
different syntax different syntax is
another word for grammar basically its
programming jargon for grammar so commas
brackets that this is syntax in here you
know you've got the two quotes and you
got brackets that's referred to as
programming syntax if you change this to
version 3 there'll be certain features
of pine script that you wouldn't have
access to anymore so for the most part
you can just leave this line you'll want
you'll unless you're working on an old
script that's the purpose of this is to
allow for backwards compatibility with
previous pine script versions for the
most part you're gonna want to leave
this as it is because you're going to
want to work with the latest version of
pine script obviously if you want access
to all the latest features and bells and
whistles then you're gonna want to leave
this as version 4 now moving on this is
where things get a little more
interesting a little more complex so
this first line here dictates what type
of script this is going to be now
there's two types of scripts that you
can create in pine script one is an
indicator like any other indicator you
would have seen like RSI MACD moving
averages that all falls under indicator
the other script option is a strategy
script now a strategy script is used for
back-testing strategies over historical
data automatically I'll show you a quick
example of one of the strategies scripts
I've created so here you can see that
the script places market trades so you
can see it went long here at the close
of this candle and exited for a profit
at the profit target and now adding up
all of these over about 208 trades over
the past year or two of data it had a
53% win race so 53% of these trades hit
target before they hit their stop-loss
so this is quite advanced we'll go over
this stuff much later in the course but
I'm just showing you what this strategy
script is for for the most part we're
going to be working with standard
indicators so to write a standard
indicator script you need to name this
study now this line here is sort of like
a letterhead you know on a letter you
would have something at the top of the
page explaining what the letter is for
or who it's intended for that's what
this does for the pine script compiler
it tells a pine script compiler that
this script or writing is an indicator
script not a strategy script and so the
two scripts get access to entirely
different features we don't want to be
working with any of the mock trade
features so we're just gonna leave this
as it is for the next few videos and you
can name this whatever you want I'm
gonna call this beginner script just for
an example describing this next line
will be easier basically add to chart
you'll see that now this this blind plot
is telling the script to draw the
closing price to my screen and it's that
simple
from three lines of code you can delete
these if you wanted to and this will
still work and there you go three lines
of code and we're already drawing the
beginnings of an indicator I'll show you
one more thing before I wrap this up and
then we can move on to the next video
where I'll go into much more detail
about the code part of this if you just
simply add this line of code in here oh
this is saying set the variable called
overlay to true and true this is called
a boolean it's a funny word you'll get
used to it but it's called a boolean in
programming and that's just another
fancy word just like how lawyers have
their own jargon as you would know the
financial industry has its own jargon to
make things overly complex so that only
other financial experts can understand
it programming is exactly the same
there's a bunch of jargon terms that
only other programmers will understand
and boolean is one of them all it means
is that yes or no 1 or 0 it's pretty
simple so this little line here is
saying set the inbuilt
variable overlay to 1 / yes / on /
now if I remove this from my chart save
it and then click Add to chart now we'll
draw the line it's a bit hard to see but
you can see it draws the line on to the
actual chart instead of to its own box
now this is obviously really useful for
drawing moving averages or like some of
my scripts this script is an overlay
script and it draws directly to the
chart you can see it draws a moving
average in a bunch of signals and
stoploss placements targets I'm gonna
show you guys exactly how to build
something like this and this is the
beginnings of that and so that's it this
lesson I hope you found it interesting I
hope you found it useful and strap in
because we're gonna get into much more
complicated stuff than this in the
videos to come alright thanks for
watching everyone thanks for listening
good luck with your trading good luck
with your coding and I'll speak to you
in the next video
[Music]
[Applause]
[Music]
you
[Music]

MERGING Stochastic & RSI • Pine Script [OUTDATED V4] Tutorial

hi traders in this lesson I'm going to
show you how to draw the RSI indicator
over the top of a stochastic indicator
by creating our own our a science to
cast ik code so let's get into it start
a blank script here gonna remove this
script going to call this PS MC
stochastic and RSI I'm gonna save these
scripts add it to my chart and we're
good to go so the first thing I want to
do here as always is get my user input
user input and we needed several inputs
here in order to draw a fast stochastic
we need the K input we need the D input
we need an overbought level and we need
an oversold level so I'm going to use
the input function for all of these and
this first input function is going to
get our K length so I'm going to title
this input function K length I'm gonna
give it a type of input integer and a
default value of 14 which is the
standard default for a stochastic
indicator next up we need to get our d
input which is going to be a moving
average of the k variable so here I'm
going to give it a title of d.length a
type of input integer and a default
value of 3 so these are the default
parameters for your standard stochastic
indicator we have a key length of 14 and
a moving average a simple moving average
of the K length of a 3 period moving
average and when we calculate the actual
stochastic this will make sense later on
in the script so next up we need our
overbought and oversold levels so I'm
going to title this over board threshold
and I'm gonna give it a type of input
float and a default value of 80 so you
could set this to integer if you wanted
to but I find that it's better to set it
to a float because then your user can
come up into the settings menu and
change the overbought level or oversold
level
more minutely so you could change this
to 80 point one for example it just
gives you a little bit more control a
little bit more flexibility with your
scripts parameters so I'm just gonna
copy this line of code here and change
this to say oversold and change the
default value for the oversold to 20 so
by default we're using our overbought
and oversold levels as 80 and 20 but you
could change these to whatever you
wanted to nineteen point nine for
example something like that but we'll
leave it as 1820 for now and let's move
on to calculate our stochastic so in
order to do that the stochastic
indicator is similar to the RSI
indicator in that it's an oscillator
that oscillates between a value of 0 and
100 now there's a mathematical formula
for this indicator that's quite simple
you no need to know this and need to
understand what this is or how it works
in order to use it but I like to have a
thorough understanding of all the
indicators that I use and so I will
write out the formula for this
stochastic and it goes a little
something like this 100 times the closed
minus the lowest low over the past 14
candles divided by the highest high over
the past 14 candles minus the lowest low
over the past 14 candles or of course
this 14 could be whatever we set out
k.length to so let's write this out in
prime code so we need to create a new
variable called K and we're gonna set
this to 100 times we need to open a pair
of parentheses here I'm gonna get the
closing price minus the lowest low over
our K input length so by default 14 then
close that parenthesis you don't need to
have these parentheses here in closing
this entire statement this would work
just as well but I like to just for
visuals sake I like to wrap any equation
in parenthesis so I just know for sure
what arithmetic operators are being
executed within these parentheses but
anyway now we need to divide whatever
this result is by
the highest high / out key input length
- the lowest low / our key input length
and I'm just gonna wrap this entire
calculation in a set of parentheses just
so that we know for certain that this
value here whatever this turns out to be
is going to be multiplied by a hundred
here so there's our stochastic formula
that will give us our fast stochastic
next up we need to calculate our D
variable which is simply a simple moving
average SMA this will use the inbuilt
simple moving average function we need
to pass it our K input and our length
which is d input so now we're
calculating a simple moving average of K
based on a three period length and our
user can change this to whatever they
want by changing the D length input
parameter in the settings menu so that's
it we have now calculated how stochastic
I'm gonna get rid of this formula here
just to tidy the script up a little bit
and all that's left now is to draw data
to chart so for this I'm going to plot
out K variable I'm going to give it a
color of color purple I'm gonna give it
a title of K so that we can adjust this
in the settings menu if you want to next
I'm going to plot the D variable here is
D value and it's gonna have a color of
color orange and a title of D then we
need to pluck our over board an oversold
levels so OB level will give it a color
of color dot red and a title of
overbought and I might set the line
width here to two as well just so it's a
little bit thicker and it stands out a
little more on our indicator box and
then finally I'm just gonna copy this
entire line of code paste it down here
change this to oversold level change the
color to green and change our title to
oversold so now we're drawing our
stochastic and if I save these scripts
and we minimize this pine editor there
we go just like magic
we are drawing our stochastic indicator
onto our chart and everything appears to
be working perfectly
so just before I move on I should point
out that you can achieve this
calculation using an inbuilt function in
pine script so I've written this formula
out manually because I thought you guys
might find it interesting how to achieve
this so that if you ever run across an
indicator out there in the wide world of
the internet that pine script doesn't
provide an inbuilt function for you can
just write out the formula yourself but
if we wanted to we could have just used
the inbuilt stochastic function so this
function here takes four input variables
it takes a source a high a low and a
length so we could write in here close
high low and just we could put 14 in
here for a default stochastic length or
just copy our K input into that and now
if I saved these scripts I'll be getting
exactly the same thing drawing onto our
chart but for the purposes of this
demonstration we're just going to leave
this custom formula in just because it
makes this lesson a little bit more
interesting so now if you were to try to
detect setups
whenever the RSI goes overboard or
oversold we'll try to identify
divergences such as this divergence here
you can compare whatever price is doing
to your K variable or your D variable so
if you wanted to detect the market being
oversold you could see if the closing
price is below K or D and then if this
condition is met then you can do a bunch
of other calculations and we're not
going to go into that in this lesson
because this lesson is just about
drawing the stochastic and the RSI which
we'll get to next onto your chart and
I've already shown you how to detect
candlestick patterns and work with
conditions so if you want to make this
more complicated you can go ahead and do
that in your own time but next up before
we finish this lesson let's draw our RSI
on as well so here I'm going to create a
new input variable called RSI length and
we're gonna give it an input title of
our side length a type of input integer
and a default value of 14 so by default
we're gonna calculate the same arrow
sign length as out K and on here I'm
just gonna add and RSI and we're going
to calculate our
using the inbuilt RSI indicator function
which takes two input parameters and
that is a source price so in this case
we're just going to calculate it on the
closing price and we're gonna give it a
length of RSI lengths so by default this
will be a 14 period RSI and now if we
come down here we'll plot the RSI onto
our chart I'll give it a color of color
black and I'll give it a line width too
as well so that it stands down a little
more and we'll give it a title of RSI so
now if I save the scripts we'll be
getting our our side drawn over the top
of our stochastic so that we have it and
just before I finish this lesson I'm
just gonna change the color of this RSI
to red or green based on whether it's
overbought or oversold just so we have
some visual cues of what's going on with
that so here I'm gonna change this to
say is our RSI level greater than our
overbought level question mark then if
this is true then set the color to color
red otherwise is the RSI less than our
oversold level question mark if so and
set the colored color green and if
neither of those conditions are true
then we set the color to black and I
should probably change these to less
than or equal to and greater than or
equal to so if the RSI hits our
overbought or oversold level the color
of the RSI will change color and if I
come to the settings menu change the RSI
length to let's say seven and I save
those settings here we go you can see
that when the RSI goes over bought we
get a red RSI drawing and when it goes
beneath the oversold level it turns
green and there we have it we're done so
that's it for this lesson I hope you
found that helpful if you did and you
want to learn more about Pine scripts
head over to pine skip mastery com here
you'll find my advanced pine script
courses and my basics course which is
free so if you want to learn more about
pine script head over here and you'll
find out a little bit more about me and
a little bit more about pine scripts I
hope you found this lesson interesting
and helpful I'll see you in the next one
[Music]

How To Use LABELS • Pine Script [OUTDATED V4] Tutorial

hi coders and traders this is Matthew
from pine script mastery calm in today's
lesson I'm gonna be addressing a
question I got from a student recently
about drawing text onto your chart so
this student asked can the text
parameter be referred to a string
variable on the plot shape function he
wants to draw the difference of two emas
converted into a string variable and
then placed into the text parameter of
the plot shape function now
unfortunately you can't do this in Pine
script because the text parameter of the
plot shape function requires a constant
variable meaning a variable that does
not change but in today's lesson I'm
going to show you how to achieve the
exact same thing plotting the difference
of two EMA's to your chart using the
label object so if that sounds like
something you'd be interested in stick
around and I'll show you how to achieve
that in this lesson so here I am in the
PI in script editor and all I've done is
create a blank script I've changed the
title and I've set overlaid it true so
let's get started with the code for this
lesson the first thing we need to do is
calculate the difference between two
EMAS
so here I'll create a comment here it
says calculate difference between 50 EMA
and 100 EMA and we're going to give this
variable a name of variable value and
this could be any variable that has an
integer or float value so what we're
going to do here is we're going to get
the EMA over the past 100 bars on the
closing price and we're going to
subtract that from the 50 EMA of the
closing price so now of course one way
you could plug this to the chart is to
just paste that in there save the script
and up here in the top left you will get
your value plotted to the chart that's
one way to achieve this but if you want
the text to be drawn directly onto your
chart beneath the candle or beneath a
price action setup or something like
that then you need to use the label
function so if we were to use the plot
shape function and we were to say draw
this on every bar on our chart and set
the text to first of all just test we
save the script we're getting a shape
drawn above all of our bars with the
text test but if we were to change this
to say two string
variable value and save the scripts get
an error the reason for that is that
this text parameter needs to be a
constant string meaning any string
variable that does not get changed in
our script at any time that doesn't help
us when we're trying to do what we're
trying to do here which is plot the
difference between these two EMAS to our
chart as text so we need to use the
label functionality so here we're going
to say create a label and the first
thing I'm going to do is create our
label text which is going to use the two
string function and what this two string
function will do is convert any variable
or value that we give it into a string
datatype so that we can pass it into the
text parameter of our label object so I
know it's a bit of a mouthful but I'll
show you and demonstrate how to achieve
that next so we're going to convert our
variable value into text that will
assign this label text variable to this
text string version of whatever this
turns out to be and next up we need to
create our label to draw this to the
chart so I'm going to just create a new
label object called our label and that's
going to be set to label dot new and
then open parenthesis to start using
this function so this label function
takes a number of function parameters
the first one is an x-coordinate and
that is going to be what bar number to
draw this on so if we just set this to
bar underscore index that will just
reference the current bar index on
whichever bar this script happens to be
running on and so by default if we leave
this as it is it'll just draw on every
bar on our chart the next parameter it
takes is a y-axis parameter and we don't
need to use this parameter because we're
just drawing it onto the bar we're not
drawing it anywhere else on our chart
except for just on the bar itself so we
can just write n/a in there the next
function parameter we need to define is
our text parameter and for this we're
going to pass our label text variable
here well you could just copy this and
paste it into here as well but then this
line gets really long so I'm gonna leave
that as that and of course you could do
any edits you wanted to with this string
such as adding on some sort of tag or
something like the simian photo
ticker ID and that sort of thing so
we'll leave that as its own variable for
now the next function parameter this
takes is an X location but that's an
optional parameter we're not going to
define that today because we've already
defined our x coordinate as bar index so
we don't need to give it an X location
we do need to give it a wire location so
we're going to set the wire lock to Y I
locked up below bar so this will set the
Y location to below the bar the next
parameter we need to put into this
function is the color so we'll give this
a color of color green you can set that
to whatever you wanted to and we'll set
the text color to color dot white so
we'll have white text over a green label
so here we need to write a few more
function parameters so I'm going to
start a new line here so I'm gonna put a
comma on the end of this line and then
continue this line on the next line with
a space one space indentation if you do
not include this indentation then the
pine Script compiler will not know that
you're trying to write this line of code
across multiple lines and you'll get a
compile error so always remember to
indent at least one space if you're
going to continue on to the next line
with your code so the next function
parameter that we're going to use here
is our style parameter and we're going
to set this to label dot and if we press
control space you'll get a list here and
if I start to write style here's a list
of all the styles we have to choose from
and there's quite a few but for today's
lesson we're just going to go with style
underscore label up and then we're going
to give it one more function parameter
which is our size we're gonna set these
size to size dot normal and now if I
save the script we will be getting
labels drawn on to our chart as you can
see here there's quite a few of them
they start to draw over the top of each
other and that's a problem yeah but we
can fix that later you can also see that
it's drawing the difference in the two
EMAS
in pits so if I add two exponential
moving averages onto my chart one is a
fifty EMA and one is a hundred EMA and
we measure out the
difference between these two EMAS you
can see we get around 89 pips which is
what this label here says that's eighty
nine point five blah blah blah pips if
you want to convert this into points in
the whole numbers all we need to do is
wrap these in parentheses and divide
this by Simeon firm in tick now if I
save the script these will be in whole
numbers and they'll be in points so here
we have 895 points between the EMAs and
if you wanted to get this in pips you
just divide this number again by 10 but
we'll leave it in points for now cuz
that's not important but before we
finish this lesson let's just tidy this
up a bit
by deleting any label that is not the
current label so in order to achieve
that all we need to do is delete our
label they came before the current label
so now if I save the script every time a
new label is drawn to the chart the
previous one gets deleted and we just
have one label drawing onto our chart so
now we're drawing the difference between
the EMA variables as a string text
variable using a label directly on to
our chart and there are multiple useful
use cases for this functionality for
example if you wanted to draw your
stop-loss price directly onto your chart
you can do so here so if I add on my
ultimate pull back indicator that I have
created in the past and I come into the
settings menu and turn on draw stop by
labels to the charm round it to a whole
number as well you can see that this is
drawing my stop-loss size in pips to the
chart which is in this case around 148
pips you rounded up to the nearest
number so that's one useful application
of this sort of information and my
favorite way to use this whenever I
detect a setup on my chart with a stop
loss in a target price I can draw that
information directly onto my chart so it
don't need to measure this out and I can
get an accurate reading of the distance
if I turn around our stop loss the whole
number off my stop loss is exactly one
hundred and forty seven point five pips
from the closing
of these set up candle so that's it for
this lesson
I hope you found that helpful if you did
and you want to learn more about pine
scripts head over to pine script mastery
com here you'll find my advanced pine
script courses and my basics course
which is free so if you want to learn
more about pine script head over here
and you'll find out a little bit more
about me and a little bit more about
pine scripts I hope you found this
lesson interesting and helpful I'll see
you the next one
[Music]

How To Use EMA FILTERS • Pine Script [OUTDATED V4] Tutorial

hi traders in this video i'm going to
show you how to create
an ema confluence filter for your
scripts
so basically what that means is here i
have two emas plotting onto my chart
we have a 50 ema here
and 100 ema below it and for this
particular script it doesn't matter what
entry reasons
you detect in your script you can be
detecting any candlestick pattern that
you like
but for today's example i'm keeping it
very simple and the entry reason we're
detecting is just simple engulfing
candles they don't have to be swing lows
they just need to engulf the previous
candle and
what this script is doing is first of
all
price must be above this 50 ema before a
valid
signal will be detected but the
50 ema must also be above the 100 ema
before a valid signal is detected and so
in today's
video i'm going to show you how i
created this script so first of all
let's remove the script
reset the chart and create a new blank
script so here i am with a blank script
let's get started first thing i'm going
to
do is always is get user input and for
today's video we're just going to get
two
uh inputs two ema length inputs so here
we have two inputs ema length one
ema length two of type integer and we're
just going to set it to 50 and 100 by
default
and the next thing we're going to do is
get the actual ema's
so we need ema1 is set to ema close
with the length of ema length 1 this
input here
and then we'll just copy this paste it
down here and change these to
two so there's our emas now we can draw
them to make sure that they're working
properly
so the first one i'm going to plot as
ema1
and i'm going to change the color based
on where the price is above or below it
so we're going to say
is the close above ema 1 if so set the
color to color.green
otherwise set it to color.red and we're
going to give it a line width of two
let's thicken it up a little bit now
copy this line of code paste it in there
change this to ema2 and we'll just get
rid of this because
it'll be confusing to have both ema's
changing color we'll
just set this second ema to color.blue
and we'll just thicken it up a little
bit change the line width to three
save the script we shouldn't have two
emas drawing there perfect
and so now in order to get the filter
and detect whether these ema's are above
or below
each other we need to detect some entry
reasons
so here i'm going to say detect entry
reasons and again this could be any
entry reason you want
i'm just using engulfing candles today
because they're an easy example
so i'm going to create two variables
here long entry and short
entry long entry is going to be set to
whether the
current candle close is greater than or
equal to the previous candles
open and did the previous candle
close as a bearish candle
or a doji was a previous candles closing
price less than or equal to the previous
candles opening price
and then it's just the opposite for a
bearish engulfing candle
so there's our long entries and short
entries now we can plot these
to the chart so create a new section of
code
here call this plot entry signals
and we'll just use plot shape for this
not plute
shape plot shape uh long entry
i like to do it this way if you don't do
it this way
i'll show you what happens in a second
but what we're doing we're saying
if we have a long entry then set plot
shape to 1 which means it will plot
a shape otherwise plot n a and we'll
give it a style of shape dot
pro up for a bullish candle and the
color will be color.green
and the location will be location dot
below
bar so just really quickly let me save
the script make sure that's working
there we go so now the reason why
i like to do it this way
because we could just get rid of this
code here and this will still compile if
i save the script
you can see it's doing exactly the same
thing the difference is
up here so when we have a signal
you can see that this plots 1.0000
or however many decimals are on your
price chart but now if i go to
any candle that does not have a signal
we're also getting 0.000
this is obviously a long number and if
you've got a lot of plots
in your script these numbers can add up
quickly
if you have six digits plotting for
every single shape on your chart
whenever there's a no signal
it'll just really clutter up your chart
so i like
to add this little bit of code in here
so what we're saying is we're saying
if we have a long entry detected then
set this plot shape to 1 which means
true it'll just draw the
shape otherwise plot n a so now if i
save the script
you'll see that when we hover over any
candle that does not have a signal
we're just plotting n a it's much
shorter than a six digit number
so that's why i do that here let's move
on
copy this line of code paste it in here
get rid of blow bar because by default
this plot shape plots above the bar and
for
bearish signals that's just fine
so we're going to plot shape for every
short entry
and the color of color.red now if i say
the script we'll be getting
bearish engulfing candles plotting to
our chart as well
but we're not taking into account our
ema filters yet
so for that let's add a new section up
here
called get filters we're going to have a
long filter
and a short filter now our long filter
is going to be there's a couple of ways
we can do this first of all
we could just check if the emas are in
confluence so we could just say here
is ema1 greater than ema2
or is ema1 less than ema2 for a short
filter
then if we add this boolean into our
entry reason detection down here so
short
filter and long filter combined with our
long entry and short entry conditions
now if i save the script we'll only be
getting long
bullish engulfing candles plotting if
this 50 ema
is above the 100 ema
and vice versa for shorts we'll only be
plotting
bearish signals if the 100 ema is above
the 50
ema so that's the first part of an ema
compliments filter
and this works just pretty pretty good
works pretty fine actually
uh but if you want to take it one step
further you can also detect
if price action is below this 50 ema
for shorts or above for longs so if we
wanted to we could add into this long
filter
is the current close greater than ema 1
and is the ema 1 above
our ema2 and vice versa for short so we
could say
is the price of the current candle below
ama1
and is ema1 below ema2
so when i save the script here this
entry pattern here is going to go away
as is this one here and this one up here
so now if i save the script so there we
have it so now we're only plotting
signals
if the 50 ema is below the 100 ema and
price action is below the 50 ema
and the opposite for long trades so
that's one way to apply
an ema filter uh but before i end this
lesson i thought it might be interesting
to show you guys how you can
disable your ema 2 in your script in
case
you have a script that has this
functionality in it
but you want to allow both options for
your users so you want to allow
the user to disable ema2 and only use
the ema1 as your filter the easiest way
to do that is to just set ema
2 to 0 ema2length to 0
and detect that in your script so i'll
show you what i mean right now
so down here we can change our filter to
say
is the closing price above our ema 1
and is ema1 above ema2 or
is ema length two equal to zero
and copy that down into there and so now
our filter
will return true if price is above the
ema
and our emas are in confluence or we've
disabled
ema2 by setting its length to zero now
the problem is if i say the script will
get an error
whenever i come up and set this to zero
because
you cannot have if i click on that it'll
tell me the error
we cannot have a length of 0 passed to
the ema function
must be above 0. so what we need to do
here
is say ema length 2
equal to 0 question mark then set it to
1
otherwise set it to ema length 2. so
what we're saying here is we're saying
for our second ema
if the user has set ema length 2 to 0
then we just want to get an ema with a
length of 1
otherwise we do want to use our ema
length 2 parameter
because it's set to something other than
0.
so now if i say the script that will
work just fine
if we come up here and we set email
length 2 to 0
we'll be getting any signal that closes
above or below this 50 ema but you can
see we're also plotting
our second ema with a length of one so
if we come down to where we plot our
emas
and we check here if our ema length two
is set to zero
so ema length two equals zero question
mark
then we want to draw n a
otherwise we actually do wanna draw our
ema
two so now let's save the script
minimize that come up to the settings
menu and set ema length two to zero
our second ema goes away and it is now
no longer being considered
in our filter check uh if you didn't
understand anything in this video just
rewatch it it'll make sense i'm
sure but basically what we're doing here
is we now have two emas
if our first ema is
above our second ema and price action
is above our first ema
then the script will be looking for long
trades
otherwise if our first ema is below
our second ema and price action is below
the first dma then the script will look
for
short trades and if you want to you can
come into the settings menu here
set ema length two to zero hit ok
and now this script is only using the
first ema as the filter this is a
very simple filter very simple method
but it works very well but finally
one last thing that i have found useful
in my own scripts
is to detect how many candles
are above or below the ema preceding the
setup
so for example in this case you can see
we have
two candles that closed above the ema
immediately preceding
our setup what happens if you want to
invalidate the setup
based on this condition as well i'll
show you how to do that really quickly
so here we come up here and above our
filters
let's add in ema breach check
and what we're going to do here is we're
going to create two new variables we're
going to say
bars above ema and bars below
ema and this is going to be set to 0
by default then we're going to use two
for loops here we're going to say 4
i equals 0 2 and
let's create a new input variable up
here i will say
e may look back and this is just going
to be another input
with a title of ema lookback a type of
integer and a default value of
three so we're going to look back three
bars and count
how many bars are above or below the ema
and incorporate that into our filter
so here i can change this through to ema
look back
and now we can check if the close
of our current iteration we can just put
i in here
which is this guy here so if the current
adoration of our loop
our for loop looking back if the closing
price of that candle
is above the ema one then we want to set
bars above ema to bars
above ema plus one and we can also check
in the same for loop we can also count
how many bars close below the eme
so here we'll say if the closing price
of the current
iteration of this loop so you know we're
looking back
one two three candles if the current
candle
is below the ema or the previous candle
or the one before that then that will
increment our bars below
variable by one so this is how we
count candles beyond the
ema so now if i save the script should
compile without any errors
there we go now all that's left to do is
add these checks
into our filters so i'm going to create
one more user input here it's going to
be called max bars beyond ema
it's going to have a title of max bars
beyond ema
it's going to be of type input.integer
and have a default value of one so we're
only allowed one bar
to close beyond the ema over the past
three candles by default for a signal to
be considered
valid so now if i come down to our long
filter and short filter
we can add on the end here and bars
for a long trade where checking bars
below ema
is less than or equal to max bars beyond
ema and the opposite for short trades
we're checking
and bars above ema is less than or equal
to max bars
beyond ema so now if i save the script
we come up to the settings menu and we
turn off our second ema that will bring
back this example here
and look at that we are now invalidating
this setup here because we have had more
than one candle
close above this 50 ema over the past
three bars
so now if i come up to the settings menu
here if we change this max bars
beyond ema variable to 2
let me click ok this setup will come
back
because it's now considered valid
because we can have a max of two candles
closing above the ema for short trades
and obviously for long trades
it is the opposite so back here if i set
this back to
one ah sorry if i set this to zero
that will invalidate this setup here
because we've had one candle close below
the ema
so this is a great way to avoid taking
signals
around the ema when price is
consolidating
around it so typically speaking when
the ema is tested as support or
resistance
and price responds from it it's often
likely that we only have a maximum of
one candle closed
below it if we have more than one candle
close below it preceding a setup
then that usually means that the ema is
being ignored
so that i found in my personal trading
that the optimal setting for this filter
is one bar
beyond the ema over the past three bars
preceding
our setup so if we zoom out a little bit
look for some examples so you notice
we're working off closing prices here
not wix because any wix test in the ema
is a good sign that's a bullish sign
that this ema is acting
as support and pushing price up but
if price hovers around the ema
for a little bit too long such as in
here
we do not want to be going short on any
short signals
if price is consolidating around the ema
because that means we're either entering
a period of consolidation
or price wants to reverse so i hope you
found this lesson interesting i'm going
to leave it there
i don't want it to get too long we
covered a lot of subjects here we've
covered how to create a single
ema filter we've covered how to
create two ema filters in confluence
with each other we've covered how to
create a filter with an ema breach look
back
so we're searching back three bars
counting how many bars close beyond the
ema
so above the ema for short trades below
the ema for long trades
and if we have too many bars closing
beyond the ema
then we're adding that filter in our
script as well
and there's just a few ideas for you to
play around with in your own scripts
to add some ema filters to potentially
optimize your strategy scripts
or your setup detection indicators if
you have any questions
shoot them to me otherwise i will see
you in the next lesson good luck with
your trading good luck with your coding
speak to you soon have a great day
if you found this video helpful and you
want to learn more about pinescript head
over to panscriptmastery.com
i have an advanced course there with 70
plus lessons
covering pinescript from the basics all
the way up to more advanced topics such
as strategy scripts
and complex indicators and if you don't
want to pay for anything that's fine
i've got a free course there as well
that goes into great detail about the
core fundamental
concepts you need to know in order to
use pine script effectively
so i'd love to see you there go and
check that out if you're interested in
that otherwise hang around
hit that subscribe button and i'll be
back with more free content
really soon thanks for watching i'll see
you next time
you

PineConnector TradingView Automation MetaTrader 4 Setup Guide

what's up Traders I'm Kevin Hart and in today's video I'm going to be showing you how to install Pine connecto...