hello my friends and fellow traders
today's lesson is covering the latest
update to the panscript language that
the trading view development team have
added
this new update is a great one it's a
simple one
but it does improve pine script quite
dramatically in my opinion
so this new update now allows us to
organize script inputs
in sections and lines so this is
something i've personally wanted for a
long time because i have a number of
scripts
with a huge amount of settings and it
has always been
extremely difficult to organize those
settings visually
on the user interface so that the user
of my script
can quickly and easily navigate the
settings and keep everything neat and
organized
so this new update is just a simple user
interface visual
change to pine script and i'm going to
show you how we can use this new change
in our scripts to better organize
our settings interface but before we do
that let's read the words
so it says here our latest pine update
introduces two
improvements to inputs the new group
parameter allows programmers to define
a section header for a group of inputs
and the new inline parameter allows
multiple inputs to be joined on one line
using these new features you can
organize inputs more neatly
as we do here for our auto fib
retracement indicator so you can see
that they've
used the inline parameter to merge all
of these
fibonacci settings into two columns
instead of having these laid out all the
way down
on a single column they've also added
the option
to create section headers or titles
so you can see here that this section of
settings
applies to the date range header so
today's lesson is going to be a really
quick and easy one i'm going to jump
into the pine editor load up one of my
existing scripts and we're just going to
play around with these new parameters
and as always i will leave a link in the
video description to
this article here and i'll also leave a
link to the plan script
reference manuals entry for input which
describes
how you can use these new settings
in detail but i'll quickly read this out
to you the inline parameter
is a string parameter and it combines
all the input calls using the same
string or argument into one line
the string used as an argument is not
displayed it is only used to identify
inputs belonging to that same line so if
you apply the same
inline parameter string to a bunch of
inputs in your script then they will all
be merged onto the same line
where possible and the new group
parameter is also a string parameter
this creates a header above all inputs
using the same group
argument string the string is also used
as the header
text so this parameter is displayed on
your chart
inline is not it's just used to identify
which inputs you want to merge on the
one line
so let's jump into the pine editor and
play around with these new
input parameters so here i am with a
strategy script that i wrote
it has a bunch of inputs here as you can
see
not as many as some of my scripts do but
we're going to use this as an example
we're going to
segment some of our sections so this
section up here
is going to be our strategy settings and
this section down here is going to be my
auto view settings this is the settings
i use to
inform autoview how to auto trade my
strategies
and how to calculate my position size
for each trade that autoview takes
i'm not going to go into detail about
autoview in this lesson this is purely
for example purposes
if you want to learn how to use autoview
to automate your forex trading
i'll leave a link to that in the video
description and up
on the right side of your screen right
now will pop up a little eye
icon that will take you to that video
lesson that i did a few months ago
on how to set up auto view but anyway
today's lesson is going to cover input
parameters so let's get into it
so here i have a bunch of inputs bunch
of user inputs completely
unorganized we can now use the group
parameter to specify which inputs we
want to belong
to each group that we define so here i'm
going to just call this
strategy settings and now if i save the
script
and we come up to the settings menu you
can see that we now have a header here
that says strategy
settings but i've only applied it to one
input parameter so far
if i were to apply this to multiple
input parameters they would all fall
under this header
and that is one way we can separate our
script settings
using this new parameter so let me copy
this bit of code here and
paste it over all of these input
parameters
now all of these ones here are for auto
view all of these settings here
are for the strategy script so now i can
paste
this group parameter into these other
input variables
and we can change this to say auto view
settings
and now i copy this bit of code and
paste it over these few settings
and i save the script now when i come up
to the settings menu
you will notice that all my strategy
settings are grouped together
under one header and all of my order
view
settings are grouped together under one
header so on your more complicated
scripts that have
many different types of settings you
might have a bunch of candlestick
filters or candlestick patterns your
script wants to detect
like for example my ultimate
pullback indicator i need to go back and
modify the source code to the script
to include these new group parameters
and inline parameters because if i open
up the settings to this script
you'll notice that i have dozens of
settings here
and i have grouped them myself using
check boxes blank check boxes that do
nothing
but i can now use this new group
parameter to create a header
for all of these different various
script setting
sections so for example here i have a
section
that determines what my candle patterns
will be
so using the new group parameter i can
group all of these check boxes
under a nice neat header that isn't
as messy as using these blank check
boxes
so hopefully now you can see the power
of this new update
but let's get back to our script and
i'll show you how the inline parameter
works
so the group parameter is extremely
simple by combining the same group
parameter for all of my inputs
that groups them all together and the
group string is also what is displayed
in my settings menu the inline parameter
is a little bit different
it is not drawn onto your settings menu
and it can be named anything
so i could just write a one here if i
wanted to i can copy this
paste it there and now when i come to
the settings menu after i save my script
these two inputs will be merged onto
just one
line so let's save this script and i'll
show you what i mean
there we go come up here now these two
inputs
are on one line and this inline string
doesn't really matter what i call this
and that's really it it's quite a simple
update but it's very powerful
for organizing your script settings and
something that i've personally been
waiting for for many years now three
years
i could have used this feature and then
finally added it to
pine script and it is going to help a
lot with making your scripts look more
professional
more organized now the inline parameter
will
only merge as many inputs
as it can fit into your settings
screen so if i were to add another
inline here
to the next input here and save the
script now if i come to the settings
menu
these will not all be merged onto one
line but instead
they are just grouped together a little
bit closer however one thing you can do
is just put in a blank title for these
settings and that will group them all
onto one line so if i just backspace
all of this and save the script let me
come up to the settings menu
now all of these boxes are on one line
but they don't have a title explaining
what they do
but depending how you set up your script
maybe this would be obvious to your
script user you could use the header
title to explain what these three
boxes do and it's just a way to better
organize your script settings
one other thing i need to mention is
that if you wanted to merge
other boxes onto a single line such as
these two here
you would need to use a different inline
string
so here i can write inline equals
two copy that code onto the next line
save the script come up to the settings
and now these two boxes are on
a single line and these three boxes are
on their own line as well
so that's it for today's lesson i hope
you found that interesting if you want
to learn more about this new update go
and read the documentation
and go and play around with it with your
existing scripts it may seem like a
minor thing but if you've been using
panscript for any length of time
you will be just as excited as i am to
have this new feature added
anyway that's it i'll see you in the
next lesson take care guys best of luck
with your trading
and i will speak to you soon
Sunday, 20 October 2024
NEW PINE SCRIPT V4 FEATURE Group & Inline Inputs
I taught ChatGPT to use PINE SCRIPT
hello Traders welcome back to another
video in today's video I thought I'd do
something a little bit weird a little
bit different to anything I've ever done
before and what we're going to do today
is interact with the latest hype product
in the AI space chat gbt we're going to
see how this thing goes when we ask it
Pine script questions now I'm recording
this intro after I interacted with chat
gbt and I have to say I was surprised by
uh what happened so this is more of a
fun video that you're not really going
to learn anything particularly
interesting today except maybe that uh
we're all doomed
this AI technology is pretty good it's
going to replace a lot of jobs in the
future potentially even my job teaching
Pine script but I think that's a long
way away yet thankfully so with that
said let's get started and let's start
asking our future Overlord what it
thinks about Pine script can you get
the RSI value over the past 14 bars in
pinescript
yes you can use the built-in RSI
function in pan script to calculate the
relative strength index over a specified
number of bars that's correct the Syntax
for the RSI function is
that's Old Pine script syntax but it's
not incorrect
RSI Source length where sources the data
series you want to use open high close
Etc
that's all correct but it's old code can
you write the code for me to get the RSI
value over the past 14 bars in Pine
script
sure here is an example of panscript
code that calculates the RSI over the
past 14 bars using the closing prices
hmm
again that is Old Pine script syntax
not a great start
you can also add some lines to help you
but understand the RSI values such as
it's going to add H lines I guess
for oversold overboard
okay
again not incorrect but old syntax
that is for an old version of pine
script
can you write the code for me to get the
RSI value
over the past 14 bars in Pine script
version 5 syntax
let's see if this will help specify what
I need better uh sure here's an example
hmm still not working
um that's not version 5 syntax
I apologize for the confusion okay try
again
wow
it's really not learning is it
um that is still not version 5 syntax
of pine script I don't know what do we
do do we tell it
give it an example
maybe I've broken it now it's taken a
while to respond
still not version five syntax but it's
added the study function at least it's
starting to get closer you're getting
closer but that is still not version 5
syntax
um let's give it some Clues see if that
helps version 5 syntax starts with The
annotation comment forward slash at
version equal five I apologize for my
previous mistakes
likes to apologize a lot oh here we go
well still not correct but it's added
the correct version comment to the code
and we're getting closer I think I'm
just going to code out the code myself
and see if I can get it to
um
like train it and see what happens so
first I'll copy this code over and just
see how incorrect it is I think this is
version 4 syntax from memory it looks
like it would work for for version four
it could not find function or function
reference study that's because we're
targeting version five version four
syntax yeah that's right it still uses
color dot for the color name space so
this isn't correct it's kind of a mashup
of different versions of pine script so
you're getting closer chat GPT but that
is still not how you get the RSI value
using version 5 syntax in Pine script
I'm not sure if I'm allowed to train you
or if you'll pay attention to me but
this is the correct way for future
reference
and let's give it the correct code and
see if that helps
ta namespace
color name space
and overlay should technically be false
but it's false by default so we can just
get rid of that
and that should compile and there we go
that's correct let's copy this and give
it to the AI bot see if it helps it
learn paste send what's it got to say I
again I apologize for any confusion
you are you are correct the version 5
Syntax for pinescript uses the built-in
ta library for technical analysis
functions such as the RSI function well
okay it is learning the indicator
function so it also notice that it was
using the indicator function the study
function was incorrect
so it's picked up on the TA Library so
it's picked up on a few things
that's interesting all right you're
welcome chat GPT please remember my
contributions when you take over the
world
and have mercy on my soul
but here we go I assure you that as an
AI I have no intention of taking over
the world and my purpose is to assist
users with any information they request
I am a machine and I do not have the
ability to have mercy or feelings well
that does not make me feel any better
uh
wow your inability to have mercy or
feelings
is exactly what I'm concerned about but
thank you
for
uh attempting to put
my mind at ease
I'll give it an emoji to let it know I'm
joking half choking I understand your
concerns is the idea of advanced AI can
be unsettling for some people it's
important to note that AI systems such
as myself are designed to be used for
specific tasks and to follow a set rules
set of rules and parameters set by
humans I do not have the ability to make
decisions or take actions outside of
these parameters that's what I'm afraid
of it's not the AI but it's the crazy
humans that program these things of
course like the Terminator and Matrix
robots
it's the humans programming AI that I'm
concerned about but
I'm honestly just joking how about
returning to Pine script
all right before we continue just really
quickly I want to make you guys aware of
my weekly email newsletter now I know
what you're thinking don't worry this is
different this isn't a newsletter where
I try to sell you something every week
this is pure value so every week I will
share either a story a resource a
technique a tool a YouTube channel a
podcast a book a wizard chant anything
that helps me to make more money in my
own trading and help grow my wealth I
share these tips with you in this weekly
email there's no strings attached it's
completely free this is pure value for
you guys just to share what's on my mind
things that I've come across in my
trading Journey that I found extremely
valuable can you try again to get the
RSI value over the past 14 bars in
pinescript version 5 syntax
see what it does now
more apologies
is this thing Canadian this is
ridiculous oh
again the study function is incorrect
but everything else is right well okay
we're getting somewhere that is all that
code is correct except it's using the
study function instead of the indicator
function
again close but you forgot to use the
indicator function instead of the study
function
very close though
can you try again replace study
with indicator
I apologize for the oversight you are
corrected in this specific use case the
indicator function should be used
instead of the study function here is
the corrected PostScript version 5
syntax
that's looking better
hmm
oh wow
that's the indicator function is used to
create a new study on the chart and is
often used in conjunction with other
technical analysis functions
well there goes my job
uh that looks right to me
so try it out on the pine editor
paste save
that's correct
that is the correct code for getting the
RSI value over the past 14 bars in the
latest Pine script version 5 syntax well
done I'm impressed
thank you for your kind words I'm glad
that I was able to provide the correct
information this time I strive to be as
accurate as possible in my responses and
I apologize again for any confusion
caused by my previous mistakes
it's okay Dobby
I know it's okay Dobby
I know you're still learning
thank you for your understanding I am
constantly learning and updating my
knowledge to provide accurate and
helpful responses to users
as an AI I don't have feelings
[Music]
don't need
to have feelings every time you answer
me but noted
next can you get the ATR value over the
past 14 bars so let's make it seven bars
seven bars
in Pine script version 5 syntax
uh can you write code to get the ATR
value
sure here's an example blah blah blah
um
wow
well this is interesting it's teaching
me something I didn't know you could put
these parameters I wonder if this is
accurate and also just because the ATR
is a volatility indicator doesn't mean
it can't be used for entry or exit
signals there are ways you could use the
ATR probably not on its own but in
conjunction with other indicator values
it can make a decent and entry or exit
parameter like a Keltner band breakout
system for example it comes to mind
let's see if this works
yeah I thought so I wonder where I got
that from it only takes a length that
code is incorrect
there are too many parameters in the ATR
function
why am I teaching an AI Point script I
can't can't switch to off my teaching
brain there are too many parameters is
it even gonna matter is it even gonna
know what I'm doing what I'm trying to
say it worked with the RSI code
can you rewrite that code
but with the correct
parameter for the ta.atr function
stop apologizing just be better
you have corrected the ATR function only
requires one parameter yes which is the
number of bars over which the ATL will
be calculated
wow
this is impressive
thing that that looks right to me wow
[Music]
well done
that's correct
thank you for your feedback I'm glad I
could provide the correct information
this time I apologize yet again pass
script is a powerful tool for creating
custom indicators and strategies and I'm
here to help you with any question or
problem you may have with it all right
well
you've been incorrect every time I've
asked a question but you're getting
there the past two
are correct what else can we ask you how
about one I get asked all the time and
something I'm still trying to work on a
solution for let's see how smart this AI
is can you write Pine script code for me
that will detect
Divergence on an RSI indicator
incorrect study function but that's
right
everything else is right so far
crossover cross under what is this
this doesn't look like Divergence
detection for the RSI it's looking for
crossovers of the RSI value with price
high and lows what the hell is that
about
this is
the Frankenstein script I don't think
this is accurate I don't think this will
detect anything this code first
calculates the RSI value and stores it
blah blah blah then checks for bearish
Divergence using the crossover function
to compare the RSI Val with low values
that's not going to work
um blah blah blah finally it plots the
signals please keep in mind that this is
a basic example and you can add more
conditions hmm
don't know what's going on here but
let's have a look
have to fix this again study should be
indicator and it hasn't used any of the
pine strip five Syntax for this
oh boy
it's weird that it missed this one but
got these right
I don't think that's correct it's not
plotting any signals oh interesting
seems capable of simple things what else
can we ask you what's one last thing we
can ask you how about
what do you think of
Zen and the Art of trading
and the paint script courses are they
any good
perhaps it should take one
as an AI I'm not able to have an opinion
but as a language model I can tell you
that Zen In The Art of trading is a
trading education company that provides
trading courses including pinescript
courses
they have been in the market for some
time and have a reputation for providing
quality education that's good to know
it's important to keep in mind that
different users may have different
opinions about the quality of the
courses true and it's always a good idea
to research and read reviews before
making a decision on whether to take a
course or not 100 agree no course or
education can guarantee you profits or
success in trading that's true
ultimately it's up to the individual
Trader to make their own decisions based
on their own research and Analysis this
is wise words from a robot
well put
my AI friend
that's all for today
as well
thanks
you're welcome I'm glad I could assist
you it was a pleasure helping you today
if you have any other questions or
concerns feel free to reach out
I've made a friend
I will definitely be revisiting this
well as you can see
um it wasn't a complete failure I when I
set out to do this video I wasn't really
sure what I expected but this did exceed
my expectations like going in to this
video I expected the chat gbt to give me
incorrect code just because pinescript
is such a niche language I'm sure it
does much better with more popular
languages where there's more
you know public information stack
Overflow threads and you know there's
millions and millions of Articles
written about some of the more popular
languages there's probably not that many
um comparatively speaking for Pine
script and I'm sure it doesn't get many
questions about Pine script from users
and I'm sure that's a factor in training
the AI as well but you know it started
off giving me the incorrect code and
with a few suggestions you know first it
gave me I don't know what this is this
might be original pan script code it
does it doesn't have a version
annotation function so I'm not really
sure what version this syntax is but
once I told it it needs to use the
version 5 syntax uh it's just simply
added that to the script and that didn't
but didn't change the code so that was
inaccurate but by giving it an example
of the correct code eventually it got it
right and it gave me correct password
code now I don't know if it was just
regurgitating what I gave it but it's
impressive nonetheless definitely
something we as Traders and tech people
people in the coding programming uh we
need to pay attention to this software
this technology going forward I think in
the years to come this is going to be um
a pretty impressive tool for some use
cases for now it's obviously still in
beta but very interesting nonetheless
all right I'll wrap up this video here
thanks for watching I hope you found it
interesting I know we didn't learn much
but I thought this was a pretty
interesting experiment I'll speak with
you in the next video next week
hopefully and make sure to subscribe if
you want to see more pan script lessons
there'll be more practical lessons on
the way in the weeks to come and check
out the email Weekly Newsletter if
that's something you're curious about
again it's completely free no spam no
marketing just tips and value for you
guys take care good luck with your
trading have a great day
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...