Sunday 20 October 2024

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 connector into metatrader 4 so that we can automate our trading view scripts now I've already done a video on metatrader 5 that is the platform I will be using personally to go through the rest of this series but for those of you who have a broker that does not offer metat trator 5 or you prefer metat trator 4 I'm going to quickly show you how to set up Pine connector for this platform now if you want to know more information about Pine connector go and watch the metatrader 5 version even though it shows you how to install Pine connector on metatrader 5 I also go into a lot of information about what Pine connector is and how it functions and I'm going to skip all of that for this video to keep it really brief I don't want to repeat myself unnecessarily so if you're new to Pine connector and you have no idea what it is go and check that out uh the metat trator 5 version of this instructional video now before we continue I need to mention that this is not trading advice I'm not a financial adviser this is risky stuff if you don't know what you're doing if you're not a competent Trader I recommend you stay away from Pine connector or at least spend a lot of time on the demo account before you even consider uh live trading using this expert advisor there is a lot that can go wrong you can lose money very quickly if you don't know what you're doing but in this video series on Pine connector I will walk you through each step of the way and for those of you who are comfortable with the risks involved in automated trading we will automate a script by the end of this series I can't promise it'll be profitable cuz it's an example script but I will show you guys how to set up a fully automated script through trading View and pine connector so that you can execute trades on your broker while you sleep anyway with that out of the way let's continue with the instructions let's download the windows version of metatrader 4 and let's install this onto my system next and then click finish we can close this tab I need to select server 01 next existing trade account paste in my um metatrader account number I'm going to change these account numbers these are demo accounts anyway way um but if you're doing this yourself don't give this number out uh because people can try to screw around with your account so click finish to log in hopefully this works there we go incoming mail there we go we have logged in and once again we need to turn off these obnoxious sound effects so I'm going to go to tools options events and stop that click okay there we go all right so let's jump over to the Pine connector instructions and download the metatrader 4 expert advisor for Pine connector so here I am on my members portal the first thing I need to do is change my account number because I've already set this up on metatrader 5 so if I go to file uh login copy this number and paste it in here now my license will work with this new metatrader account number now you need to use your own metatrader account number number this will not work with my number it needs to be the one you've logged into your platform with so now that I've done that I need to download the metatrader 4 expert advisor so I can open this folder up right click this EX4 file cut open up metatrader go to file open data folder then we need to go into mql4 experts and paste this file into here now I can open up my expert advisors tab down here right click on this and click refresh and here is our Pine connector expert advisor but before we use this we need to change a few settings so we need to come up to tools options um expert advisors we need to click to allow automated trading and we also need to allow these dll Imports now this allows expert advisers to do things like access the internet outside of the platform which is required for uh Pine connector if you're not comfortable with this make sure to reach out to the Pine connector support team to discuss any apprehensions you have but personally I trust these guys I've used them for a couple of years now so I'm going to allow that click okay and the final thing we need to do is make sure this is turned on make sure this is green um now let's go through the instructions here if I click EA guide let's make sure I haven't missed anything we click on metatrader 4 I've downloaded the EA I've installed it into my data folder into mql4 I have allowed dll Imports I have enabled auto trading the final thing to do is attach the pine connector EA to my chart so I can right click this and click attach to chart now I need to come to commment make sure allow live trading is turned on and allow dll Imports is turned on as long as these two options are on the expert advisor should be able to execute trades through our broker through the metatrader platform now we need to come to inputs this is where we put in our license ID now there'll be a link in the video description if you haven't used Pine connector before it's an affiliate link so if you do sign up I do get get a small cut of your payment at no extra cost to you so if you want to support the channel that's one way to do it but if you don't want to support the channel for whatever reason uh that's fine to just go to the Pine connector website and sign up for a free trial you get a 7-Day free trial um get your license ID from your uh the main site dashboard so if I go to members portal scroll down and copy this number I can paste that into here and click okay and now assuming I've done everything correctly this should enable Pine connector there we go we have successfully connected to Pine connector's server everything is good to go so let's jump back over to the instructions here I've allowed live trading and dll imports on the expert advisor settings tab I've inputed my license ID we have successfully connected to the server so our connection is good um the final thing to do is send a test alert to make sure this is working correctly so first we need to find a symbol so if we go back to to metatrader and I go file uh or view where is it here symbols you can press control U on a Windows computer or just click symbols here uh we go to FX Majors we need to make sure that the symbol we want to trade is enabled so if we double click on these you can see they turn gray that means that trading is not enabled on these symbols and the expert advisor Pine connector uh will not be able to execute trades on these symbols if we send alerts to these symbols so we need to enable all the markets we want to trade once these are enabled we can click close now notice in my symbols list we're going to send a test command to open a long trade on euro dollar and my euro dollar symbol in this list has a suffix so depending on the broker you are using you may have a prefix or a suffix on the market you want to trade in my case I have a suffix which is a full stop a I need to send this entire string to Pine connector in my alert if I want to open a trade on euro dollar so let's do that now let's scroll down through the instructions we have enabled euro dollar we have gone over the suffix here so the final thing to do is um copy this line here go to trading view let me delete the metatrader 5 test alert click ADD alert make sure that euro dollar is selected um I went over this in the metat trader 5 version of this video but it is IDE to use the same broker feed you can see here this says pepperstone that is the same broker I'm using on my metatrader platform this is not necessary you don't have to use the same um data feed as long as you send the correct symbol the correct symbol oh my goodness Euro doll. a as long as I send this to the correct link with the correct license ID it doesn't matter what Market I trigger this alert on the trade will go through to Pine connector here but obviously does help to be using a data feed that is as close as possible to whatever your uh metatrader platform is using so in this case I'm using euro dollar on metatrader and uh trading view through pepperstone um and the data feed is pretty close so we shouldn't have too many issues with trades being executed at um different prices on both platforms so now I can paste in what I copied from the pine connector website and now I need to replace my license ID and my symbol with the corresponding parameters to trigger an alert on euro dollar so to do that I can come back to this page copy my license ID I paste that in here now this license ID again corresponds to your metatrader account number so you can't use my license ID don't even bother trying you need to create your own um but there is a one week free trial for those of you who aren't ready to commit any money to this and you just want to play around make sure to sign up to the free trial um go to your member dashboard copy your license ID in here buy means we are going to buy at Market risk equals 1 means with the default um expert advisor settings with the default settings here uh we will go over these settings in detail in future videos but for now using the default settings sending a risk equals one command will open one standard lot on the symbol we specify and for the symbol remember we need to type out the um the market we want to trade and then the suffix so a now I need to change my condition to greater than zero and now this alert will trigger as soon as I create it and price moves because obviously price will always be greater than zero unless the world has imploded and the euro is no more uh but hopefully by the time you watch this video that hasn't happened anyway the next thing we need to do is come to Notifications make sure web hook URL is turned on and this link is pasted in you can get this link from the uh instructions here so you need to copy this URL paste it into the web hook turn the web hook on all of these other settings do not matter they're optional if you want to be notified when your script executes a trade then you might want to set these up when you create your alerts but for today's test we don't need to worry about that um and it looks like we're good to go I'll just change this to Pine connector test mt4 now when I click create this should trigger immediately and we should either get an error in the experts tab or trade should be executed there we go it looks like our trade executed just fine there we go we have a trade opened we have opened one standard lot on euro dollar at Market um using an alert sent from Trading view amazing stuff now if you get an error in this experts tab uh when you try to trigger this alert if there's an error code here like a number then you need to come to pinec connector.com error and then if you you search for your error code um there should be a description on what the error means and Rec and recommendations on how to rectify that error but we didn't get an error luckily uh this works straight out of the box with the default settings so I can wrap this video up here and in future videos we will go into more detail about the settings of this expert advisor I'll be doing most of my um personal examples on metatrader 5 but you guys should be able to follow along on metatrader 4 if you're using metatrader for because these settings are pretty much identical on both platforms with all that said I'll wrap this video up here I'll speak with you in the next one take care and good luck with your training

PineConnector Template for AUTOMATING Pine Script

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

PineConnector Settings Guide - Automate TradingView Scripts

hey what's up Traders I'm Guy Sebastian and in today's video we're going to have another look at Pine connector today we're going to break down the pine connector settings and the syntax commands for sending alerts from Trading view to metatrader to autot trade our Pine script indicators and strategies I'm going to open up the settings for this expert advisor um in the previous video I recorded on a 4K resolution so you'll notice this dashboard thing looks kind of janky in the first video of this series I'll record on 1080p for the rest of the series so this looks normal don't be alarmed by all the red in this uh dashboard I accidentally left the trade open from the last video and it racked up a pretty big loss on euro dollar but luckily this is a demo account that's why we use demo accounts for this sort of thing when we're learning and setting up um tools like this I do have pine Connector running on a live account it's running on my ultimate pullback indicator um you can get more information about that on our website pinescript mastery.com if you're interested it's um got full integration for Pine connector all you need to do is insert your license ID and any relevant parameters for Pine connector and it will automatically send any trading signals to Pine connector and it's working really well over the past few weeks so towards the end of this series after we've gone over a lot of the um core fundamentals of pine connector I'll revisit that script I'll show you what the results are and we'll break down what I've learned from that experience and what tips and advice I can give you guys um but anyway let's get into the pine connector settings if this is the first video you're watching make sure to go back and watch the first video in the series I've got an instructional video on how to set this up for metatrader 4 and 5 two different videos I'm using metatrader 5 but it shouldn't matter what platform you use the settings will be slightly different in some areas but the core fundamentals are all the same so I'm assuming you've already set up Pine connector and today we're going to open these settings to do that we can just right click our chart we come down to expert list and then click properties now again you will need to use your own license ID you can't steal mine um because it's linked to your metatrader account number so yeah don't try to use mine but the good news is you can sign up for a onee free trial if you're not confident that this is worth your money yet and you can play around with the full functionality of the tool for that full week all right so let's break down the core settings here I'll just do these quickly because in future videos we'll go over practical examples of these settings with actual scripts so obviously you need your license ID that's the most important input here if you don't put this in correctly then this tool will not work the next most important setting is our stop loss and take profit setting so by default it's set to Pips that is the recommended setting for Pine connector but there are other options here so if we set it to Pips then when we send SL and TP in our alert syntax so open up the charts these settings here and it does matter which order you put these in by the way when whenever you send an alert to Pine connector we need to first put our license ID then a buy or sell or pending limit order command then the currency we want to trade then we have our stop loss and take profit and risk if I set both of these to 50 and we open up the settings and have this set to Pips then our stop loss will be 50 Pips from the current market price when our trade is executed so we would have a 50 pip stop loss in a 50 pip take profit if I change this to price then these values need to be price values so if I wanted to put my stop loss at uh 1.58 I would type in here 1.58 and now my stop loss would be a price value but my takeprofit also needs to be a price value so we change this to 1.62 that would give us a roughly one:1 risk reward profile if our trade were to be entered at 1.06 the current market price and then the final option here is percentage that's exactly the same as Pips but obviously percentage based so most Traders probably wouldn't use this option maybe crypto Traders might uh but for Forex Traders it's unlikely you would ever use percentage based stop losses and take profits most of you will be working with pips but we do have the option for price as well if you need to use that option again the recommended option is Pips because that helps alleviate the issue of the pricing discrepancy between metatrader and trading view when your trade is entered it's entered at metat Traders price and so if you enter your stop L and take profit based on Pips that keeps everything as consistent as possible across both platforms next up we have risk so the default setting is set to Lots so if we set our risk to one and look on the left here we have these um example parameters if we set risk equals 1 in our alert then our position size will be whatever number we put here so in that example it would be one standard lot if we put 0.1 it would be one mini lot 0.01 would be a micr lot there are other options here dollar amount percentage of balance based on lots and margin available margin and then finally percentage of account balance as a loss so this is the most commonly used one I would imagine this is the one I use in all my scripts and this limits my loss based on a percentage of my account balance so if I set risk equals 1 and I have this set up in the pine connector settings then if my trade loses I will only lose 1% of my account balance now on the settings page there is more information here so under volume there is a description of each setting so go and read this if you want to know more about these middle three options but for me I will mostly be using percentage of account balance so that's what I'll leave this on for now next up we have our pending order this is our entry order so if we send an alert of buy or sell like this that's a market order but if I change this to buy limit or sell limit now we're placing buy and sell limit orders and if we are sending buy or sell limit orders this setting comes into into play so by default it's set to Pips from current market price so if we send an alert that says price equals 10 then our buy limit will be set 10 Pips below the current market price on Pine connector uh on metatrader same as our Target type so our Target type has Pips price and percentage so does our entry pending limit order Pips price and percentage most most of the time we will be using Pips um but I'll show you some examples of these others in future videos finally we have account filter basis and we have four settings here balance Equity margin percentage and free margin let's go over to the settings page and read what these do so this setting helps filter the trades that Pine connector can take so if we choose balance and we set account filter to 1,000 then the signal will only be processed if your account balance is greater than 1,000 if it's set to equity then our open Equity needs to be greater than 1,000 if we set it the free margin then our margin needs to be greater than 1,000 and margin percentage is the same as uh free margin but uh but obviously this will only be processed if your margin percentage is more than the specified number so I personally don't touch this setting in my own trading or rather I don't send this parameter in my alerts but this parameter here is there for you guys to basically control your risk that's what this setting would be mostly used for that way that way if your script goes ballistic and starts pumping out dodgy trades um you have like a a break an emergency break limit um if your account balance Falls below a certain number the expert advisor will stop taking trades or if you just have a lot of um signals being generated and you don't want to take any trades when your margin is used up for example so you're not getting margin calls anyway moving on to input so here is like a master override that you can um input so that when you're trades are received by the expert advisor these settings are used instead of whatever you send from your alert I've never used these settings um so I'm not going to go over these but this option is here for you if you need to do this for whatever reason um personally I like my script to send my trade parameters so I leave this setting as it is um so let's move on to General pyramiding so typically pyramiding is used to add to winning trades the first setting is on if you set this to on then all incoming trades will open without restrictions so if you have a hedging account that allows open long and short trades on the same symbol then any long and short trades that come in will be will be allowed to execute if you select on if symbol and direction in profit so this setting here then the trade will only open if if you have no open trades on euro dollar or your open trades on euro dollar have a profit that's Break Even or better and if we set it it to off either one buy or sell then if you have one trade open on euro dollar then a short trade will not open or if you have one uh Buy trade long trade on euro dollar another long trade will also not open and then finally we have off only one buy and one sell this will allow one long trade and one short trade to be open on the same symbol so these are advanced settings for accounts with hedging enabled um some Brokers allow you to have that setting enabled so that you can have long and short trades open simultaneously I personally have never played around with that just because it adds a lay of complexity to the back testing process that I'm not um comfortable dealing with I just can't be bothered I'd rather have a simple system that trades either long or short at any given time it's a lot easier to back test and prove that it works on historical data so I keep this um off typically so I'd usually have this off either one buy or one sell um or there's another setting down here Max open open positions per symbol I'll usually just set that to one and leave this on that way only one trade is open at a time but anyway we'll get to that next up we have close on reverse close on reverse determines the treatment of opposite signals so this is another setting that I've never played around with personally perhaps we'll cover this in a future video if you guys are interested in this but personally I leave this off and as I said I I stick to simple systems when I'm automating my trading next up we have Shadow targets I'm actually not sure what this is let's have a quick read Shadow targets hides your intended stop loss and take profit now I actually have no idea what this is we'll have to play around with this in a future video I've again I've never used this setting I'm not sure what that does Shadow targets hides your intended stop loss and take profits I'm guessing it means it doesn't enter these stop loss and take profits into the market to hide your stop- loss and take profit from your broker I'm guessing that's what this does we'll have to play around with this in a future video moving on partial close percent percentage this determines the percentage of your positions to close when using the close long percent and close short percent commands so we have three options 25% 34% and 50% this is obviously useful for scaling out of positions instead of exiting your trade entirely this is also not a setting I've ever played around with perhaps we'll cover this in a future video if you guys are interested in that uh next up we have Max open positions this defines the maximum number of positions across all of your symbols so if it's set to zero the pine connector EA will not limit your position count if it's above zero then uh Pine connector will limit how many open trades you can have accordingly so let's say you set up alerts on like 20 different markets but you only have enough money in your account to have three or four open trades you might want to set this number to three or four that way you won't be getting margin calls and trades trying to execute when you already have a lot of open trades um and then finally we have Max open position positions per symbol which does exactly what it sounds like defines the maximum number of positions per symbol um I typically set this to one um because I as I said I trade simple systems that only have one open trade per symbol I prefer to trade lots of symbols and only have one trade per symbol then have lots of Trades executing on a single symbol just makes it a lot easier to go through the strategy development process and back testing for me personally the way I do things all right let's wrap this video up with the last few settings categories here next we have dashboard that is this dashboard here and um we'll maybe break this down in a future video cuz there's a lot of information here to dissect but uh this shows you your p&l and your performance metrics for your system since um from Pine connector's perspective based on live executed trades you can see my giant loss here from the trade I left open from the previous video and if we go to the documentation here um the settings we have to work with are profit computation so by default it's set to calculate your p&l while including commission taxes and swap fees so that's really cool that gives you a very realistic portrayal of your systems performance metrics um then you also have the option to display this information without commission taxes and swap um but your results will be um better than realistic when you have this setting turned on because it's not taking into account all the hidden costs of trading in terms of system development so your back testing results will usually not show this information at least not on trading view since trading view doesn't have access to this information from your broker directly so these are the sorts of things you need to factor in during your system development and back testing process but by running your system on a demo account or a small real money account for a couple of weeks you should get a pretty realistic representation of how your system's performing with these fees um included in that performance you can also change the font size and turn the dashboard on or off um so if we go to experts properties dashboard um you have three options here Tech size on or off and the uh calculation technique then we have some risk parameters here so let's go over the documentation for these um first we have daily profit this determines your daily account takeprofit the daily recompute occurs at midnight GMT so that's important to know if you're using this set if it's off then your system will just continue taking trades regardless of how much profit you make in a day if it's below one then you're using a percentage amount so 0.1 in this parameter here would turn your system off it would stop allowing Pine connector to take new trading signals if your profit for the day exceeds this number personally I've never been a fan of limiting The Profit I make in a day but there are probably reasons to use this um especially if if you're trading a managed account and you're trying to keep your performance metrics and your Equity curve volatility in a certain range so a number below one would be a percentage amount so 0.01 would be 1% 0.5 would be 50% so on good luck making 50% in a day um but if you do more power to you if you set this setting to a number greater than one then this is a dollar amount so 100 would mean that if your account makes $100 worth of profit your um expert advisor will stop taking trades and you can check the day's profit Target using your experts log which is this setting here next we have daily loss which is exactly the same but obviously limits your daily loss which is a setting that it makes a lot more sense for me to use Um this can stop your system from going haywire if your system is taking a lot of Trades and you're racking up losses quickly um setting a daily loss limit can protect your account from that happening again if you're trading managed accounts you might want to turn this on so that you don't exceed your daily loss limit if you're a retail Trader you probably use this mostly to protect your account from something going wrong with your system or maybe you're a day trader and you want to limit your loss for the day not a bad idea to use this setting if you're trading lower time frames especially and it works exactly the same way as the daily profit limit um but obviously this is losing percentage and losing dollar figures and then we have our action so this is the action the EA or pine connector will take if one of these um thresholds are hit so halt EA will stop the EA for the day and it will restart automatically on a new day which I'm guessing is midnight GMT as it says up here so at midnight GMT your daily p&l will reset and if you have the setting turned on um the new day's p&l cumulative p&l will be acted on on accordingly you could also set it to close all positions so if your daily profit or loss is hit it exits all of your open positions or the third option is to close all positions and halt the EA so if you just have halt EA on and your daily loss limit is hit for example then all your open positions will still play out so if you've got stops and targets set the trades will play out as they were set up um but no new trades will be taken however if you set close all positions and hold EA then it will exit any open position positions and also hold the EA so you'd probably want to use this setting if you're going to use a loss limit on your uh account next up we have cumulative profit so this is like the daily p&l um setting except it's for cumulative profit since Inception so since you started running your system um this setting will add up your pnl so we open up experts properties so we have a daily profit and daily loss limit limit and an according action and then we have a cumulative profit and cumulative loss limit um and a ea action so we can hold the EA for a day we can hold the EA permanently until we turn it back on manually and then we have our same options but we close all positions or we close all positions and pause the EA for the day or we close all positions and turn the EA off until we manually override this and that's it that's the core settings for Pine connector again we'll go into more detail on these settings in future videos as we start coding scripts to send this information these parameters directly to Pine connector from Trading view alerts so that we can automate our trading um so far we've only done test alerts using uh test alert syntax in future videos we will code all of this and I'll give you a template for a script that includes all of this information so that you can set up your alerts like I have here with my UPI I can select my script select any alert function call make sure my web Hook is turned on and my license ID is inputed into the script and then whenever my script detects a training setup an alert will be generated and sent to P connector you can see here a signal is being detected if this signal closes valid so this bullish engulfing candle closes with all the conditions met in 45 minutes from now uh Pine connector will execute a trade on my Live account so really cool stuff here really powerful um it's a really powerful tool for systematic Traders I hope you found this video interesting thanks for watching I love you guys I'll speak with you in the next video where we'll start coding we'll go into more detail about the syntax so so far we've only really covered fixed profit and uh stop losses and risk in future videos we'll cover more Dynamic stuff like trailing stops how to exit trades so for example based on exit reasons so if I come up to the settings of my UPI and scroll down to um exit settings I've got the option to use a trailing stop here that will use a a trailing stop to lock in profit so once my target is hit the script will start trailing my stop loss until it's hit we can send alerts to Pine connector to update our stop loss as it changes or I can tell Pine connector to close a trade when an exit reason is detected so if I say so for example if I turn on use higher close lower close exit as soon as my target is hit and we get a candle that closes above the previous candles high I can tell Pine connector to exit that trade at Market so there's some really cool powerful combinations of settings and script parameters and code that we can use to create pretty versatile trading view systems that can be automated through our broker using pine connector that's where the fun stuff will start to happen in this series so make sure to subscribe to the channel if you haven't already and I'll speak with you in the next video take care good luck with your trading now none of this is trading advice be careful out there it is possible to lose a lot of money if you don't know what you're doing with this stuff so take it slow start with the demo account if you're going to play with this tool treat it with respect and you should do just fine have a fantastic day and I'll speak with you soon goodbye

Pine Scripters Network • Join Our PINE SCRIPT COMMUNITY!

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

Pine Script [OUTDATED V4] Tutorial Lesson 9 How To Avoid Repainting!

hey traders welcome back to another pine script tutorial my name is matthew from zen and the art of trading and today i'm excited to ramp things up a notch and explain to you how to create a higher time frame indicator that references the previous day's high and low and doesn't repaint now that sounds like a mouthful to you that you just don't understand then I highly recommend you go back a few lessons maybe to the start if you're new to Pine script but what are we doing here well let's go out to the daily chart first of all and hide this indicator and let me draw in a couple of lines so first of all let me draw in the high of this day and the low of this previous day the script that I'm going to teach you how to code today will do just this it will draw the previous day's high and low over your intraday charts so now if we drop down or one hour chart you can see that the high of the day was this wick here and the low of the day was this wick here and everything that is happening today as at this bar here is within the context of this previous day's high and previous day's low so all of these bars this is basically all of today has been an inside bar meaning that the high and low of today's bar is contained within the high and low of the previous day's bar and so if we get a breakout today that'll create a new high new daily high and that's the purpose of creating the script I'm going to show you how to create today we can use this script to see how price action is performing within the bounds of the previous day's high and low but I'm gonna take this lesson one step further today and I'm going to show you how to achieve this without repainting to your chart so before I continue if I turn the script off this um today I'm going to recreate a script I made a while ago so if you type into the indicators box HTF you'll see here this indicated by a zen and the art of trading called higher timeframe high and low if you click on that this script does basically the same thing the difference is I haven't updated it yet let me change this to daily but this script repaints repainting is the arch-nemesis of all beginner pan script coders basically what this is doing is that on historical bars it's referencing the previous day's high which is what we want but on the current bar as it's moving as the price is changing our value is changing so if I hover my mouse over the current bar you can see that that's where these values change they diverge from the historical values the reason for that is that these historical values are referencing the previous day's high and this current value is referencing the current daily bars high because every time price action moves it recalculates the higher time frame values we don't want that not on this particular script and some scripts you may want that but on this particular script we do not want this what we want is this a clean line a clean value that shows us the previous day's high in context of the current price action so you can see here that price action is actually breaking through the previous day's high but if I turn on the repainting script our high is changing with price action so today I'm going to show you how to eliminate that I'm going to show you how to manipulate a higher time frame data to show the high and low of the previous day or week change this to week and it will show the previous week's high and low and so all of that and more in today's lesson let's get straight into the coding so first things first let's start with a blank slate I'm gonna create a new blank indicator script and I'm going to save it and call it lesson 9 and so here we have a blank script I'll get rid of some of this because it's unnecessary for today and now we have a clean blank script or blank canvas if you will so I'm going to rename this script lesson 9 you can call it whatever you want to and I'm going to set the overlay to true now as always I'd like to begin my scripts by getting the user input variables so I'm going to write a comment here saying get user input and the first input we're going to get is what time frame to reference so I'm going to call this res short for resolution I'm going to use the inbuilt input function it's going to have a title a settings title of time frame and it's going to be of type input dot control space to bring this box up resolution is what we're looking for so that's another word for timeframe the final variable we're going to put into this input function is the default value and today we're going to be using D so our default higher time frame reference is going to be the daily chart you can change this to whatever you like you could change it to W for weekly or even M for monthly but I'm going to leave mine is D for daily because that's what most intraday traders will be referencing that's the only input variable we need for this lesson so let's move on to the next line of code so the next thing we're going to do here is create our own custom function now this is going to be a little bit advanced so if you're new to pan script don't freak out this is gonna be a little bit difficult to understand but I'll do my best to explain it in a way that makes sense to both people who are proficient with programming and those who are new to this stuff a function is something like plug you can see this is an inbuilt Pyne script function created by the pine script development team and the tradingview developers but you can also create your own custom functions so say that there's a repetitive complex task you want to keep doing in your scripts that pine script doesn't provide an inbuilt function for well you can just create your own and today I'm going to show you exactly how to do that we're going to create our own security function that eliminates repainting and the first thing we need to do just like any variable in pine script we need to define what the variable is called so in this case I'm going to call it RP short for repaint underscore function so this is our repaint function or in should be called NRP non repainting function but I'll keep it RP for short because it's just easier to to write and this RP function unlike a typical variable which is assigned a value based on a inbuilt pan script function or operation this function actually requires input variables so the input variables were going to reference here is the symbol the current market we're trading and the res resolution the current time frame we're trading and also source so our open high/low or closed so now we've defined and our custom function and we've defined what inputs it takes now we need to assign it to an expression basically we need to tell pine script what this function does and the way we do that is using an equal sign just like when we're assigning a variable to a value but instead of just leaving the equal sign we're also going to put a right arrow on the end so this is saying the repaint function with these inputs is defined by this next line of code and so what we're going to reference here is we're going to reference the inbuilt security function so our custom function is going to return the inbuilt security function while taking our custom inputs into consideration and so the way we do that is will write underscore symbol underscore R as an underscore source and so now we can hit save and this will compile and it's still plotting the closing press but our function is created and right now this is just duplicating the security function it's returning exactly what this would do if we were to say if we were to use this inbuilt security function with the default values so I'm gonna leave this for now and we'll come back to it in a second first of all we're going to get our price data in this case it's higher time frame price data and what we want to get is the higher time frame high and the higher time frame low and so higher time frame high is going to be assigned to our custom repaint function and for the market the symbol is going to take our current symbol Aussie CAD so we're gonna write in sin in fur dot ticker or ticket ID sorry ticket ID so that's the ticket identification tag in this case AUD C ad it's going to take res which is this variable here we created so we can change our time frame value so by default it's going to take a daily time frame input and the source is going to be the high so the high time frame low is going to be exactly the same repaint that takes an input of symbol info ticker ID our custom resolution variable which is set to daily by default and it's going to reference the low source the source for this custom function input is going to be low so high and low high timeframe high high time frame low so now we can draw these values to our chart so let's overwrite this clothes value with a higher time frame high we're going to color it red and we're going to title at higher time frame high then we're also going to plot the high time frame low it's going to have a color of blue and it's going to be titled higher timeframe low if I hit save that should draw these values to our chart and there we go but notice it's repainting every time the current intraday bar changes its value so does the higher time frame high and low we don't want that we want to eliminate that so that this high previous day is high continues drawing until the current days bar closes so how do we do that let's come back up to our custom function this is why we created this custom repaint function now if we add on to the end of source two square brackets and the conditional statement then we can eliminate repainting altogether so our conditional statement is going to be if the bar state dot control space is real time question mark one otherwise zero what this is saying is if the current daily bar higher time frame bar is real time meaning it hasn't closed yet it's not a historical bar then we want to reference the previous day's source high low close open otherwise if this bar is not real time meaning it is a historical bar then we do want a reference that days high low and now you can see that repainting has gone away as the intraday bar changes its value the high and low is no longer changing with it and so we've just eliminated repainting we're drawing the previous day's high and low to our chart and if we go out to the daily chart we zoom right in as this daily chart bar is moving the high and low is not moving when this daily bar closes these lines will adjust for today's closing prices high and low and those lines will draw over tomorrow's intraday price action and so there we have our completed indicator it's not repainting it's drawing the high and low the previous day's the higher time frames bar and we can adjust this to what every one we can change this to one week and it will now draw the previous week's high and low and so if price action gets down here there's a good chance it could act as support and so that brings me to the end of today's lesson I hope that this was helpful to you hope that it made sense to you if not go back and watch the previous lessons that may make this lesson make more sense if you haven't watched them yet otherwise if you want to take your pants trip coding to the next level I've left a link in the description to my advanced pine script cost and I'm working on where I go into far more structured detail about all of these different functions of pine script and how they all come together to create a indicator or strategy script so if you're excited about buying scripts and you'd like to take your coding to the next level I highly encourage you to check that one out and I should quickly mention that anyone who signs up to my mailing list to be informed of when the Advanced Course releases will receive a 50% discount off the opening price so if you're interested in that head over now to my website the link is in the description and sign up to be notified about the course release otherwise I'll be back soon with their new free pine script tutorial where I think I'll probably cover time zones and I'll show you how to plot data within a particular time zone so thank you for watching guys if you have any questions leave them in the comment section below and I'll get back to you as soon as I can otherwise I'm excited to see you guys in the advance pilot script course or on my next free video so I'll speak to you then take it easy everyone goodbye [Music]

Pine Script [OUTDATED V4] Tutorial Lesson 8 Using The Security Function & Higher Timeframe Data

a traders welcome back to another pine script tutorial today's tutorial is going to focus on the security function in order to use higher time frame data so the example I'm going to use today is implementing a higher time frame EMA so what we're going to do is we're going to access the 50 day EMA on these intraday time frames so on this four hour chart when we're finished it will be plotting the 50 day EMA as opposed to the 50 standard EMA so let's get straight into this one it's going to be called less than 8 today because that's what we're up to the first thing we need to do is set the overlaid to true so that this will draw on to our charts the next thing we need to do is get some user input so the first input I'm going to get is the time frame what time frame do we want a reference so this is going to be called EMA time frame it's going to be a type of input dot resolution we're working with resolution here which is which means time time frame and the default value is going to be D for daily chart you could also set this to 1440 which is 1440 minutes 1440 minutes is one day otherwise just use D for short the next input is going to be the EMA length so MA length and a type of integer integer and the default value is going to be 50 typos everywhere today all right the next input is going to be whether or not to color this EMA now this will make more sense later but what basically what this is going to do is if price action is above the EMA the EMA will be colored green and if price action is below the EMA to be colored red this is just something I like to do with my indicators the ones that use emas so red obviously means I'm looking for short trades and green means I'm looking for long trades and so I'll show you how to do that in this tutorial today as well so this will be called color EMA and it'll be a type of input bool boolean and the default value is gonna be true last but not least is going to be our smoothing function now I'll explain this one later when we actually have the EMA plotting to the chart but this is going to also be a boolean input so input title equals smooth type whoops type is input bull and this one is going to be set to true as well I'll save that and we'll move on to the next bit of code which is going to be get actually getting the EMA value itself so I'll call this calculate EMA and we'll begin here by establishing an EI EMA variable so this EMA variable is going to be set to the inbuilt EMA function if you hover your mouse over this it'll tell you what you need to input in order to get a return value and this EMA function takes a source and a length source is high low close that sort of thing length is obviously the period length of the EMA so we want to calculate this EMA based on the closing price and it's going to be a length of Len of our variable we created here so a default of 50 the next thing we need to do is get the higher time frame EMA so we're going to basically plug this liner code into the security function in order to use this to calculate this EMA value based on the daily closing price or whatever time frame you set in your resolution input so we're going to get to email use here and this is gonna be a little bit complicated to explain but I'll do my best basically when you're calculating a higher time something like a higher time frame EMA you've got to remember that if I go down to a one-hour chart for example there's 24 one-hour bars in a day 24 one-hour bars make up one daily bar and so there's gaps between the star of this 24-hour period and the beginning of the next four-hour period there's gonna be gaps in price data on that higher time frame and so what we're going to do in order to compensate that is we're gonna have to EMI values one is going to compensate for that value and the other is not so basically one is going to be a smooth higher time frame EMA value and one is going to be a stepped higher time frame EMA value so this will make a lot more sense when this is drawing to the chart so let's just write the code first and then I'll come back to explaining what's happening so the first EMA value are going to get is the smooth EMA value and we're going to assign this one this variable to the security function and now I'll explain what goes into this one if you hover your mouse over the function name it will tell you what inputs it takes and it outputs whatever it needs to floating-point numbers like price price data integers boolean's color which I believe is candlestick color today we're going to be working with the float because we're going to be calculating an EMA value which is a float because it has decimal point numbers just like price action does because it is a an average of price action values the first input this thing takes this function takes is what's symbol do you want to calculate this data on so you can actually use this to reference other symbols so you could reference and we're on Ozzy CAD here Australian dollar versus Canadian dollar but you could reference the euro dollar or or a stock commodity whatever you feel like so I'm not going to go into detail about that in this tutorial this is just introducing you to the security function but in future tutorials I'll show you how to reference other markets today is market we're just going to reference the current symbol so we need to write in here sim info which is short for symbol info press control space and you get a list of of variables you can you can grab from this basically this this collection of instrument data and so out of this list we want ticket ID and this will give us the Australian cat AUD C ad and I believe it will also get it from the same brokerage so so whatever broker you're on it will get the price action data for the symbol you're on from the same broker which is important obviously because different brokers have different price data and so you want this to be consistent with the symbol you're referencing on your charts so trading view takes care of that all for you just by this little happy little line of code here to reference Bob Ross but the next variable we need to input here is the resolution what time frame are we referencing and we can just reference our time frame important from up here so just type in res sorry I could have taken lots of breaks between writing this out because my neighbors are redoing their lawn and there's someone out there shoveling a whole lot of gravel I don't envy them today that's a harder job than writing code that's for damn sure so the next input variable we need to get we need to plug in to this security function is it's called expression here you can see expression is a third input basically this is any expression any line of code and so we're going to be plugging in this here into into this expression slot or whatever and what this is saying is on the current symbol ticker ID or Z CAD on the current time frame or that are on the reference time frame the daily time frame it's saying tradingview please get us the EMA variable from this information so this will be the daily clothes on the daily chart and we'll be calculating a 50 period EMA with that information but we're not quite done yet we also need to plug in the gaps variable and the look-ahead variable and I'll explain what those do next so the first one is gaps and we're gonna write in here bar merge dot and press control space and that will show us the available variables for bar merch basically if you put bar merge caps on what that will do is remember I said that there's 24 one-hour bars in a day well this will merge the gaps between the start of the day and the start of the next day and basically what that will give us is a an average of the average we're going into EMA inception here and we're calculating a average of the EMA the exponential moving average and merging the gaps between price action so again that'll make more sense when you can see it on the chart so for this one we're just going to write gaps on so we're turning bar merge on emerging the gaps of any price action gaps on the higher time frame we're turning that feature on the next input is an interesting one as well this is the look ahead so if I type bar merge dot control space we have look ahead on or look ahead off basically what look ahead is is that in historical data when you're referencing a higher time frame pine Script obviously has access to the days closing price the current days closing price so right now the day daily chart hasn't closed on this time frame so if you were to turn this to look ahead on it would be referencing the current days closing price and that's how you would run into what's called repainting issues I'll get into that in another lesson because it's a little bit advanced for this stage of this this course but basically in layman's terms what that means is that if you set this to look ahead on throughout historical price action the script will be able to look into the future to see what the day's closing price was before the day would have closed in live action so first of all there's all sorts of reasons why you would want the script to be able to cheat and look ahead but I'm not gonna go into them today I'm just gonna say that for the most part for most scripts that you create it's probably safest to just turn look-ahead off so this script is going to merge any price action gaps between any missing price action gaps and it's going to not look ahead and basically when you turn this off what that means is that instead of on historical data instead of referencing the days closing price and cheating seeing looking ahead to see what the day's closing price was it will simply reference the previous day's closing price instead which in this case for the purposes we're using this higher time for an EMA for is exactly what we want so we'll leave that off and the next step in this tutorial lesson is to create the EMA steped version and then I'll will plot these to the chart and it'll make a lot more sense what these to do so again we're going to reference the security function we're going to do all the same here we're going to reference the same symbol that we're currently on the same higher time frame setting the same EMA expression the only difference on this line of code is that we're going to set Bar merge gaps off and the BOM merge look-ahead is also going to be off so literally the only difference between these two lines of code is that this one has gaps off and now we can plot these two variables to our chart so let's do that here now we don't want to draw both of these EMAS at the same time which is why I have this smooth setting here so whether this is turned on or off we'll determine which one of these EMA is we draw it to the chart so this is going to be a little bit of a messy line of code but I'll explain it as we go first thing we're going to use is what's called a conditional operator if you're not sure what this is just go back and go through my previous lessons where I explain in detail how this works but this is like an if if or else statement so we're going to say if smoothing is on if this smooth bullying is set to true in the settings menu then we want to draw the EMA smooth otherwise if this is set to false we want to draw the EMA step value then comma for that the next function setting for this this plot function is going to be the color what color are we going to draw this EMA at and that's where this color variable boolean comes into play or you want to say if we're coloring this EMA then we want it to be green if the current closing price on this time frame is above our higher time frame I'm gonna use EMA step for this and I'm not gonna explain why but that'll make more sense if you if you go over this lesson a couple times and you and you really think about what these two lines of code do but anyway here we're going to stack two conditional operators on top of each other so we're gonna say if the color variable is turned on this boolean is set to true and the if the closing price is above the higher time frame EMA then we want to set the color to green otherwise if color is set to true and the closing price is not above the EMA higher time frame EMA then we want to set the color to red and then we'll draw another semicolon here otherwise we're just going to paint it black as the rolling stones would say I'll just go over this one more time because the nodes would be confusing to look at but what it's saying is if the color variable is set to true if the user has set this boolean to true this check box is ticked and the closing price is currently above the higher time frame EMA then we want to set the EMA color to green otherwise if it's the closing prices below the EMA or equal to it then we want to set it to red and if this color variable input variable is not set to true meaning the check box is not ticked then we're just going to paint it a solid black color and that's it for this section now we're just going to set the line width to two so that it's just a little bit thicker I feel that that works better on EMAS especially a higher time frame EMA and we're going to title this plot function so that our users can go into the settings menu and change these colors if they want to so I'm going to say EMA in brackets hiya time frame and that's it for this script basically we can hit save and add to chart hopefully there's no errors doesn't look like it add to chart and there we have it it's now plotting to the chart but because we're so zoomed in on this one hour time frame we can't see it so zoom out a little bit let's go up to the 4-hour chart and here we have the higher time frame EMA 50-day EMA being drawn to our 4-hour chart but we do have smoothing turned on so if we come up to here and we turn smooth off now we have our stepped 50-day EMA and so I'll just quickly explain this stepped EMA again now that we can see it on our chart and that'll be the end of this lesson so we go down the one-hour chart zoom out a bit if I count the amount of bars between each step you'll see that it adds up to 24 so during this whole day of price action the EMA was one solid value and this was the previous day's 50 EMA value based on the closing price and this is exactly what we want if you're going to use this information to trade off this is what you want on your chart and now this script isn't quite perfect if I am if you look up here you can see that it's it is actually repainting it's still repainting even though we set look ahead to off I'm not going to go over how to fix that in this in this lesson because it's it's quite a detailed process and the lessons already long enough but this is the gist of what you would need to do in order to achieve working with higher time frame data using the security function in future lessons we'll do other things like drawing the higher time frame high or low but that sort of thing but this is a great introduction to the security function and what all the variables do and so yeah this if we turn this to smooth if we turn the smooth function on you can see that it's merging the gaps and so we're not getting that stepped effect but but this is an inaccurate 50-day EMA reading looks a lot better looks cleaner on your chart and it could be useful for things like just performing general technical analysis on your charts but if you wanted to use these levels to trade off it would be much better to have this depth version on so that during this day you are referencing the previous previous days 50 EMA value instead of the current days 50 EMA value which really we won't know until the end of the trading session and that and the current daily chart closes so yeah that's it for this lesson I hope that made sense if not leave a question in the comment section and I'll get back to you as soon as I can if you found this lesson helpful please subscribe to the channel that there's a lot of motivation to continue making these videos and I'm glad to be able to help you guys learn this new skill and just before I leave I just wanted to let you guys know that there is a lot that goes into creating complex and practical useful Pyne script scripts and indicators and so I'm considering creating a very in-depth advanced plan script course for you guys going into detail maybe going over how I create my own indicators my own complex indicators such as my ultimate pull back indicator which I actually used to trade the live markets forex markets and this is painting pull back signals to the charts so you can see it's it sends me an alert telling me when to go long or short tells me my stop-loss my target placement and you can see it's had a couple of winning trades here I'm considering teaching you guys exactly how I made this sort of indicator the catch is this information is quite valuable it took me a long time many many many hours of work to get something like this working and I don't really feel comfortable giving away all of my secrets for free so I'm considering creating a premium pine script course where I'll go into much more detail about how to practically apply all of this information and I'll make it affordable when it is finished and by the end of it you will be able to create your own strategy scripts your own indicators and tools to aid in your own trading and so over the next few maybe months I'm going to be working on that and building that and making that as great as I possibly can and I'll let you guys know when it's ready and for those of you who really want to take this to the next level that'll be a great resource for you guys to really enhance your edge and in that course I may even include a mentorship option where you can get one-on-one access with me and ask me questions and I'll help you to create your own scripts because right now I'm getting a lot of questions from traders and coders and I just I really don't have the time to help everyone and so I'd love to offer a service where I can help you guys but obviously with the amount of time I spend on my own trading and content creation I just don't have the time to do that for everyone so I'll have to find a way to prioritize that and maybe the core students can get that priority and so if you're interested in that I'll leave a link in the video description to sign up to my PI inscript mailing list and anyone who signs up before the course is released I'll send out an email to you when it is released and I'll give you a significant discount on the opening price for supporting me and for pursuing success and being proactive about your trading because I respect that and I will reward that where I can so we'll speak to you guys in the next lesson good luck with your trading best of luck with your coding keep at it I know this stuff can be confusing and it takes time to learn but it's extremely extremely valuable information to master and once you do you will be able to take your trading to the next level completely and possibly even automate your strategies that'll be another thing I'll cover in the paid course how to use third-party api's to automate strategy scripts so take it easy everybody I've enjoyed this time with you I hope you did too and I'll see you in the next lesson good bye [Music]

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...