hi Traders welcome back today we are going to be doing more Pine connector material in the previous video I did a simple script template for automating your Pine script strategies through Pine connector using trading view alerts in today's video we are going to be dramatically or significantly expanding on that previous script to create a very Advanced template script that will allow you to automate pretty much 99% of most systems out there all you need to do is replace my strategy code with yours and the rest of the script should work mostly out of the box now for those of you who are not familiar with what Pine connector is make sure to go and watch the previous videos in this series it's basically a metatrader Plugin or expert advisor that allows us to automate our trading view scripts using trading view alerts directly from our pinescript code so it adds full automation functionality for um mostly Forex Traders but if your broker allows you to trade other markets you can automate those markets so crypto CF C fds Commodities some Brokers offer cfds on stocks that sort of thing if your broker offers the market through your metatrader platform then you can automate it through trading view scripts so this video is going to significantly ramp up the complexity of the previous videos so if you haven't watched them make sure to go back and watch them to get Pine connector all set up properly otherwise you're going to get lost in this video with all that out of the way let's get started so here is the source code this will be available on my website check out the uh pinned comment below so we're just dealing with a very simple strategy here it's not a particularly Advanced system all it does is buy and sell overbought and oversold um conditions so the RSI 14 period RSI is overbought it will buy bullish candles if it's oversold it will short bearish candles today's lesson is not a trading strategy lesson it's purely a pine connected template um so the whole idea here is that you rip out my strategy code this bit of code here these three lines of code you change these to your systems entry criteria and then with some minor adjustments elsewhere in the code you should be able to adapt this code to work with any of your systems now there are some exceptions for certain systems but I will get to that throughout the video let's get started with breaking down the user inputs so this script comes with a bunch of strategy settings for my sort of simple template strategy we have a stoploss distance this is in Pips if ATR multiplier is set to zero so if ATR multiplier is zero then stop-loss distance Is pips based it's a fixed pip stop-loss distance now if I set this to one that will override our stoploss distance in Pips and we will be using a average true range multiplier um for our stop loss so if I set this to one then we will have a 1 ATR distance from our entry the closing price of our signal candle down to our stop loss for a long trade or up to our stop loss for a short trade we can also so change this setting here to high low and then the stop loss will be calculated from the candles high or low so those are our stop- loss settings the next few settings here are our profit risk reward profile so if this is set to one then we have a one: one risk reward from our entry so we'll have if we have a 10 pip uh stop loss then we'll have a 10 pip Target Break Even is exactly the same except this is for triggering our break even stop- loss so if I set this to one and this to two then if price hits a 1: one target from our entry our stop loss will be moved to break even and then finally we have our trailing stop distance this is the same as these two but for our trailing stop so for example if we set this to 5 to1 now we have a 5x Target from our entry so if we have 10 pip stop loss we have a 50 pip Target uh but that's obviously not going to get hit very often so maybe we want to move our stop loss to break even at 1:1 so now our stop loss will be moved to break even when price moves 1 to one in our favor and then finally if we want to start trailing our stop loss we could set this to 2: one and it's going to be hard to find a trade that actually triggers these conditions but I'm sure we'll find one I see one here here we had a trade enter nearly got stopped out then our break even Target was hit our stop loss moved up to break even and then our trailing stop Target was hit and our stop loss began trailing to lock in profit had this trade continued in our favor this stop loss would have trailed upwards to lock in profit so those are our simple strategy settings um there were two more options here for exit reasons so if I turn exit on higher close on or off now the script will um let me find an example real quick um it'll be easier if I turn these settings off to find an example here we go this will do so if I have this setting setting turned on exit on higher close lower close and I'm in a long trade as soon as our Green Line gets hit that's our take profit if I'm using an exit reason here then we don't place a fixed Target instead the script will wait for price to touch this um Target and then when our exit uh condition is detected the script will exit our trade so in this case we're waiting for a lower close so this candle closed lower than this candle after our takeprofit was hit our profit trigger was hit and then we exit the trade on the next bars open after this lower close obviously for um short trades it's the opposite so for a short trade we would be looking for a higher close so in this case here we went short and then we had a higher close we exit on the next bars open and then here we have another exit reason I just wanted to show you guys how to use multiple exit reasons with pine connector these are purely for example purposes they're very simple exit reasons they can be effective on some systems I do use these sorts of exit reasons on some of my trading systems but you probably want to add some more complexity to these a little bit more sophistication you probably want to combine indicator conditions that sort of thing with your exit reason higher close lower close is a pretty good exit reason but opposite color bars not really you'd probably want to combine that with something like a um indicator overbought over sold condition again this is example purposes this is about the pinescript template not about the system itself um so yeah this will exit an open trade based on an opposite direction higher close or lower close this will exit the trade based on an opposite direction bar in general so if we're in a long trade and we print a red bar we exit and vice versa for a short trade so those are our system settings very simple system um but again you should be able to convert most training systems that are simple the more complicated a training system is the more difficult it's going to be to plug it into this template but personally all of my systems are very simple I can copy and paste probably all of my systems into this script and get it working um so for those of you with access to the Mastery course or my indicators and strategies course um feel free to play around with any of those scripts you should be able to copy and paste the majority of them um the entry conditions you should be able to replace this with the entry conditions from any my scripts and this script will work almost out of the box you will need to tweak a few things here and there for certain strategies but should be pretty simple so that's it for our system let's go over the pine connector settings this is this is the uh point of today's lesson all of these settings below this label here so if you watch the previous lesson on my simple template you'll recognize most of these settings but there are a bunch of new ones that I've added to make this Advanced template uh useful for most Traders this should cover 90% of requirements for Pine connector if this is off and you set up your alerts then they will not be sent to Pine connector so uh but this is on by default the next setting is obviously very important that's our Pine connector license ID if we don't have the correct ID then our order will not be routed to metatrader so make sure to put in the correct ID here then we have our risk per trade again I went over these settings in the previous videos this is BAS on your Pine connector expert advisor settings so if you've set pine connector up to use Lots then this would open one standard lot if you've set it up to use a percentage of your account balance then this would risk 1% of your account on the on any trade that is open by this script entry Pips is for our entry limit order so in the previous script we used Market orders in this script we can either use Market orders or we can use um limit orders so limit order will place in the case of a long trade let's say we get our awesome looking bullish candle here and this triggers our long trade um if we set this with this turned on our alert would send a limit order let's say this is the candle's um closing price the script would send a Buy limit order 0.1 Pips below that closing price over on metatrader so whatever the price is on metatrader if we had entry Pips set to 0.1 and this turned on when we um set up our alert then we would place a buy limit order 0.1 Pips below the signals confirmed closing price if you want to just use Market orders to enter your orders immediately then leave this setting off and then this setting here is ignored spread filter is another pine connector setting this will only execute trades if the current market spread on your broker is below this pier amount um I personally leave this on in most of my scripts just to prevent my um my system from taking trades during some sort of Market Calamity like if if the spread is greater than about three Pips on my broker that I use um then something's gone horribly wrong because my spread is usually around 0.1 Pips at least on the major pairs that I trade the next setting here is our break even offset so let me show you what this does if I set what do we want here we want this I'll set this to 5:1 and my break even to 1:1 let's find an example yeah this one will do when my break even um price is hit what happens here when this order is sent to uh Pine connector is this is our signal candle the RSI my settings are different here Al So currently for testing purposes I set my RSI period to three I was a bit confused there why this was a buy signal when the RSI wasn't oversold but let me just change this to be consistent with the script so let me explain what happens here what happens here is our script detects this green candle as our entry condition when this bar closes green while the RSI is oversold we have our long conditions met when this bar closes if I have alert set up then trading view will trigger my alert and the script will send the syntax to open a trade to Pine connector so with the settings I have here we would open a market order so at Market our stop loss would be down here and our break even price would be also included in our alert to Pine connector so when Pine connector receives our alert it would receive a command telling it that we want our stop loss to be moved to break even when price reaches this threshold so this is a 1: one distance from our entry to our stop loss here 1:1 now this is a p value when it's sent to Pine connector so if I measure out roughly from our entry up to the Blue Line This is what would get sent to Pine connector so if I bring the syntax over real quick for Break Even This syntax command be trigger automatically moves the stop loss of whatever position we tell it to manage when be trigger is satisfied so in this case my script would tell Pine connector set my be trigger to 1.3 we're on a 1 minute time frame here again for demonstration purposes I don't recommend trading this time frame not even with an automated script due to all kinds of reasons mostly slippage and commission costs um but anyway that's up to you this isn't trading advice uh make sure to read the disclaimer if you haven't already um this 1.3 pip Break Even trigger would be sent in this order so when this order is sent it would be be trigger equals 1.3 then Pine connected knows that when we enter our trade if price moves up 1.3 Pips then we want our stop loss to come up to break even so our break even functionality is handled completely by Pine connector the moment our trade is opened be trigger uh sorry be offset uh this setting here is how many Pips we want to offset our break even order so if I throw an array here um so actually I had to reset my settings here because my offset wasn't accurate but anyway let me start again with this example here's our entry price the open of this red candle so that's our entry price right there if I set Break Even offset to 0.1 now our break even price will be 0.1 Pips above our entry so the point of this is really just to cover the spread so if you set this to zero and price comes down and hits your break even um technically it's not really Break Even because you've got spread to account for and commissions to account for so um if you exit the trade at exact ly the same price you bought it at you're going to take a tiny loss because you're going to take the hit from the spread and the hit from the commission so for Traders who are sensitive to that maybe your system has a very thin Edge and you don't want those trading costs to infringe on your Edge or you just don't like um losing money on a break even trade uh then that's what this setting is for I wouldn't recommend setting it too much higher than the spread so just have a look at whatever your average spread is on your um whatever Market you're trading through your broker and if you want to then that's what I would set this to I would set it to whatever the spread usually is so that's all of these settings the next few settings here are use limit order we already went over that if this is off then we send a market order if it's on we use a limit order this many Pips from our entry price our signal price the candle that triggers our order use pip based entry is recommended to be on with uh Pine connector's documentation recommends using this setting and not not using this setting so so it recommends using Market orders to enter trades and pip based um stop- loss and takeprofit for your limit orders um that's because there is a slight difference a very slight inconsistency between trading views price data and metat Traders price data it shouldn't matter on most time frames but on the lower time frames it does matter a little bit and so to keep your script as consistent as possible with metatrader they recommend Pine connector recommend using pip based orders because that way no matter what price your trade is opened at over at metatrader your orders will be exactly the same distance as they are on trading view so that should mitigate any issues with price discrepancies or inconsistencies if you're not sure what I'm talking about go back and watch the previous couple of videos in this series where we went over that in detail so use pit based entry is for our entry limit orders so let me find our debug label here it is um if I turn use limit order on then our label here will change this is what gets sent to Pine connector we are sending a buy limit on Aussie Yen and our price value is 0.1 Pips from um in this particular uh case we are looking at this trade here as our debug trade um if I was using a by limit order with these settings then we would place our by limit order 0.1 Pips below um the trigger price if I turn this off now our script is sending a price value when this updates in a moment slow today there we go now we're sending a price value instead of Pips to Pine connector now you need to make sure that whatever you've set your script up here is consistent with whatever you've set pine connector settings to be uh so if you've set your Pine connector settings to use price values then you need to ensure that your script template here is also using price values but if you're using the recommended settings for Pine connector you would would want to leave this on you would want to set pine connector up to use pip based orders and then having these settings on will ensure that your stop loss is sent in Pips your take profit is sent in Pips and your entry limit orders are sent in Pips however if you have a reason why you want to use price values and it's up to you U personally I use price values in all of my Pine connector um automation scripts and I've never had any issues but that's probably because the broker I use has very very close price data to metatrader and trading view so um it's I haven't really run into any issues where one platform had a very significant different price to the other but if you have a broker that does some Brokers do have like as much as a whole pip or even a couple of Pips difference between the two platforms that is going to be a big problem if you're sending price orders to Pine connector so if that is the case you'll want to use these settings for me through pepperstone the broker I've been using for the past year or so I haven't had any issues with that anyway let's move on to the final optional settings here um I've included a metatrader symbol override for people who use my ultimate pullback indicator they have run into issues where some markets have totally different symbols to what they're trading on trading view so for most Forex pairs the symbol will be the same on both platforms but there might be a prefix or a suffix again if you if that sounds like gibberish to you go and watch the previous videos but on my broker for example o Yen when I'm sending an order it would need to look like this AUD do uh audjpy a if I don't put a on the end of my symbol then the order will not be sent to my broker or my broker will not accept the order so in this case I I would just add a on metatrader suffix and then any order that gets sent if I look at my label here my debug label you can see that my symbol now says audjpy do a if I wanted to override the symbol entirely I would put override um whatever text I want to override it to in there and now that's what gets sent to Pine connector so there's very very rare edge cases where this would be required so I just included that in the template why not most of the time you don't want to touch this 99.9% of the time you will not want to touch this unless you really know what you're doing and you're running into that issue where the symbols don't match at all on metatrader prefix is the same as suffix but it puts it be uh before wellow can't type before so now we'll get before before our symbol so uh yeah that's pretty self-explanatory um strategy ID is for running multiple strategies on the same Market same symbol so if I'm running a hedged account account or hedging account through my broker that allows me to open long and short trades at the same time or I'm running two systems that only trade in the same direction so if I'm um trading two long only systems one on a 5 minute chart and one on an hourly chart and I want both systems to run through the same account over on my broker through metatrader I can separate the systems using a strategy ID so if I type strategy one into this box now whenever my orders get sent for this particular setup so if I set an alert right now any alerts that are triggered by the script will include this comment and this comment is how we use multi strategies so multi strategy documentation here for Pine connector says um if you want to use multiple strategies you need to include a comment and all orders with the same comment will be handled um as if they're their own system so you can trade multiple systems on the one Pine connector ID through the same broker on the same Market um using this strategy setting this is obviously for advanced Traders only if you're not particularly Advanced with trading or experienced I'd stay away from this completely and just use one um script per symbol on your Pine connector setup uh for me personally I only run one script per symbol on my Pine connector as you might have noticed by now if you've been following me for any period of time I'm a simple Trader I prefer Simplicity over complexity any day of the week if I can make a system simple even if a particularly complex system would make me more money unless it's significantly more money then I prefer the simple system because Simplicity works it's easier to work with it's less headache there's less to go wrong there's less confusion when things do go wrong um but then again I do trade a lot of markets I trade um crypto stocks and Forex if you're only trading Forex then you may want to increase the complexity of your system setup through Pine connector um but I'll leave that with you guys this isn't a trading course right now this is just teaching you how to get P connector working through your trading view scripts in the future I do plan to expand the channel to cover more broad trading Concepts and techniques that I use but uh for now um that is not what we are talking about so that's it for the settings let's briefly go over the code because the code is a bit it's just a wall of text but it all it is pretty simple it looks more complicated than it is um again you can copy all of this code into a blank script replace your strategy settings with whatever settings you like to tweak replace the um if you just a quick tip if you press crlf and type for SL SL exclamation mark this will take you to the couple of um places where you need to replace your my code with your code so this is my entry criteria for long trades and short trades I'll change this back to 14 so here we need the RSI to be under 30 and we need a bullish candle and we can't have any open trades currently so this system only takes one trade at a time it does not pyramid it does not trade in multiple directions it's just one direction at a time one trade at a time very simple entry criteria short trades are just the opposite direction you'd want to replace these conditions with your systems conditions and that's it if you want to use different exit reasons so these are my exit reasons here that we already went over then you would um add those settings up here add in your exit settings so here are my two onoff values for my exit reasons and then you would need to again come down here change these to whatever your exit inputs are and then if use exit reason is on the script will behave slightly differently based on those exit reasons and then of course you'll need to come down to where the exit reasons are also triggered so these are my exit criteria if I have higher close lower close turned on and we get a bar that closes below the previous Bar's low then we exit our trade if exit trade is triggered then Pine connector will send an alert to close any open long trades so again just really quickly if you want to change the script to work with your code change this code here to match your your entry criteria or conditions the indicators you want to use the price conditions Etc make sure to change your exit reason criteria if you're using exit reasons and that's pretty much it I mean unless you're using particularly obscure trailing stops that don't use an ATR trailing stop or or if you want to change the ATR trailing stop distance you might want to add some more inputs to this I try to keep this script as simple and stripped back as possible I could have added a lot more settings here we could have had a setting for for our ATR distance or period we could have had a uh setting for our RSI period and our overboard oversold settings but these weren't relevant to the script today so I didn't include those obviously if you're working on your own script you might want to add those user inputs uh but anyway let's just wrap up this video by going over the important stuff here so you shouldn't need to touch any of this with your scripts this just prepares some um constant variables so it prepares things like our symbol that we send to Pine connector it just sort of helps us build our string this is our text string that gets sent to Pine connector this is all handled here um and we just pass in the relevant parameters so this function here PC alert entry and in fact let me rename this I'll rename this to PC entry alert to be more consistent with the styling of the script there we go so this function here is going to terrify some of you guys especially those of you who are new to pinescript don't worry about it you don't need to know what this does you can copy this into your script and it will just work it's a it's just a function that takes a few parameters and all it's doing is building a string so it's just adding all of the text up together in such a way that um Pine connector can read so it assembles this text alert in the correct syntax to be sent to pinec connector all we need to do is pass in a direction our price entry price if we're using a limit order our stop- loss value our take profit value our break even trigger value and this truncate here is purely for the label uh for some reason with trading view scripts if you're working with float numbers so decimal numbers it will add like an extra 10 decimal numbers after the decimal place um and so to make make this label easier to read I made sure to truncate or strip out the extra decimal places um so that we don't have so many numbers in our debug label but whatever is in this label will be sent to Pine connector now as far as I know Pine connector can accept as many decimal places as you send it but um if you are running into issues with having too many decimal places in your alerts for whatever reason just change this to true and that will make sure that the alert text that gets sent to Pine connector always only contains five decimal places that should fix any issues that you encounter on any markets out there there may be some very slight rounding errors on things like crypto that have a 100,000 Satoshi decimal places but it should be fine to do that if you run into any issues um I might even leave this on by default because I can't really think of any reason why rounding to five decimal places would break any scripts as far as I know there aren't many Market out there other than crypto that have more than five decimal places in their price quote and even if they do rounding the remaining six plus decimals shouldn't really affect anything significantly so I think I'll just leave this on by default but if you're having issues play around with this uh set it to false or true um or if you're having any issues with this uh just send an email to Pine connector support team and they should be able to walk you through a solution but I haven't encountered any issues with this um function I use this in all of my automated scripts so yeah that's it uh the next thing we do is we get our pip size so for Forex one pip is 10 points so so one pip is 10 points on stocks and other markets that's usually not the case usually one point is one pip so on Forex we want to set our pip size to 10 points on other markets it should be okay as one here is where we store all of our stops and targets Break Even prices this is mostly for drawing things onto the chart so in this case um drawing our stop-loss prices and break even prices Etc um when our alerts are sent to buy connector other than a trailing stop alert everything else is sent straight up when we um enter our trade so all of these variables here are mostly just for drawing the signals onto our chart so that we can see what's happening next up we calculate our stoploss distance so if we're using an ATR we take that into account if we're not using the ATR then we just use um our stop our stop loss distance settings here converted into Pips then we have our entry conditions we have this other custom function here which takes all of our trade parameters so our Trade Stop distance or Price our profit distance it takes all of that information our stop- loss our take profit our break even distance and and it uses this function that we just went over to build a string that gets sent through our alerts to Pine connector and that's what this code here does next we check if we have a long trade conditions met if we do have a long trade then we calculate all of our strategy parameters um build all of that together into into our string and that gets sent to Pine connector if Pine connector is enabled we also have our strategy code here if we're using a limit order then we need to use a bu limit in our strategy entry to match what gets sent to Pine connector otherwise we pass in na if this setting is turned off then we don't use a b limit order this will just enter at Market through the strategy tester short trade is obviously identical but the opposite direction then here I just update my entry price from the close of the signal candle so here for example when this bar closes and we open our trade on the next bar our stop loss and take profit is calculated from the signal CLE so once our sign signal is confirmed we calculate our stop loss and take profit but for things like a trailing stop and break even price we need to calculate that information based on where our trade was opened and so this bit of code here just makes sure that our entry price is consistent with what the strategy tester is working with um next up we have our long strategy management code this is for the strategy tester when our trade is opened I already went over this the break even trigger is sent in our alert to open the trade so we don't have to send any alerts to Pine connector that's all handled by Pine connector when our trade is opened but we still need to tell the trading view strategy tester that our trades at break even and we need to draw that information so that's why this code is here next up we have our trailing stop activation code so if I turn that on uh trailing stop distance let's set that to one and set this to zero now the line will turn orange when price touches this line that triggers our trailing stop to start locking in profit so that's what this parameter does if we have a trailing stop turned on and price exceeds that um activation price then we begin trailing our stop loss we'll get to that code in a moment but next up we check our exit reason code so this is the same basically as our trailing stop activation but it's for our profit price so again if I set profit let's turn trailing stop off and set our risk reward to 2:1 now when this green line is touched by Price the script will begin looking for our exit reasons so in this case that is a lower close which we get here and our trade exits at Market on this bars open and here if we are using a limit order and price exceeds our takeprofit price that means that if our trade has not yet been filled so let's say we've set our B limit order to 10 Pips for whatever reason I wouldn't recommend it you want this as close as possible to price um but if I set this to 10 Pips we got our entry signal and our buy order was placed down here and it was never touched by price so we never got filled on our long trade but price came up and touched our takeprofit then we want to cancel this pending limit order because now we're out of sync with our strategy tester code so that's what this does if our takeprofit is hit if our would be take profit is hit and we are using a limit order then we want to cancel that pending limit order um next up we have our confirmed bar code so when a bar is confirmed so the bar closes this is where we check for our exit reasons so if our exit criteria is met then we send an alert to Pine connector to close our long trade at market and we also close our strategy test to trade to be consistent with um the strategy tester and pine connector and then finally we have our long trailing stop code so if our trailing stop is activated and our new long stop loss is greater than our current stop- loss then we want to update our stop loss so if we're using a fixed stop loss up here so this is a fixed stop loss and this is turned off then we want to Trail our stop loss the same amount of distance from whatever we've Set uh this setting to so if we set it to close then on each bar that closes we would Trail our stop loss up in the case of a long trade by 5 Pips from the closing price if we set it to high or low then it would be 5 Pips from the low and if we're using an ATR traing stop then it will obviously be an ATR distance from the close or the low in the case of a long trade and then if Pine connector is enabled then we send an alert to Pine connector to update our stop loss to do that we use the new stop-loss take profit long command and we pass in our new stop loss and also a strategy if we're working with a strategy ID and then our short management code is identical to long but obviously in the opposite direction then we have our trigger stop-loss takeprofit orders in the strategy tester so this passes in our stop- loss price and our um takeprofit price if we're not using an exit reason so if I turn exit reason off this green line just becomes our takeprofit if I have an exit reason turned on then we don't want to place a take profit because out exit reason will trigger the exit at Market when it's detected so that's what this code here does and then finally we have our debug label which just shows what is going to be sent to Pine connector if a trade is detected so the next time a trade is detected um with the settings I've just set up we would send our Pine connector ID we would buy Aussie Yen at Market with a 5 pip stop loss and a 10 pip take profit with 1% of our account balance or one standard lot with a spread filter of three so if the if the spread is greater than three then the trade will not be placed we will not buy oen at Market so the spread filter is obviously most useful with Market orders if you're using limit orders to enter your trade it's not that big a deal if the spread is elevated because you won't be filled on your trade unless price exceeds your limit order price including the spread so the spread is useful for Market orders um but any anyway that's outside the scope of today's lesson hopefully if you're using pine connector you are experienced enough with trading to know what I'm talking about um finally we have all of our plots for drawing our orders and that's it that's the script it's a long video I apologize for that but there was a lot to cover here the source code will be on my website as mentioned at the start of the video check out the pin comment below in the video description if you want to learn more about pin script or get your hands on all of my personal systems and strategy IES go and check out our website pinescript mastery.com I'll speak with you in the next video take care best of luck with your trading I'm not sure what we'll do on the next video maybe we'll apply this template to an existing system that I've already published on YouTube um that might be a good way to wrap up this sort of tutorial series to demonstrate how you can copy all of this code into a blank script and Port over one of my existing systems to use this um template and with that said I'll leave this video here thanks for watching best of luck with your trading I love you guys make sure to subscribe if you haven't already and I'll speak to you soon goodbye
Sunday, 20 October 2024
How to use TIME & DATE functions in PINE SCRIPT V4 • Session Volatility Indicator 📉
hey traders today i thought i'd do
something a little bit different and i'm
going to show you
a script that i recently wrote i'm going
to break down the source code
show you guys how to use the time and
date functions
in your scripts
i was going to wrap up my order view
series this week but i just haven't had
the time to record that lesson
yet so that will be next week instead
i've been extremely busy this week with
my own trading
in the forex and crypto markets and
running the pine script mastery birthday
discount
if you're interested in any of my
courses now is a great time to pick them
up because i have a 25
off discount going to the end of the
week but i don't want to hop on about
that any longer let's get into today's
lesson where i'm going to break down
this new script i've just created this
week
called my session volatility indicator
or calculator so this is a lesson taken
from my indicators and
strategies course where i break down the
source code to every script i've ever
written and because this
is a short script but an interesting
script covering a couple of features i
haven't covered on my youtube channel
before i thought it's a great
opportunity to
show you these features this is an open
source script i don't release all of my
scripts open source because a lot of
them are quite valuable and take a long
time to make but this one didn't take
very long at all so i just released it
as an open source
script so i'll leave a link in the video
description to the source code for this
script over
at tradingview anyway let's get into
today's lesson
this script is a session volatility
calculator so what it's doing is it is
scanning through all the price action on
my chart between two specific dates
and a certain time of day it's then
measuring
the highest price during that certain
time of day and the lowest price
to get the range of that session and
then it's adding up all of those
sessions
to give us an average and this is the
average range of the trading session
that we have specified in the settings
menu so let's jump over into the pine
editor and i'll break down the source
code to this script
so here we are in the pine editor um the
first thing i do
as always is get my user input quite
simple here we're just getting four
inputs which will be easier to
demonstrate if i open up the
uh settings menu so we have our start
date our end date so this is the range
that we want to the date range that we
want to calculate the average
session size during and the time session
to analyze is where we specify
the time of day so this
last setting here this color background
changes the background color of our
chart
if the price action printing onto our
chart falls within
this time session and within these dates
so you can see i've set the dates here
to the first of june which was a couple
of days ago as of recording this video
the end date is 2099 so like 70 years
from now
by default this is set to the year 1000
and this is set to 2099 and that just
makes sure that all the price action on
our chart
is taken into consideration at least
until the year 2099 and then
if i'm still alive then i can update
this to the year
3099 but by then i'll probably be a
cyborg and the markets will be run by
artificial intelligence and none of this
will
be useful anyway so let me increase the
resolution of my screen
and we'll go through the source code
here line by line
most of it should look familiar to you
if you've gone through any of my other
indicator lessons some of this stuff is
just directly copy and pasted
from other scripts that i've written all
right so that was our user inputs
the first thing i do after getting my
inputs is
define a custom function that converts
4x pips into whole numbers so this is
only for the forex markets
if you load this script onto any other
market this
function basically doesn't do anything
but if you load it
onto a forex market and the atr the
average
true range is less than one or less than
a whole number
then this little bit of code here will
convert your number in pips
into whole numbers so you can see up
here that the
box here says 22.875
if i were to not use this function this
would say
0.00022
and so to make it more useful i convert
that into a whole number
but if i load something like a crypto
chart on my screen let's load up bitcoin
um this just changes to price change and
it's cut off on my screen here because i
have my resolution turn right up but if
you had this on a normal resolution this
would
say price change instead of pips so you
can see here that
during the time i've highlighted on my
chart at least
on these two days the average move for
bitcoin was
and seventy 1176 dollars i probably
should have mentioned this at the start
of the video but the purpose of this
script
the reason i developed the script was to
help me calculate
engage session volatility which can help
with things like target placement
in day trading strategies and just
getting a general idea of how much
markets move
during certain times of day so for
example i could set this
setting this time session to
9 a.m my time here in australia to let's
say
10 pm my time which might be
the active trading time that i have to
trade the markets i could see how much
movement happens during that time
compared to when i'm asleep or i can
check
what the average move is on aussie yen
during the asian market
so between 9am and 4pm
my time and i can see if it's worth
developing day trading strategies on
those pairs
based on how much they tend to move
because if a market doesn't move much
during a certain time of day then it's
completely pointless trying to trade
a 15-minute chart or five-minute chart
strategy anyway this is a coding lesson
not a trading lesson so let's move on to
the next
part of my code here which is this
function
in session which just returns whether or
not
the current bar falls within the
specified time period
and the specified time of day so this
function
appears in a lot of my scripts are
basically what this n a
check does is it checks whatever value i
pass into this function
to see if it's n a n or not a number if
it's not a valid number
then it returns true if it is a valid
number then it returns false
and then this time function checks to
see if the current bar falls within the
time session we give it
and if it doesn't then this time
function returns n a
and so our n a function will return true
and this check here will
fail i could have also written here not
n a
and gotten rid of that if i wanted to
but i'll leave it as it is
and basically this check here will fail
this whole function
this function returns a boolean value by
the way it returns true or false
and so yeah if the current bar does not
fall within
the session was specified then in
session returns false
i added on this colon one two three four
five six
seven on the end of our time session
here because
for some reason if you don't do this
this is how many days of the week
to include in this check if you don't do
this then for some reason on weekends
the script doesn't include weekend days
in the uh time function check i'm not
sure why maybe they've changed that i
haven't checked if they've fixed this
but maybe it's intended to be that way
but basically this is for crypto markets
because crypto markets
obviously trade over the weekends and so
i had to add on uh
which days of the week to check by
adding on this string here and just a
side note
worth mentioning is if you wanted to
check just how
a market performed on a monday you could
get rid of these and then it's only
going to check
on the monday or on a weekend you could
just have six and seven
i believe that works i haven't actually
tested that but if i recall correctly
from
when i was studying the documentation
that's how this parameter works
so that's something you might want to
play around with if you're interested in
this sort of thing and then of course
next we check if the current bar's time
falls within our start date and our
end date then we change the background
color
if the user has turned color bg on in
the settings menu
and the current bar falls within our
given time session
then the color of the chart changes to
blue with 90
transparency so rgb is red green blue
255 is maximum amount of blue and 90
here is our transparency setting and
otherwise
if these two booleans do not pass they
both return false or one of them returns
false
then we just change the background color
to n a or nothing
let me leave it as it is next up we
count how many bars are loaded onto the
current
chart and i'm not sure why we do this
because i don't use this information
anywhere else in the script so i'm just
going to remove that
and we'll move on that must have been
from when i was testing something
while developing the script so let's
move on to the next block of code which
checks if a new session has begun so we
create a var variable
this is used later on in the script is
like a flag
so that the script knows that we are
currently within the given session
and we want to save or store relevant
data
from that session so if in session is
true
and we were not in session in the
previous bar
then that means we've crossed into our
session and we set within session to
true
so again that might be confusing but
what what is happening here
is this bar here was not within our
session
but this bar was the script has detected
that the previous bar was not in session
but this bar was
and so we know that this is the
beginning of our time session
and then we can do the same for the
ending of our time session
where we check if a session is ended so
for this check we check
are we no longer within our time session
and
were we in our time session on the
previous bar that means we have
exited our time session
and we want to perform the calculation
for this relevant
uh time of day so the next thing we do
is declare a bunch of required variables
for
our analysis the first one uh these are
all var variables because we want these
saved across all the bars on our chart
the first variable is our recent
movement this is
the recent movement of the current
session so if i hover my mouse
over here you can see these numbers up
here
the purple number is the current
sessions range
and the orange number is this number
divided by
the average so it's basically a
percentage of
the average if i hover over here you can
see that this purple number
says 17.8 that's because we had a
17.7 and it's rounding up to 17.8 so we
had a 17.7 pip
range from this high down to this low
this was 17 pips
that is stored here in the recent
movement variable then we have our total
movement variable
this adds up all of the movement from
all of these sessions on our chart
and saves it so that later on we can
divide it by how many sessions we
counted in order to get the average
so next up we have our sessions counted
this adds up how many sessions we have
analyzed
we need this number in order to
determine the average then we have
max int i just added this variable uh
for our lowest low
so every time we reset for the next
session we set our lowest low to this
large number and the reason for doing
this is that
as soon as we start scanning a new
session
the lowest low is always going to be
less than this number
unless the price of the asset we're
analyzing
is above this number and i don't know of
any markets that have a price
larger than this number maybe there are
some out there but for the most part
this should work
on all the markets on our chart same for
highest high that's just set to a
negative number because
every time we start analyzing a new
session the first bar's high
is of course going to be higher than
negative one and this ensures
that in this example for example uh the
first bar
of the range was the highest bar in the
session
so when we begin saving our highest high
and lowest low of the current session in
this
block of code here our high is of course
going to be higher than negative one
which is the default setting for this
variable
and so no matter what the first bar of
the session will be assigned highest
high
and if any other bars in the session are
higher than this bar then this will be
overwritten
with the high of that bar and lowest low
is initialized as our max
integer value all right so this is where
most of the
sort of the bulk of the script occurs
the analysis that the script does
so the first thing we do is we check if
the session has ended so
again is the current bar out of our
session and was the previous bar within
the session
then we've exited our session or the
session has ended
so we set within session to false so
that this code no longer executes
and we analyze the movement of the
recent session so recent movement is
assigned to the highest high
of that session minus the lowest low the
total movement
is incremented by the recent movement so
this just adds
up all of these session sizes across our
entire chart
and then we divide that number by how
many sessions we analyze in order to get
the
average then we increment sessions
counted by one
so every time we analyze a new session
our sessions counter
increases and then we reset our stored
high and low for the next session so
that when the next session begins
these numbers get overwritten as soon as
price is being analyzed so once this
session ends
they are both overridden with
their default values so the highest high
goes to negative one the lowest low goes
to a large number
the next block of code here simply gets
the highest high and lowest low of the
current session so if we are within
the time period we want to analyze and
the current bar's high is greater than
our saved highest high
then we want to overwrite that highest
high with the current bar's high
same with the low then once we've done
all that we can calculate the average
pip movement over all analyzed sessions
so to do that we just divide the total
movement
by how many sessions we counted that
gives us the average
and then we can plot all that data to
the chart so we plot our
volatility info if we are within a
session
then we plot our highest high and our
lowest low and if we are not within the
session
then we plot our recent movement and our
recent movement divided by the average
movement so that's the purple and orange
number up here
so you can see this is the very first
session that we have counted on our
chart or analyzed on our chart
and so 17.8 divided by 17.8
is one so this was 100 of the average
and then our second session was 122
of the average but we're only analyzing
two sessions here just for demonstration
purposes
if i were to set this to let's say 2001
and click ok now the script is analyzing
every session on my
chart and you can see that the average
pit movement is 32.9
and so our orange percentage number
changes here so this session
was 80 of the average this session was
50
of the average so this was a quiet
session compared to the average
and then finally we make use of a brand
new feature
two-part script the team added very
recently and that is
tables so here we are creating an output
table to display
the average pip change and i'll leave a
link below this video
to the blog post that explains this
latest update
basically what we're doing is creating a
new table
we want the position to be in the top
right of our chart then we specify
our columns and rows i copy and pasted
this code
from the blog post and i haven't changed
these but i'm pretty sure we could set
these to one and one since i've only got
one
column and one row there but i'll leave
it as it is for now then our border
width
is set to three then we have a custom
function here that fills
the cell of our table we specify the
table we want to fill
the column the row the value
and then some text to add on to the
value
so all of this information is inputted
into the table.cell function
which fills this cell of the given table
with a given column number in the given
row
with our cell text and our cell text is
just converting
our value to string and then making sure
that we cap the decimal places at one
two three four five decimals then we add
on a new line
and our description text so that's how
we get
the pip change text below the number or
the value then we fill in all the other
information here the background color
which is just color.green
and transparency which is 80 and the
text color
is the same as the background color and
the width
of this cell is six now i think if i
remove this
then the cell should
change based on the text size
dynamically
that's much better and we only fill our
cell
on the very last bar that is loaded onto
our chart
this is for optimization purposes if we
don't do this
nothing changes except that our cell is
filled
on every historical bar on our chart and
this
number is basically overwritten every
time a new bar
is loaded onto the chart but we don't
want that we only want this information
to print to the chart
on the very last bar of our chart and
this is where we use our fill
cell function to put in our average
movement
as a whole number and then we check if
the symbol info
the market type of the current symbol is
4x if it is 4x then the text
we add on to our value is pip change
otherwise it's just
price change and that's it it's actually
a pretty simple script
the concept at least is quite simple but
hopefully you found that interesting
and maybe you can think of other use
cases for this approach
for example i would like to play around
with a relative volume
indicator that uses this approach i
already have a few
relative volume scripts that i've
written but i think comparing the
relative volume
to the average based on time here the
same way we've done here with price
i think that would be an interesting
concept to explore but anyway i'll leave
it there
thanks for watching and good luck with
your coding take care
all right thanks for watching everyone i
hope you found this lesson interesting
if you did make sure to hit the
subscribe button if you haven't already
because i will be back very
soon next week in fact with a new pine
script video
next week's lesson is going to cover how
to set up a virtual private server
so that you can run auto view 24 7 on a
remote server
so you don't need to leave your home
computer running in case your girlfriend
or your wife
doesn't like the sound of that or in
case your power bill is a little too
high and that will be the final video in
my auto view series and then we'll move
on to other topics
including a expert advisor that was
brought to my attention recently
it's a script that runs in metatrader
that can
read or receive your trading view alerts
and
execute trading commands based on those
alerts through metatrader which is
pretty powerful stuff
and i'm really excited to explore that
tool oh and by the way if you're
watching this video after this
promotions ended
there is also the coupon code youtube
which will get you 10 off all of my
courses
it's not as good as 25 but hey i can't
give discounts out all the time
i already think i've priced my courses
at a pretty fair value
so that'll do it for today thanks for
watching everyone i appreciate your
support
for the channel have a great weekend and
best of luck with your trading
as always take care
How to use METHODS in Pine Script
g'day Traders today we're answering
another question from a student in the
Mastery course and this student wants to
sort an array of EMA values but also
keep the corresponding ticker ID
associated with that value while being
able to interact with the arrays so for
example in this case we're sorting the
array in ascending order so the lowest
EMA value is first the highest is last
but we're also keeping track of which
ticker each value corresponds to now the
methods I'm using to achieve this are
quite interesting and the script
actually makes use of a brand new pan
script feature that was released a
couple of days ago called custom methods
so in this video we're going to be
covering how to create custom types data
types and we're going to be covering how
to create a custom method and this is
the new feature I'm speaking of method
syntax comes to panscript so if I scroll
down here the blog post here says the
dot notation used for extension methods
in other languages is now available in
Pine scripts I love the guys that write
these blog posts they're clearly
programmers they're not speaking to
Traders they're speaking to programmers
with all this jargon basically what this
means is if we're using something like a
box for example excuse my childish
writing with a mouse the dot notation is
this so dot new
and then we can use a function or it's
actually a method but a function and a
method are pretty similar you don't
really need to know the difference in
pinescript to be able to use them
properly if I scroll down here see this
line here Source array dot push value in
the past you would have to do something
like this array dot push and then pass
in the array ID and then the value but
now with this new method feature added
to Pine we can do exactly the same thing
by just saying array ID dot push value
now in this particular example it
doesn't make our code that much more
efficient but in a complex script you
can see how this can really help tidy up
our scripts and make the code a bit more
intuitive to read especially so without
further Ado let's jump into the pine
editor and start writing out the script
all right so here's our starting
template all I'm doing here is creating
a regular indicator script with overlay
to true so we're drawing over press
action and we're getting five ticker
inputs or symbol inputs it doesn't
really matter what these are they could
be anything but for today we're sticking
with Forex so we're just working with
oanda we've got euro dollar dollar Yen
New Zealand dollar pound dollar and gold
and what we want to do is get the EMA
value for each of these the 50 EMA on
the daily chart daily time frame so
we're going to be using the security
function here then we're going to insert
all of those EMA values into an array so
we're going to be creating an array
based on a custom type so before we do
that we need to Define
our custom type that stores both
the EMA value and the ticker ID so to do
that we use the type keyword doesn't
matter what you call this I'm going to
call it EMA underscore sorted wow if I
can spell EMA underscore sorted and now
we need to define the data types that
are stored within this overall class
type so I said we need to store the EMA
value and the ticker value so that's a
float value and a string value so we can
just declare these values in here so
float EMA value and string ticker
that's it we have defined our custom
type now we can create a type based on
this by simply saying EMA sorted my
custom type equals EMA sorted.new
and then it takes the float value
and a ticker string and so now what we
need to do is create five of these for
each ticker ID and get the EMA value
using the security function for each but
before we do that let's declare our
custom array so for this array I'm going
to make it persistent so it doesn't
reset on every new bar on our chart
that's because on each bar we're going
to be setting each of these five values
in the array so we don't really need to
recreate the array on each new bar this
will just make our script compile and
run a bit faster so to Define any array
the syntax is usually like this array
and then open
arrows and then the data type of the
array needs to go in between these
arrows so if we're going to create a
array based on a custom data type we
need to paste our data type name into
this array syntax and then I need to
give it a name so I'll just give this
the name of just EMA array and then we
need to set it to array dot new open
left arrow and then we need to put the
data type in again
and also specify the size of the array
now this is optional but for today we're
going to set it to five so we have an
array based on a custom data type with a
total of five elements and that's going
to be these five custom data types so
now we have our array declared let's get
our EMA values so since today's lesson
is not about the security function I'm
just going to copy this code over to
save time it's not that complex anyway
all we're doing is requesting data from
a security that is not this symbol be
passing our symbol IDs our ticker IDs
the time frame we want to get this data
from and then the expression the data
that we want to request from the
security in this case that's the 50 EMA
based on closing price from the daily
chart for each ticker or symbol now we
have these five EMA values
the next thing to do is completely
optional but because it makes it easier
to understand what's happening we're
going to draw all five of these onto the
chart this is obviously optional we
can't really do much with this
information since this is all EMA values
for markets completely unrelated to this
one but at least we can see our values
up here now and what we want to do now
is add all of these to an array and sort
them in ascending order so lowest number
to
the highest number in order to do that
we need to insert all of these values
into our array so that's going to look
like this now notice that for the first
time as of a couple of days ago we can
now use dot notation with arrays to
interact with those arrays so as I
mentioned earlier in the past in order
to do this sort of thing in order to set
the first element of this array to any
value we would have to write array dot
set
and then pass in our array ID then pass
in the index then pass in the value but
now we can skip this part and just
simply put dot and then the method that
an array typically has access to and
here we go now it's not that amazing but
for any of you experienced programmers
out there you know that this is pretty
cool feature then I'm surprised it took
this long for the trading view
developers to add it to Pine it's much
more intuitive this is much more similar
to traditional programming languages now
the syntax we can use here is much more
intuitive for most programmers out there
who work with the more popular languages
like python Java JavaScript C and all of
those sorts of languages so anyway we
need to set all five values here so I
can copy and paste this line a few times
remember array values elements start
from zero the first index is zero so
zero one two three four gives us five
elements we need to pass in the value of
each EMA and each ticker string so we're
setting each array element in our custom
data type array to all of these values
and we're creating a new EMA sorted type
passing in the email value in The
Tickler for each and now we have
everything we need in order to
manipulate this data in this case we're
going to sort the data in ascending
order and to do that we're going to use
the new method
feature now methods work pretty much
identically to custom functions so a
custom function will look like this
let's say you have value 1 value 2.
and you want to return whatever value
one multiplied by value 2 is this is how
you would Define a custom function that
multiplies these two values and outputs
them and then we could plot this by
saying what's 1 times 2.
save my code and we're getting two
plotted up here using this custom
function now to do a method a custom
method it's pretty much the same syntax
except we need to use the method
keyword in front of this and so our
custom method is going to be called sort
custom array and now this is where
things get pretty complicated
particularly for this lesson if we make
the very first parameter of this method
an array then we can call this method by
using the
dot notation I showed you just before
so we can use this syntax to sort out
EMA array if we make the first parameter
in this methods parentheses a custom
array like this and now we need to use
the same custom function syntax equals
sign followed by a right arrow enter Tab
and then anything within the scope is
executed by this method when we call it
now normally if you're just working with
a standard float array
um like this let me comment this out so
this compiles properly
if we had an array like this
test array equals array float
array.u
float
five values if we had a normal float
array like this we could simply just use
the test array.sort
function and this would sort the values
in ascending order however with our
custom data type this function won't
work so if I paste EMA array in here our
script is now broken because biascript
doesn't know how to sort an array filled
with data types of this nature it
doesn't know that we want to sort the
array by EMA value so what that means is
we need to write our own code for
sorting the array elements and that's a
little bit tricky it's not too crazy but
it does require some pretty scary
looking code if you're new to buying
scripts for those of you who are
experienced this won't be that bad but
we just need to Nest two for Loops
within each other and then these two for
Loops will will cycle through the array
and compare all the elements to each
other and then set the array elements in
order of their values in this case
ascending order so to do this we need to
create our first which is going to be 4i
equals 0 2 Source array dot size minus
two I'll explain why it's made is two in
a moment but now we need to Nest a
second for Loop here and so the second
for Loop is going to Loop within this
for Loop it needs to have a different
index value obviously we can't call this
I so we have two for Loops here the
second for Loop is going to be set to
the first for Loops index plus one and
We're looping two
our source array dot size
-1 and so now what we can do is we can
check if Source array dot get I so
that's this first for Loop value or
index array index so we get that value
now remember when we get this value it's
going to be this data type our custom
data type so what we can do here is say
EMA value
if
the first Loops EMA value is greater
than the second loops
BMA value then we need to swap their
positions in the array so to do that we
need to create a temporary data type
here called temp
equals Source array.get I and then we
need to set Source array dot set I to
this for Loops element so I can copy
this here and change this to J
and then we need to set the
second
for Loops array element to our temp data
type so we're essentially swapping these
two elements position within the array
because they are not in the correct
order so now if I save my code let's
just make sure this compile is okay
there we go no problems now what we can
do is
call this custom method
on our custom data type array
so we can sort email array we could also
call this function like this
email array
that would do the same thing so now you
can understand why methods are very
similar to functions in fact if we got
rid of this
and at the end of our for Loop we just
return the source array we could do
something like this so this is how it
would work in the past you'd have to use
a custom function and you'd have to call
it like this but now that we have the
new method functionality we can simply
do that and that makes coding a lot more
efficient when working with complex
scripts like this so
here we are defining our custom array
sorting
method we're calling it here the final
thing to do is draw this data to the
Chart so I'll just copy this code over
to save time here we're just checking if
the script is running on the final bar
on our chart we're creating a array text
it's blank to begin with and then we
Loop through all of our Ray elements and
we append or add the array elements text
to this value and then finally we create
a label with the text so that we can see
what the heck's going on with our custom
function so now if I save my code we
should be getting the script to be sort
of the beginning of the video there we
go
sorting everything in ascending order
using a custom method a custom data type
and a array based on that custom data
type so we covered quite a few Advanced
Pine script Concepts in today's lesson I
hope you guys found this interesting
just to wrap up the lesson I want to
cover a couple things first of all this
probably looks a bit complicated we can
get rid of this line of code here and
just add on a new line at the end of
this so now if I save my code the label
will still be drawing but we have a
blank string at the bottom of the label
that's why I added this uh extra line
here this just checks if this for Loop
index is equal to the final Loop if it's
on the final Loop then we don't add a
new line character to the label text and
that's obviously purely optional just
makes the label look a little more
symmetrical for all of you OCD Traders
out there what else is there to cover uh
with the for Loop here the reason why we
have to subtract 2 from this original
for Loop is is because if we don't do
this we get an array index out of bounds
error on the final Loop if I change this
to -1 and save my code the script will
no longer compile because in
array.getfunction index 5 is out of
bounds so that's why we need to subtract
2 from our original Loop but we don't
need to do that for the second Loop
because the second Loop Loops up to the
final element where this Loops up to the
second final or second last element and
then this for Loop runs on that second
last element and we're adding one to the
original array index and so this for
Loop runs on the final array element
even though this Loop doesn't Loop up to
the final element hopefully that makes
sense it's really hard to explain this
sort of stuff but if you play around
with this code and try sorting your own
custom data types I'm sure you'll figure
out what I mean with practice the final
thing I want to do before we end this
video is I want to show you guys how we
could add
a optional Boolean value to this method
called ascending and ascending is always
going to be set to True by default so
this is how you declare a default
parameter now if I save my code
everything will compile without any
problems if I get rid of this equals
true however now we have a problem
because this is no longer an optional
parameter and our function call our
method call here requires us to specify
whether ascending is true or false
like so but for this example that I'm
about to show you we're going to leave
this as true by default and then what
we're going to do is check in this if
statement this value and if this value
is false we're going to sort the array
by the opposite direction descending
order so what we're going to say here is
we're going to say if ascending and this
condition is met the element of I is
greater than the element of J if that's
true we swap the elements or and then
I'm going to put this on a new line just
because it's easy to read otherwise it's
going to be off my chart here to split a
if statement across multiple lines you
need to press space after you hit enter
otherwise you get a syntax error and for
the second check the second condition
we're going to check is ascending not
true and are our array elements in the
opposite direction so is element I less
than element J if so then this for Loop
will sort the array in descending order
so now if I put false within this
parameter within this methods
parentheses and hit save this list will
now be sorted in the opposite direction
so now we have the highest number at the
top or the first element in our array is
the highest number all the way down to
the lowest number you could also achieve
this by just calling EMA array dot
reverse because we're sorting in
ascending order so we could just reverse
the order of our array we want to but I
thought it was cool to show you guys how
we can add this optional parameter into
our method so remember if we don't
specify a Boolean value here then it's
going to use this default value which is
true and we're going to sort the array
in ascending order anyway my brain is
fried after this video I hope yours
isn't but it did take me a while this
morning to figure this out so I've been
coding for a couple hours I'm going to
go take a break now as always the source
code will be below if you want to play
around with this I hope you found this
video interesting if you did make sure
to subscribe hit the like button all
that YouTube stuff if you want to learn
more about planescript check out my
website pinescriptmastery.com there's a
free course there for all of you
beginners if this went way over your
head then you might want to start there
it's completely free and has several
hours of content covering the basics of
Pine and finally if you're not aware I
do a Weekly Newsletter email that's also
free where I share book podcasts
websites blogs animal sacrifice
techniques anything that helped make me
a better Trader I'm kidding about the
animal sacrifice I don't do that but
there is plenty of free awesome content
on my website the art of trading.com go
and check that out if you want to learn
more about Pine script or just my
trading style and knowledge in general
as always I hope you have a fantastic
weekend best of luck with your trading I
love you guys thanks for being here
thanks for supporting the channel and
I'll speak with you in the next video
take care
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...
-
9XVmTMv2TOE so hello there and welcome to another tutorial my name is Tammy Bakshi and today we're going to be go...
-
cf24R12l0uw [Music] so well there and welcome to another tutorial my name is Tammy Bakshi and this time we're goi...
-
5I8rLVvcbok hey guys welcome back to another lesson in this lesson i'm going to be covering a popular request whi...