Pine Script [OUTDATED V4] Tutorial | Lesson 7 | How To Use ATR Trailing Stop Loss

Поделиться
HTML-код
  • Опубликовано: 16 дек 2024

Комментарии • 117

  • @faenorsjewel5618
    @faenorsjewel5618 4 года назад +15

    Another really amazing lesson.
    Very well explained, so as a noob I'm having no issue following what you are saying.
    Seriously Matt, thank you very much for your efforts!

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад +2

      You're welcome my friend! I'm glad you're enjoying the lessons :) plenty more on the way!

    • @faenorsjewel5618
      @faenorsjewel5618 4 года назад

      @@TheArtOfTrading :) I'm looking forward to them almost as much as I am looking forward to having a keyboard with 2 working shift keys....gods I can't wait to have 2 working shift keys again :P

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад +1

      ​@@faenorsjewel5618 hahaha yeah I feel you! I spilled a drink all over my keyboard last night while I was doing some editing and now mine is playing up too 🙁

  • @johnmoran5667
    @johnmoran5667 4 года назад +5

    i very rarely comment on anything but this is is a truly OUTSTANDING introduction, understands you have to walk before running
    Only suggestion is when starting a script put a few blank lines at end and type above these...in the middle of the text pane... so that when people pause the RUclips progress/volume bar is not in the way

    • @johnmoran5667
      @johnmoran5667 4 года назад

      Which reminds me I should log on and complete the course

  • @pranjalchaubey
    @pranjalchaubey 4 года назад +2

    Your videos are nothing less than phenomenal......you deserve more subscribers and more views!

  • @muhammadsyrian9186
    @muhammadsyrian9186 3 года назад

    The best way for teaching is to build more complex ideas on a simpler one, step by step, thank you.

  • @jamesoneill6778
    @jamesoneill6778 3 года назад +2

    Really good. Just like my C++ instructor you remind me of him so much. Love that you give uses for the code when you explain it. Really help me have a basis for creating my own scripts.

  • @RKCHUX
    @RKCHUX 3 года назад

    Hi Matthew! First of all want to really thank u for your vids. They are amazing and u r an awesome tutor! For someone with zero coding experience (and frankly dislike/fear), u have made the videos and lessons surprisingly well-taught and enjoyable. have loved each one of your lessons so far and am sure gonna enjoy the others as well equally.

  • @dalmarjosesantos
    @dalmarjosesantos 4 года назад +2

    Very well explained, stop loss and take profit are a very important indicator, thank you very much.

  • @obwanda9113
    @obwanda9113 2 года назад +1

    Hey Matt, I searched all over for a tutorial on writing a Trailing Stoploss based on price reached. All I could find including in your channel is ATR or Percentage based Trailing Stoploss. My script takes Inputs of Pips for Stoploss and RR for Profit. I would like to move my Stoploss to Breakeven when a trade reaches 1.5R Profit and then move it to 1R when a trade reaches 2R Profit. Simple and Fixed values.

  • @BilalAhmed-um1um
    @BilalAhmed-um1um 3 года назад

    even for a experienced coder, this is awesome save me a lot of time and some trading tips as well go along

  • @tyrelex7867
    @tyrelex7867 3 года назад

    Amazing lessons , great tutorial.

  • @joshibc73
    @joshibc73 4 года назад

    Awesome. So much easy to understand. I'm at 7 th lesson. Looking for strategy based learning. Hope it will come ahead.
    Thanks for your efforts and hardwork.

  • @christopherbakowski4826
    @christopherbakowski4826 4 года назад

    You're lessons are the clearest i've seen. Thank you

  • @andycarr231
    @andycarr231 4 года назад +3

    This stuff is great. Thanks so much for these great videos. I'm already getting a clear idea of how I'm going to master backtesting.

  • @JustMe-ro1be
    @JustMe-ro1be 2 года назад

    Superb! Had to watch several times to make sure I got the maths behind it, but finally got it.
    Really well explained, love that you explain in simple terms bit by bit what each line of code is doing and why. Its key to learning. Also seeing it explained on the chart as we go, that's great too.
    I think the transparency code is outdated now in v5 (I got an orange message about it at the bottom), so for anyone that may be looking for what seems like the new way? I used this - plot(atr, title="ATR", color=color.new(color.blue, 100))

  • @NathanEarlTallTales
    @NathanEarlTallTales Год назад

    Great Video! You are a wonderful mentor! Keep up the great work!

  • @GlynisDance
    @GlynisDance 2 года назад

    Your lessons are ACE!

  • @xc9112002
    @xc9112002 4 года назад

    Thank you so much
    Its very practical. like some of comments below i rarely left comments but your demonstration is amazing that's easy to understand for everyone. BTW I also love your voice and accent as well as your ending words " trade green and good luck with your coding" Haha

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад

      Thanks so much for the feedback, Eric! I'm glad you've found these tutorials helpful :)

  • @martinmedved9569
    @martinmedved9569 2 года назад

    really great lesson .. Hope you will so more of that. GREAT.

  • @vincenoel897
    @vincenoel897 4 года назад +3

    This stuff is amazing man! Keep it up! Already registered for your course :)

  • @greymodel2739
    @greymodel2739 4 года назад +1

    Thanks for teaching and guiding Us, Great Works!!

  • @potatoshop3541
    @potatoshop3541 3 года назад

    You are my hero~~~!!!!
    Thank you so much for this amazing video really.

  • @Oraclegupta
    @Oraclegupta 4 года назад +1

    Thanks for wonderful tutorial please continue good work n spread knowledge

  • @tsippiweininger8331
    @tsippiweininger8331 3 года назад

    Great lessons , great explained so i say thank u all the way from ISRAEL

  • @ganeshsuralkar3947
    @ganeshsuralkar3947 2 года назад

    thank yoiu very much for freely learning us.

  • @Juroska1
    @Juroska1 4 года назад +1

    Excellent course

  • @freddamelia4550
    @freddamelia4550 4 года назад

    Thank you for these fantastic lessons

  • @alanhill5337
    @alanhill5337 3 года назад

    Another great tutorial. Thank you

  • @jamie0056
    @jamie0056 4 года назад +1

    this is excellent, thank you for creating the videos

  • @eddu4361
    @eddu4361 4 года назад

    Absolutely fabulous! Thx mate. Subscribed immediately! Would even be sper fabulous if you could connect it to automatically adjust your stop-limit order. That would me smashing!

  • @daviecrockett2272
    @daviecrockett2272 4 года назад +1

    cheers, this is great.. I might be able to create my own alerts soon.. excellent..

  • @the_bitcoin_guy
    @the_bitcoin_guy 3 года назад +2

    Thanks for this, great video ! Got a question, when I make a strategy, and set STOP LOSS or TAKE PROFIT, based on ATR, for obvious reasons it never gets hit, because it is dynamic. How can I set a stop Loss or a Take Profit based on ATR or BB, but keep it fixed as a historic value ? Quick example: the Price now is 10.000, and the upper BB value is 10200 and the lower is 9800. I want set a Short trade with STOP LOSS on 10200 and a Take profit at = current price - (stop loss - current price) * 2 . What gives us 9600.

  • @runbama1013
    @runbama1013 2 года назад

    awesome series thank you

  • @majidiranmahbob7448
    @majidiranmahbob7448 3 года назад

    thank you so much this is exactly what i was looking for , keep up the good work

  • @mrrrokas
    @mrrrokas 3 года назад

    Nice one. Much love to you bro

  • @raminbiglari8920
    @raminbiglari8920 3 года назад

    thanks alot man, I appreciate your videos

  • @pietroaminpuddu7388
    @pietroaminpuddu7388 3 года назад +4

    You have not written a code for trailing stop loss (ATR) but you have created a code to calculate a lower and upper band (with a multiplier) starting from the ATR. Good explanation, but the code to contextualize the content with the title is missing.

    • @TheArtOfTrading
      @TheArtOfTrading  3 года назад +2

      The idea behind this indicator is to trail your stop loss based on where you entered your position (eg., if you entered long, then you trail your stop loss higher as the trailing ATR moves higher, and you ignore times when it dips, until you're stopped out. That's how I use it anyway).
      In order to code an actual trailing stop indicator, you need to tell Pine when and where you entered your position, which is much more complex.
      I think you might find this lesson more useful if that's what you're trying to do: ruclips.net/video/WM8qOjKimUk/видео.html

    • @pietroaminpuddu7388
      @pietroaminpuddu7388 3 года назад

      @@TheArtOfTrading I'm happy with the quick response to my comment, I'm glad. Anyway, I don't write the code in Pine but on python so I was just interested in understanding the logic of the code and then rewriting it myself. The point is that the cumulative maximum (or cumulative minimum if short) condition is missing. Of course, as you say then the entry point influences the volatility and therefore the distance of the stop loss from the price series, but all I wanted to say was that this very trivial condition was missing to make it a real trailing stop loss code. Thanks anyway for the explanation in the video which remains exhaustive;)

  • @mohammedrizk3106
    @mohammedrizk3106 Год назад

    Thanks math great work
    Does this work in version 5?
    Or what we should to change in version 5 ?
    And thanks

  • @maasaa7353
    @maasaa7353 4 года назад

    Thank you so much. Truly appreciate your effort. Thanks again.

  • @kclaiborn6257
    @kclaiborn6257 3 года назад

    Thank You for these tutorials! :) :) :)

  • @CsStorms84
    @CsStorms84 2 года назад

    Hello, I love your videos! Is it possible to implement this type of trailing stop into pineconnector?

  • @RudolfEremyan
    @RudolfEremyan 4 года назад

    Absolutely interesting! Thanks a lot

  • @gdshan
    @gdshan 3 года назад

    Nice video. Is it possible to do a presentation on plotting alternate trailing stops for short and long rather than plotting both the lines simultaneously?

  • @marcinmiekisz532
    @marcinmiekisz532 4 года назад +2

    Great course! Thank you for these videos.
    I'm a really no-tech guy, so maybe you could help me. How to use this ATR TP and SL in backtesting the strategy?
    I can't come up with any working code that would set up my exit at either ATR TP or ATR SL when the ATR should be based on a candle that I enter the trade.
    Hope it's understandable :D Do you have any ideas?

    • @johanekman6273
      @johanekman6273 2 года назад

      Hello Marcin. I know it's quite some time ago but did you manage to get the code working for the above mentioned backtesting system? I'm in search for the exact code.

  • @shaddyghazal8255
    @shaddyghazal8255 Год назад

    great, but how to add the ATR to the strategy.exit functions so we can see what the back test results are?

  • @richardforonda2701
    @richardforonda2701 3 года назад

    hey bro question is it possible to used stop Loss moved automatically adjust/moved using PaperTrading ,same as u've done on OANDA Autoview thnx 4 ur time Keep Safe i've enjoy ur Free Lesson Keep it Up i've Learn alot

  • @DevilsAdvocateZT
    @DevilsAdvocateZT 3 года назад

    one thing though, the price will never fall below the stop unless you are looking at the stoploss indicator yesterday. So, how do we move the graph, so we can see it break through?

  • @unbreakable3396
    @unbreakable3396 4 года назад +1

    another question , can we put our stop loss under the entry candle by 2% for example and the target will be the same R/R 1?

  • @garyjon3474
    @garyjon3474 4 года назад

    Is it possible to have write a script that has indicators on the top, such as Moving average and Bollinger Band along with indicators on the bottom such as ADX and TSI? Going off the videos I've seen the overlay function only allows one or the other with the True/False setting.

  • @lisborn2000
    @lisborn2000 2 года назад

    Hey buddy, that's an awesome tutorial. I have been searching for something like this for long time. Just found your channel today and i want to make a personnel request. can you please make a video on how to create an alert on tradingview using short or long trailing stop combined with another indicator into one single code ? For example, an alert when short trailing stop is crossing the 200 EMA in one single code.

  • @evolv_85
    @evolv_85 4 года назад

    This is fantastic.

  • @silencecaptive
    @silencecaptive 3 года назад

    Het Mathew, great stuff as always. one question: on minute 18.00 how do you plot these dashes for stop loss and take profit? I have tried using stepline, yet it still connects the trailing line: plot(longstop, title= "long trail stop", style=plot.style_stepline, color=color.new(color.silver,60))

  • @sumitb2015
    @sumitb2015 3 года назад

    Good video. But here the trailing Stop should be calculated till previous day close. Otherwise we will never have price crossovers as the trailing Stop will always be lower than the current close price..

  • @NM-ki9ih
    @NM-ki9ih 4 года назад

    If I am in a long is there a way to get the trailing stop to find the highest high of that trend regardless if it was 3 bars back, 7 bars back or 50 bars back? Like as long as I'm in a long position, use the highest high you find to calculate the trailing stop with the ATR? I'd like to be able to not get out of obvious trends because of a small pull back.

  • @sorwitkates
    @sorwitkates 3 года назад

    you are the man!

  • @nirmalkumar-rj1ey
    @nirmalkumar-rj1ey 3 года назад

    whats the purpose of bullion. can we plot directly plot(lowest(low,lookback), color=color.green) ...) without using use structure

  • @kefaliask
    @kefaliask 4 года назад +1

    great lessons :up

  • @user-ml2yt9gl4i
    @user-ml2yt9gl4i 4 года назад +1

    have been watching all your tutorials. Could you make a video for algo trading with Tradingview pine script? There are autoview with pink and Algostudio out there that can make pine script automated but do not know how to proceed

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад +1

      Hey Ching! That's on the list, when I finish my Pine Script Mastery Course I'll do a short guide on 3rd party API functionality :)

    • @user-ml2yt9gl4i
      @user-ml2yt9gl4i 4 года назад

      @@TheArtOfTrading something in python?

  • @dstr769
    @dstr769 4 года назад

    the script I am modifying was made in 2017, it seems there is an incompatibility of some sort - when I put in // @version=4
    then it does not get compiled at the end

  • @Berghiker
    @Berghiker Год назад

    How can I change the strategy tester to only show trades for one trading day ?

  • @Hooli31
    @Hooli31 3 года назад

    thank you for the video! Im having struggle to keep the ATR value at the entry price, I would like to take profit at 1.5 * atr of my entry price and not "trailing" how can i do that?

  • @2blackman1
    @2blackman1 3 года назад

    Good lesson man, though for the plot(atr) line 18. Why would we bother changing the transparency to 100? Wouldn't it be simpler to just remove that line entirely?

  • @ajinkyajoshi6995
    @ajinkyajoshi6995 4 года назад +1

    Can we get buy and sell signal like supertrend indicator for any indicator???
    If yes how?

  • @tuzway
    @tuzway 3 года назад

    Awesome video.... I'm checking out your site also. I need to do a pine script for a sma/ema crossover exit strategy.

  • @martinmbome3308
    @martinmbome3308 3 года назад

    what is the lesson that teach how to plot target et stop loss please?

  • @Irshu
    @Irshu 4 года назад

    Thanks a lot for the video guy.
    I have a question, Is there any way we can plot the atr in a new pane while overlay is set to true but still want the trailing stop to be plotted on the price chart?

  • @rk_charts
    @rk_charts 3 года назад

    Really amazing Lesson,
    My self Ravi from INDIA
    Can you please make a lesson on increased Volume's High or Low gone by price, then it give signals
    One more thing can you please make a lesson video on RSI BreakOut Signals, it would be really appreciate, Thank u so much.

  • @promethvzine
    @promethvzine 3 года назад

    damn this helped me out so much! thanks for this! i'm having a lil problem with the auto scale function when i plot this indicator to the screen.
    It wants to show 0 on the BTC chart which makes all my candles squeezed together. any way i can fix this?

    • @promethvzine
      @promethvzine 3 года назад

      i found out the reason is this line:
      plot(atr, color=color.blue, title="ATR", transp=100)

  • @athar7934
    @athar7934 3 года назад

    Hi,
    Really amazing lesson, Very well explained. Can I get codes that you are showing as lesson 1-2-3?
    That will be really helpful ! TIA

  • @sharanrj5008
    @sharanrj5008 4 года назад +1

    lets take stock price is 100 and it has support and resistance at 98 and 102 for the 23-march -2020..
    now this support and Resistance i.e 98 and 102 =x
    how to check this x is equal to previous any same support and Resistance
    suppose previous 98 cames as support two times and now on 23 march this 3 rd time
    when 2nd time or 3rd time occurs on chart as support i want to display it as buy ...how to do it plz ..hlep

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад +1

      Hey Sharan! That's a really complicated thing to achieve in Pine Script. If I get time once I've finished covering the basics I'll try to create a lesson on it

    • @sharanrj5008
      @sharanrj5008 4 года назад +1

      @@TheArtOfTrading k sir ..try to create evrything about pine script it will be very helpful ..and thanks

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад +1

      @@sharanrj5008 Hey Sharan! I'm currently in the process of creating a Pine Script Mastery Course that teaches everything I know about Pine :) hopefully it will be finished really soon. If you want to be notified when it's ready, you can sign up to the mailing list here : zenandtheartoftrading.com/advanced-pine-script-course
      Otherwise when I'm finished creating that course, I will go back to making free tutorial lessons here on RUclips, so stay tuned :)

  • @johnstark9
    @johnstark9 4 года назад

    when toggling between time frames, my chart shrinks in order to fit atr value at very bottom. Only way for smooth toggling between time frames is to disable atr which defeats the point. Any advice you can dish on how to fix this problem? thanks!

  • @YourHubHubGo
    @YourHubHubGo 2 года назад

    any update on this for version 5? thank you in advance.

  • @richannforonda3847
    @richannforonda3847 3 года назад

    hoping u can do a script that can filter on a valid setup using art trailing-stop many tnx looking forward 4 that video

  • @Yourboye2
    @Yourboye2 4 года назад +1

    These lessons are amazing. I did run into a problem. (I copied the code verbatim) but when I add to the chart, it squishes the candles into a solid line. I'm not sure what I did wrong. Thx for any replies :)

    • @Yourboye2
      @Yourboye2 4 года назад

      13:50 found the solution.... :) Thx

  • @studology67
    @studology67 2 года назад

    why did we use usestructure boolean, can we make this indicator without use structure

  • @maximilianoroth1891
    @maximilianoroth1891 4 года назад

    Really amazing thanks!!!

  • @MrJonathanRB
    @MrJonathanRB 4 года назад

    Matt do you have a video to do something like DMI + Stoch are in the same OB/OS?

  • @nivas2807
    @nivas2807 4 года назад

    Can you please help me how to get higher time ATR value on lower time frames charts. Example: I want Daily ATR value same on 5 minutes and 30 minutes charts

  • @Berghiker
    @Berghiker Год назад

    How do I work with more than 2 if statements?

  • @hb7of9
    @hb7of9 4 года назад

    Amazing ty :)

  • @unbreakable3396
    @unbreakable3396 4 года назад +1

    when we can get your crash course about scripting by pine script ?

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад +1

      Hey UnBreakable! Absolutely, I'm working on that right now which is why I've been absent from RUclips. So far I have 3 hours of lessons recorded and I'm only half way through the list of course material to create :) I'll let you know on this channel when it's completed so stay tuned!

  • @ernestkayinamura6668
    @ernestkayinamura6668 3 года назад

    thanks awesome

  • @varunanilpatel310
    @varunanilpatel310 2 года назад

    How to use ATR Trailing stop loss in other live strategy ?

  • @cemaldogan2235
    @cemaldogan2235 3 года назад

    thanks

  • @shariztraderstudio1397
    @shariztraderstudio1397 2 года назад

    hai i have plotsahpe for cci crossover ema, can you show me how to plot below -100 line to zero line. -100

  • @varun7154
    @varun7154 Год назад

    how to merge two or more indicator

  • @masterthebasics4846
    @masterthebasics4846 3 года назад

    looks like trading veiw is removing the 'transp' function , now they recommend using color.new() or color.rgb()

  • @worldwideoffline6423
    @worldwideoffline6423 2 года назад

    I dont understand how this would ever get triggered...? it never crosses the price when done like this..? what am i missing?

  • @24hrdiner
    @24hrdiner Год назад

    But price never triggers the stop, so whats the point?

  • @varun7154
    @varun7154 Год назад

    hii... i want full course

  • @dougamaral85
    @dougamaral85 2 года назад

    Hi, sorry for my bad english... I'm from Brazil and my name is Doug.
    Me and my brother are trying to write a trailing stop loss on Tradingview (pine script) and we're being successful.
    Our idea is to reach a specific profit target and change the stop loss, for example:
    1- When my profit reaches 5% my stop loss will be 0%
    2- When my profit reaches 10% my stop loss will be 5%
    3- When my profit reaches 20% my stop loss will be 10%
    4- Etc... Etc... Etc...
    I don't know if you could understand my idea, but that's what we're trying to do but we're not getting it.
    Could you kindly help us?
    Best regards my friend.

  • @pradeeptv5241
    @pradeeptv5241 4 года назад

    Sir please share a simple script for plot atr and ema in a single indicator window

  • @GK-ll7zo
    @GK-ll7zo 4 года назад +1

    Hi,
    It look good, BUT ! It does not work (I think). Stop losses need to trigger, this one is just adjusting it to go lower. It is not possible to get stopped out, so IMO, useless, unless I am really doing something wrong, please correct me then.

    • @TheArtOfTrading
      @TheArtOfTrading  4 года назад

      Hi Gert! Yes this indicator is intended to be used on each bar. So you identify the bar you want to trail your stop above/below and then use that value. You don't adjust it on every single bar, only swing lows or highs

  • @RealDappyDuck
    @RealDappyDuck 2 года назад

    how do you join this mans discord

  • @aimanaimann
    @aimanaimann 3 года назад

    the atr value isnt the same as ATR built in.

  • @TheLKStar
    @TheLKStar 3 года назад +2

    This is not a trailing stop. It's a fixed stop that you turn on relative to ATR value.