Editor’s Note:
Hey everyone! I’ve been trying to think of the best way to reach all of you in our community, and since not everyone is in our private Discord group, I thought it would be great to start an infrequent newsletter. I’m not sure what it will look like yet, but I do know I want it to be valuable for all who receive it. So here’s the first edition of the Pine Script Pulse!
Featured Indicator/Strategy:
Flag Finder – By Amphibiantrading
This indicator is a well-documented open-source tool designed to identify bull and bear flag patterns. It’s pretty cool if you are into pattern trading. Especially when it comes to looking for flags, which for me are a powerful indicator of price movement. This indicator contains clear alertconditions that are ready to be converted into signals to be used for backtesting.
Pine Script Tips and Tricks:
Tip 1: When calling any tuple function you can use __
as a placeholder for variable names you don’t intend on using.[_, _, macdHist] = ta.macd(close, 12, 26, 9)
Tip 2: Never worry about repainting again when using the security function by using this functionf_security(_ticker_, _res, _src) => request.security(_ticker_, _res, _src[1], lookahead = barmerge.lookahead_on)
Tip 3: Speed up the efficiency of your Code by avoiding string concatenations. Instead of string1 + string2
use str.format({0}{1}, 'string1', 'string2')
TradingView Platform Updates:
New Strategy Variable: strategy.margin_liquidation_price
returns the price point where a simulated margin call will occur and liquidate enough of the position to meet the margin requirements.
Note: You must have margin requirements set in your strategy for this to work.
//@version=5
strategy("Margin call management", overlay = true, margin_long = 25, margin_short = 25,
default_qty_type = strategy.percent_of_equity, default_qty_value = 395)
float maFast = ta.sma(close, 14)
float maSlow = ta.sma(close, 28)
if ta.crossover(maFast, maSlow)
strategy.entry("Long", strategy.long)
if ta.crossunder(maFast, maSlow)
strategy.entry("Short", strategy.short)
changePercent(v1, v2) =>
float result = (v1 - v2) * 100 / math.abs(v2)
// exit when we're 10% away from a margin call, to prevent it.
if math.abs(changePercent(close, strategy.margin_liquidation_price)) <= 10
strategy.close("Long")
strategy.close("Short")
Enhanced Symbol Info: Access sector, industry, and country details with new syminfo.* variables.
if barstate.islast
message = str.format('Sector:{0}\nCountry:{1}\nIndustry:{2}', syminfo.sector, syminfo.country, syminfo.industry)
label.new(bar_index, high, message)
Order Fill Alert Control: Use the disable_alert parameter to manage order fill alerts in various functions.
i_entryAlert = input.bool(false, 'Use Entry Alerts')
strategy.entry('GoLong', strategy.long, disable_alert = i_entryAlert)
Indicator on Indicator Enhancement: Improved “Indicator on indicator” feature now supports multiple inputs.
Now we can use more than one external input in the strategy optimizer!
New Array Functions: Utilize new array functions like array.first() and array.last() for enhanced scripting.
A = array.from(1,2,3,4,5,6)
// Instead of
A.get(0)
// We can use
A.first()
// Instead of
A.get(A.size())
// We can use
A.last()
Better Backtesting With Heiken Ashi: A new fill_orders_on_standard_ohlc
parameter for the strategy()
declaration statement allows strategies running on Heikin Ashi charts to fill orders using the market’s OHLC values instead of HA prices. The setting can also be changed in the “Properties” tab.
Interactive Scripts Got Better: Now instead of having to remove and add the indicator to the chart again to choosing interactive points, you can simply reset the points using “Reset Points” button under the “More ” menu on your scripts. Try it out!
PineScriptStrategy Updates:
We finally released the “Practical Pine Script Crash Course”!
In this comprehensive and hands-on course, you’ll dive into the world of algorithmic trading. Whether you’re a beginner or an experienced trader, this course is designed to empower you with essential skills to quickly and confidently develop and automate your trading strategies on a live exchange
Course Highlights:
- Master Pine Script Syntax, Variables, Loops, Functions, and Debugging.
- Explore Practical Concepts: Technical Analysis, Multi-Time Frame Analysis, String Manipulation, Real-Time Indicators, Economic Data Analysis, and more.
- Excel in Practical Backtesting: Convert Indicators to Strategies, Optimize Entries, Risk Management, Performance Analysis, and more.
- Achieve Practical Automation: Set Alerts, Generate Scanners, Automate Strategies, and more using Pine Script.
Upon completion of the course, you’ll also gain exclusive access to PSStrategyX – a powerful tool to further enhance your trading strategies.
If you have any questions or need assistance, feel free to reply to this email. We’re here to help you succeed!
Other notable updates
- We Removed the forum from pinescriptstrategy.com It was antiquated and nobody really used it. Now the website is much faster! Discord and support tickets are the way to go for questions and answers.
- We also upgraded the Discord server to Nitro, now we can post sweet memes and emojis. 🦄
- Strategy Optimizer was updated! We added a feature for reversals on opposite signal.
- PSStrategyX has been updated fixing several bugs reported from our community. Thank you!
Community Showcase:
Reach out to be featured here in the next update!
Technical Analysis Insights:
BTCUSD:
We are roughly 248 days from the next Bitcoin Halving. Historically price has always increased up until and 1 year after this date. This is easily one the best trades to be making. It really doesn’t matter where you get in, as long as you are getting in! However, if you are looking for a targeted entry, you can try grabbing it around $26000. I’m anticipating possibly a move up, followed by a larger correction down to 26k area. Set your buy limits accordingly.
Upcoming Webinars/Workshops:
Im thinking of doing a livestream in the discord or on youtube. Will cover some coding and let you guys pick my brain. Let me know if you are interested by RSVP here!
Resources and References:
Pine Script Documentation
Pine Coders
Free Pine Script Facebook Group
Awesome Pine Script Repo
Stay tuned for more Pine Script insights in our next edition. Happy coding!
Best regards,
Paul D. Mendes
Pine Script Pulse Newsletter