How to make a TRAILING STOP in Pine Script

  Рет қаралды 5,596

The Art of Trading

The Art of Trading

Күн бұрын

🚩 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 ай бұрын
🚩 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 22 күн бұрын
Great, Sir.
@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.
@GreenStickStrategies
@GreenStickStrategies 2 ай бұрын
Love videos that go back to basics. Thanks. Greetings from South America.
@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?
@idrisifelana974
@idrisifelana974 2 ай бұрын
This is a nice stuff, how can I get the mql4 ver. of it.?
@AlxTSLA
@AlxTSLA 2 ай бұрын
Hey, can you show an indicator for the COT data’s? Or a kind of forecast indicator?
@stupidbitcoin
@stupidbitcoin 2 ай бұрын
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.
How to detect PULLBACKS in Pine Script
22:52
The Art of Trading
Рет қаралды 10 М.
Pine Script: A two-target MACD Strategy
1:05:17
The Art of Trading
Рет қаралды 31 М.
Пробую самое сладкое вещество во Вселенной
00:41
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 33 МЛН
ROCK PAPER SCISSOR! (55 MLN SUBS!) feat @PANDAGIRLOFFICIAL #shorts
00:31
Understanding & ELIMINATING REPAINTING in Pine Script
27:43
The Art of Trading
Рет қаралды 27 М.
How to code a TRAILING STOP LOSS in Pine Script
26:51
The Art of Trading
Рет қаралды 31 М.
RealTest: Why it's amazing
18:37
The Art of Trading
Рет қаралды 4,9 М.
A Simple Moving Average Cross Strategy (& how to use valuewhen)
19:11
The Art of Trading
Рет қаралды 12 М.
2H2024 Market Outlook Summit
1:19:21
Oak Harvest Financial Group
Рет қаралды 68
ChatGPT inside your Pine Script EDITOR!
13:23
The Art of Trading
Рет қаралды 14 М.
RealTest Installation & Setup Guide for 2024
33:33
The Art of Trading
Рет қаралды 1,8 М.
How to AUTOMATE a Pine Script STRATEGY 🤖 AutoView Guide (PART 6/8) [PSv4]
47:30
Do This Before Work Everyday to Make Easy Money ($250/Day)
13:21
Riley Coleman
Рет қаралды 672 М.
The ONLY Candlestick Pattern You'll EVER Need (Full Training)
55:11
Ross Cameron - Warrior Trading
Рет қаралды 375 М.
Пробую самое сладкое вещество во Вселенной
00:41