How to make a TRAILING STOP in Pine Script

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 มิ.ย. 2024
  • 🚩 My Socials & More Free Content: theartoftrading.com
    🚩 FREE Pine Script Basics Course: courses.theartoftrading.com/c...
    🚩 Pine Script Mastery Course: courses.theartoftrading.com/c...
    🚩 My Indicators & Strategies Course (Steal My Code!): courses.theartoftrading.com/c...
    🔷 Create your FREE TradingView Account: www.tradingview.com/gopro/?of...
    LESSON SOURCE CODE: courses.theartoftrading.com/p...
    ----------------------------------------------------
    Want to learn Pine Script? Look no further. I have you covered!
    This lesson demonstrates a simple template for creating an ATR-based volatility-adaptive trailing stop in Pine Script.
    With over 16 years of coding experience and 5+ years of profitable trading experience, I specialize in TradingView's Pine Script programming language and I'm here to pass on everything I've learned about both trading and coding.
    MORE RESOURCES:
    🔷 My Blog & Socials: www.theartoftrading.com
    🔷 My Free Indicators: zenandtheartoftrading.com/ind...
    🔷 My Favorite Trading Books: zenandtheartoftrading.com/top...
    🔷 My Favorite Trading Psychology Books: zenandtheartoftrading.com/tra...
    🔷 My Trading Video Library: zenandtheartoftrading.com/vid...
    🎤 The Art of Trading Podcast: thetradingpodcast.com/
    If you want more information about who I am and what I do, head over to zenandtheartoftrading.com/about.
    Educational Content Disclaimer:
    The content provided in our videos, including all code, lessons, and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context. Any results from strategies or tools provided are hypothetical and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and are not suitable for all persons. Before making any trading decisions, please consult with a qualified professional to understand the risks involved. By using our materials, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
    ▼Timestamps▼
    00:00 - Intro & Disclaimer
    00:40 - Lesson Overview
    02:00 - User Inputs & ATR Value
    02:50 - Calculating Stop Loss
    04:05 - Validating Indicator Values
    06:46 - Modifying Strategy Entry Criteria
    08:00 - Updating the Trailing Stop Loss
    12:52 - Drawing Stop Loss
    13:59 - Adjusting Trailing Stop Methods
    15:54 - Learn More About Pine Script!
    #PineScript #TradingView #Trading

ความคิดเห็น • 21

  • @TheArtOfTrading
    @TheArtOfTrading  2 หลายเดือนก่อน +1

    🚩 LESSON SOURCE CODE: courses.theartoftrading.com/pages/atr-trailing-stop-in-pine-script
    🚩 My Socials & More Free Content: theartoftrading.com
    🚩 FREE Pine Script Basics Course: courses.theartoftrading.com/courses/pine-script-basics-course
    🚩 Pine Script Mastery Course: courses.theartoftrading.com/courses/pine-script-mastery
    🚩 My Indicators & Strategies Course (Steal My Code!): courses.theartoftrading.com/courses/my-indicators
    🔷 Create your FREE TradingView Account: www.tradingview.com/gopro/?offer_id=10&aff_id=15271

  • @prakashrasania5637
    @prakashrasania5637 21 วันที่ผ่านมา

    Great, Sir.

  • @GreenStickStrategies
    @GreenStickStrategies 2 หลายเดือนก่อน

    Love videos that go back to basics. Thanks. Greetings from South America.

  • @Gimposai
    @Gimposai 2 หลายเดือนก่อน

    Thank you for this Art of Trading!
    For those who are new to trailing stops (like myself), be careful with super low trailing stop values as it'll give you unrealistic exits (a 1 tick trailing stop will exit you out 1 tick away from the high or low). This is due to simulating intrabar price movement in straight lines. This is from the "Broker Emulator" section of the pine script user manual:
    Since the emulator can only use chart data, it makes assumptions about intrabar price movement. It uses a bar’s open, high, and low prices to infer intrabar activity while calculating order fills with the following logic:
    If the high price is closer to the opening price than the low price, it assumes that the price moved in this order on the bar: open → high → low → close.
    If the low price is closer to the opening price than the high price, it assumes that the price moved in this order on the bar: open → low → high → close.

  • @dub4art
    @dub4art 2 หลายเดือนก่อน

    Can I suggest a topic for next lesson? Handling partials and stop loss in strategies that use strategy.entry to reverse the trade. In other words when trading condition changes from Sell to Buy (and vice versa) the strategy doesn't exit the trade (although there are some cases when it might, eg. during low or very high volatility conditions) but rather flips the trade in opposite direction. I found coding reliable SL and TPs very challenging in these circumstances.

  • @thomasreinhardt3626
    @thomasreinhardt3626 2 หลายเดือนก่อน

    I remember you had this atr trailing stop already a year ago.
    And in not moving markets, one can forget it.

  • @Whiterabbitz42
    @Whiterabbitz42 หลายเดือนก่อน

    Great info as usual..
    Thanks so much for sharing tyour info.
    Have been thinking about an exit strategy for any long entry written in pinescript.. so I came to the master.
    Setup
    input stop loss and profit taker % via input, set up max lots via input , setup max drawdown via input.
    1) Enter trade under some condition ie macd cross up etc...
    2) Set trail stop loss and profit taker
    3)if stop loss hit close
    4) if profit taker hit then don't close but make another buy and adjust stop loss and profit taker for the whole position.
    5) rinse and repeat until stop loss is hit.
    The numbers for this strategy are very interesting , maybe set max drawdown or max number of positions.

  • @greekboydinos
    @greekboydinos 2 หลายเดือนก่อน

    amazing. i’ve been waiting for this for years

  • @bhupendraghanghoriya7263
    @bhupendraghanghoriya7263 2 หลายเดือนก่อน

    You are awesome! Thanks for all the knowledge you are giving free of cost without having any hidden agenda. Thanks Mate!

  • @Matt_Pallardy
    @Matt_Pallardy หลายเดือนก่อน

    This is amazing, thank you! Do you have a video explaining how to use multiple potential exits? For example, I want to set a stop loss when I open the trade and then once I reach a certain level of profit, I want a trailing stop to kick in. Thank you again!

  • @Acosta360
    @Acosta360 2 หลายเดือนก่อน

    I gave up trying to get my trailing stop loss to work but I got it to work now. Thanks!

  • @calvinlm88
    @calvinlm88 2 หลายเดือนก่อน

    Hi, your previous videos on Real Test are captivating. Nice if you can talk more on those applications. Cheers

  • @roystoncartwright5640
    @roystoncartwright5640 2 หลายเดือนก่อน

    thank you 😊

  • @cakeprofits7589
    @cakeprofits7589 2 หลายเดือนก่อน

    Dude, you are the best

  • @only_trades
    @only_trades หลายเดือนก่อน

    Hi there is it possible to create predetermined stop orders for both entry and exit strategies. This would mean that positions can be opened 'intrabar' as opposed to 'on candle close', creating a more dynamic entry system. The stop order would be the trigger for entry and after each candle close the stop order would be recalculated if an entry was not triggered. Similarly for exit positions, where stops are triggered as soon as price crosses threshold. I dont know if pinescript can do this?

  • @dumbcat
    @dumbcat หลายเดือนก่อน

    curious how your script managed to exit intra-bar when you did not tell it to do anything special. i've had trouble trying to get intra-bar exits. i don't see anything in your code that suggests the exit should happen immediately. thanks

  • @ezrakoper
    @ezrakoper 2 หลายเดือนก่อน

    Hi Matt. When using the some parts of your code, I was interested in to add a label with the trailing stop hit price and time when it occurred. So on bar close after calculating the trailing stop exit price (long only), I was checking if the close price is lower then the ATR I calculated. And if so, add a label and a log message. To my surprise I never get the log and nether the label. On the next line comes the ATR trailing stop that will cause the trade to exit. And this do happen.
    So my question is - do you have any idea why the log message and label are not executed?

  • @AlxTSLA
    @AlxTSLA 2 หลายเดือนก่อน

    Hey, can you show an indicator for the COT data’s? Or a kind of forecast indicator?

  • @idrisifelana974
    @idrisifelana974 2 หลายเดือนก่อน

    This is a nice stuff, how can I get the mql4 ver. of it.?

  • @stupidbitcoin
    @stupidbitcoin 2 หลายเดือนก่อน +1

    Would you do a video on all the "technical" requirements Pine Script code has to meet to be published? These rules are more trouble than coding. 4 months of work and the first 15 scripts banned instantly. RUTHLESS.