Markdown: The Pine Editor's Hidden Gem💬 Markdown, a markup language
Markdown is a portable, lightweight markup language that can be used for everything whether you're building a website, documentation, or even presentations.
Platforms like Discord, Reddit, and GitHub support Markdown and is the widely go-to option for text formatting due to its simplicity. Pine Script is a language that also utilizes Markdown, specifically in the Pine Editor where it can really be used to some extent.
Since the release of libraries, user-defined types, and methods, Pine Script is entering an age where developers will be highly dependent on libraries due to the capabilities Pine has inherited recently. It would be no surprise if a few people got together and took their time to thoroughly develop an entire project/library centered around improving Pine Script's built-in functions and providing developers with easier ways of achieving things than they thought they could.
As you're all aware, hovering over functions (and more) in the editor pops up a prompt that specifies the parameters, types, and what the function returns. Pine Script uses Markdown for that, so I figured we could go ahead and push that feature to its limits and see what we can do.
Today we'll go over how we can utilize Markdown in Pine Script, and how you can make your library's built-in functions stand out more than they did previously.
For more information, visit www.markdownguide.org
📕 General Notes
Markdown syntax only works on functions and methods.
Using arrays as parameters as of 2/21/2023 breaks the Markdown system.
The prompt window holds a max of 166 characters on one line before overflowing.
There is no limit on how long the prompt window can be.
🔽 Getting Started 🔽
▶️ Headings
If you have experience in HTML, Markdown, or even Microsoft Word then you already have a grasp of how headings work and look.
To simplify it, headings make the given text either massive or tiny depending on how many number symbols are provided.
When defining headings, you must have a space between the number (#) symbol, and the text. This is typical syntax throughout the language.
Pine Script uses bold text by applying (**) for their titles on their built-ins (e.g. @returns) but you could also use heading level 4 (####) and have it look the same.
▶️ Paragraphs & Line Breaks
You may want to provide extensive details and examples relating to one function, in this case, you could create line breaks. Creating line breaks skips to the next line so you can keep things organized as a result.
To achieve a valid line break and create a new paragraph, you must end the line with two or more spaces.
If you want to have an empty line in between, apply a backslash (\).
Backslashes (\) are generally not recommended for every line break. In this case, I only recommend using them for empty lines.
▶️ Text Formatting
Markdown provides text formatting such as bold, italics, and strikethrough.
For bolding text, you can apply open and close (**) or (__).
For italicizing text, you can apply open and close (*) or (_).
For bolding and italicizing text, you can apply open and close (***) or (___).
For s̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶, you need to apply open and close (~~).
This was mentioned in the Headers section, but Pine Script's main titles (e.g. @returns or @syntax) use bold (**) by default.
▶️ Blockquotes
Blockquotes in Pine Script can be visualized as a built-in indentation system.
They are declared using greater than (>) and everything will be auto-aligned and indented until closed.
By convention you generally want to include the greater than (>) on every line that's included in the block quote. Even when not needed.
If you would like to indent even more (nested blockquotes), you can apply multiple greater than symbols (>). For example, (>>)
Blockquotes can be closed by ending the next line with only one greater than (>) symbol, or by using a horizontal rule.
▶️ Horizontal Rules
Horizontal rules in Pine Script are what you see at the very top of the prompt in built-ins.
When hovering, you can see the top of the prompt provides a line, and we can actually reproduce these lines.
These are extremely useful for separating information into their own parts and are accessed by applying 3 underscores (___), or 3 asterisks (***).
Horizontal rules were mentioned above, when we were discussing block quotes. These can also be used to close blockquotes as well.
Horizontal rules require a minimum of 3 underscores (___) or 3 asterisks (***).
▶️ Lists
Lists give us a way to structure data in a somewhat neat way. There are multiple ways to start a list, such as
1. First Item (number followed by a period)
- First Item (dash)
+ First Item (plus sign)
* First Item (asterisk)
Using number-based lists provide an ordered list, whereas using (-), (+), or (*) will provide an unordered list (bullet points).
If you want to begin an unordered list with a number that ends with a period, you must use an escape sequence (\) after the number.
Standard indentation (tab-width) list detection isn't supported, so to nest lists you have to use blockquotes (>) which may not look as appealing.
▶️ Code Blocks
Using code blocks allows you to write actual Pine Script code inside the prompt.
It's a game changer that can potentially help people understand how to execute functions quickly.
To use code blocks, apply three 3 open and close backquotes (```). Built-in's use (```pine) but there's no difference when we apply it.
Considering that tab-width indentation isn't detected properly, we can make use of the blockquotes mentioned above.
▶️ Denotation
Denoting can also be seen as highlighting a background layer behind text. They're basically code blocks, but without the "block".
Similar to how code blocks work, we apply one backquote open and close (`).
Make sure to only use this on important keywords. There really isn't a conventional way of applying this.
It's up to you to decide what people should have their eyes tracked onto when they hover over your functions.
If needed, look at how Pine Script's built-in variables and functions utilize this.
▶️ Tables
Tables are possible in Markdown, although they may look a bit different in the Pine Editor.
They are made by separating text with vertical bars (|).
The headers are detected when there is a minimum of one hyphen (-) below them.
You can align text by using a colon as I do in the photo. Hyphens must be connected to the colon in order to display correctly.
Tables aren't ideal to use in the editor but are there if anyone wants to give it a go.
▶️ Links & Images
Markdown supports images and hyperlinks, which means we can also do that here in the Pine Editor. Cool right?
If you want to create a hyperlink, surround the displayed text in open and close brackets .
If you want to load a photo into your prompt, it's the same syntax as the hyperlink, except it uses a (!)
See syntax list below.
Here are realistic usage examples. (Snippets from code below)
These follow the same syntax as the built-ins.
I'm not using horizontal rules here, but it's entirely up to you.
▶️ Syntax List
Headings
Level 1: #
Level 2: ##
Level 3: ###
Level 4: ####
Level 5: #####
Level 6: ######
Line Breaks
Text (two spaces)
Text\ (backslash)
Text Formatting
Bold (**)
Italic (**)
Strikethrough (~~)
Blockquotes
Indent (>)
Double Indent (>>)
Triple Indent (>>>) and so on.
Horizontal Rules
(___) or (***)
Lists
Ordered List (1.)
Unordered List (-) or (+) or (*)
Code Blocks
(```) or (```pine)
Denotation
(`)
Tables
(|) and (-) and (:)
Hyperlinks
(URL)
Images
! (URL)
Hope this helps. 👍
Cerca negli script per "track"
Odd_Custom Candle Calendar DayEver wonder how candles would look on a chart if they were tracked by calendar day instead of market days?
Option(s)-
📅Custom start date for candle formation
✖️Candle multiplier
🌈Up / Down Colors
Features-
📋Displays candle data with invisible plots
Use Move to Existing Pane to Overlay on chart.
Can only display a max of 500 candles!
Market Crashes/Chart Timeframes HighlightThis extremely helpful indicator allows you to highlight 7 custom date-based timeframes on your charts.
The default dates selected are what I consider to be the most significant 7 most recent market declines, including and since the 87 flash crash.
Note: The default dates are approximate but good enough to highlight the key timeframes of these pullbacks/crashes/corrections.
It's simple to use and does exactly what it should.
I created this indicator to make it easier when looking at the overall story of a chart. I found it helpful to highlight these areas to see how a market or equity has responded during these significant market pullbacks.
The highlight alone I’ve found helpful, and it becomes more powerful if you combine it with your own trusted trade system.
Also, to get the most out of using the default dates it’s important to understand the narrative behind each pullback/crash. Here’s the list of what I consider significant pullbacks:
Black Monday - Oct 87
1990s Recession - Jul 90 to Mar 91
Dot Com Bubble - 2000 to 2002 or so
Real Estate 2008 Crisis - I choose 2007-2009 to cover full insider knowledge and aftermath
2016 - 2018 - This isn't seen as a pullback, but I have it as significant because in many markets and equities, this was an almost equal percentage pullback as 2008. See Notes below
2020 Crash - Covid-19 and related shenanigans pullback
April 2021 to August 2022 - I believe we are in a current SHORT cycle so I've highlighted April 2021 as the start of what might be the start of a major decline testing Dot Com or lower levels.
A few notes on the above.
You'll find on most of the pullbacks listed above most equities and related markets behave similarly or have similar patterns.
The 2016-18 pullback is the most difficult to track. For instance, GE in this timeframe had a -80% decline, whereas BA depending on how you want to measure it had a 50-110% gain.
Line Break Heikin AshiThis script takes two candle styles and combines then into one. By only using the closing price to inform the heikin ashi candles you get a lovely line break style heiken ashi candle. The advantage to this if you are into this kind of thing is that it makes for a smoother experience. You still get wicks just because of the nature of heikin ashi but they are dramatically reduced. This is defiantly an experimental indicator as its just a different way to look at the chart. I hope some one can find use in this outside of a work around pine script limitations. I had to create this for my sentiment tracker section of my qqe bb screener because it uses so many symbols that I cant get the open, high, or low for each. If you find any bugs please report them, or if you have any feedback please leave it. Enjoy!
Fibonacci EMA's with Bollinger Bands [Feniks]Many Fibonacci EMAs are calculated and then tracked using custom-colored candlesticks so that your chart remains very clean. This setup is mainly used for scalping on the 2min. Feniks uses gray candlesticks and then all of the custom-colored candlesticks to know when to react to price action.
WARNING: Do your own due diligence and try it out. Also, the script's default colors were determined with the chart's candlesticks being gray for both bullish/bearish candles. You'll probably have to change some of the colors to make use of the script if your chart's candlesticks are not similarly configured.
The main two strategies involve the 13/55 and 21/233.
The 13 EMA (blue) crosses above or below the 55 EMA (green).
- 13/55 Crossover is shown by the triggering candlestick being blue.
- 55/13 Crossunder is shown by the triggering candlestick being orange.
- (Alerts 1/2)
The 21 EMA (red) crosses above or below the 233 EMA (white).
- 21/233 Crossover is shown by the triggering candlestick being green.
- 233/21 Crossunder is shown by the triggering candlestick being red.
- (Alerts 3/4)
Large Candle (With Alert, You have to ENABLE it on chart)You have to enable alert after adding this indicator to a chart.
Right click on chart -> Create Alert -> Select Condition: "Large Candle"; and choose "Any alert() function call"
Alert action such as email, popup, sms etc can be checked -> Create.
Disclaimer: trade on your own risk.
This script adds alert function to the "Large Candle - Tracking Institutional Buy and Sell" which can be found here:
Source code is now open to all
Digital Nivesh: Trend TrackerThis indicator is nothing but combination of Magic Trend and Super trend written by KivancOzbilgic
So credit goes to him.
I have just added some extra functionality which are below:
1. Multi time frame, magic trends time frame can be different from supertrend by changing shortTimeFrame
2. Dynamic time frame, u can change supertrends time also
Best usage is to use Magic Trend on 1 lower time frame than supertrend.
eg. Suppose ur current chart is on 5 min time, ur supertrend will be displayed with current time on chart(which can be changed also using MTF Tradingview feature), u need to keep shorterTimeFrame on lower value such as 3min .
For any question , feel free to drop comment.
München's Momentum WaveMUNICH'S MOMENTUM WAVE:
This momentum tracker has features sampled from Madrid's moving average ribbon but has differentiated many values, parameters, and usage of integers. It is derived using momentum and then creates moving averages and mean lengths to help support the strength of a move in price action, and also has the key mean length that helps determine HL/LH or rejections into trend continuation. This indicator works on ALL TIME FRAMES, ALL ASSET CLASSES ON ALL SETTINGS!!
HOW DO I USE IT?
*First off, I have arranged the input settings into groups based on the parts of the indicator it affects.
*You want to use the aqua/white/yellow (Munich's line) as your leading indicator, this is a combined average of the MoM indicator.
* When using Munich's line you want to look at the relation to the mean line (the flat line that adjusts based on price action. You will often see rejections of this line into trend continuation. I personally have caught perfect LH/HL bounce trades off of this indicator.
* Use the Background and other colored moving averages to help pre-determine moves based on the -3 offset value of Munich's line. This was by design not to create 'accurate' results, but to help predict momentum swings based on sharper moves in price action better than if all values lined up to the current bar.
Cheat Code's Notes:
I hope you guys find this indicator to be useful, this is most likely the best indicator that I have written. Simply for the fact it is useful on any chart, any timeframe with any setting. If you guys have any issues with it, shoot me a pm or drop a comment. Thanks!
-CheatCode1
BINANCE:BTCUSDT BITSTAMP:ETHUSD BITSTAMP:BTCUSD PEPPERSTONE:JPYX TVC:DXY TVC:NDQ AMEX:SPY
Trend Trigger Factor w/ Discontinued Signal Lines [Loxx]Trend Trigger Factor w/ Discontinued Signal Lines is a Trend Trigger Factor indicator with floating boundary lines to identify trends earlier
What is the Trend Trigger Factor?
Designed by M.H. Pee, the Trend Trigger Factors role is to help traders detect uptrends and downtrends and thus allow them to better position themselves in a with-trend manner. Its creator argues that the markets are mostly random but have a small trend component, which is the most crucial part of trading success. Being able to determine whether the market is in a bull or bear trend and how strong that trend is will allow you to be on the right side of the market for longer, capitalizing as much as possible on its trending behavior.
In his article, M.H. Pee used a 15-period trackback span to explain the calculations. The TTF formula is based on the so-called Buy Power and Sell Power. In his example, Pee labeled today as day 1, yesterday as day 2, the preceding day as day 3 and so on
What's new in this indicator?
Averages filter out prices prior to being used in calculation. That way the lag added is smaller than when the smoothing is used on the calculated result.
Unlike the original which uses levels +100 and -100 as significant levels for signal triggering, this version is using discontinued signal lines for trend filtering. That way it makes it a bit more responsive to market conditions
How do I use this?
The Trend Trigger Factor is similar in interpretation to the Relative Strength Index. It is plotted on a scale with most prominent levels at +100 and -100, crosses of which logically signal possible trade entries. The difference here, however, is that the upper and lower boundary flex with price movements so the upper and lower boundary shift dynamically. Crosses above the top line signify bullish sentiment, crossed below the the bottom line signify bearish sentiment.
Short Selling EMA Cross (By Coinrule)BINANCE:AVAXUSDT
This short selling script works best in periods of downtrends and general bearish market conditions, with the ultimate goal to sell as the the price decreases further and buy back before a rebound.
This script can work well on coins you are planning to hodl for long-term and works especially well whilst using an automated bot that can execute your trades for you. It allows you to hedge your investment by allocating a % of your coins to trade with, whilst not risking your entire holding. This mitigates unrealised losses from hodling as it provides additional cash from the profits made. You can then choose to to hodl this cash, or use it to reinvest when the market reaches attractive buying levels.
Entry
The exponential moving average ( EMA ) 20 and EMA 50 have been used for the variables determining the entry to the short. EMAs can operate better than simple moving averages due to the additional weighting placed on the most recent data points, whereas simple moving averages weight all the data the same. This means that price is tracked more closely and the most recent volatile moves can be captured and exploited more efficiently using EMAs.
Our backtesting data revealed that the most profitable timeframe was the 30-minute timeframe, this also enabled a good frequency of trades and high profitability.
A fast (shorter term) exponential moving average , in this strategy the EMA 20, crossing under a slow (longer term) moving average, in this example the EMA 50, signals the price of an asset has started to trend to the downside, as the most recent data signals price is declining compared to earlier data. The entry acts on this principle and executes when the EMA 20 crosses under the EMA 50.
Enter Short: EMA 20 crosses under EMA 50.
Exit
This script utilises a take profit and stop loss for the exit. The take profit is set at -8% and the stop loss is set at +16% from the entry price. This would normally be a poor trade due to the risk:reward equalling 0.5. However, when looking at the backtesting data, the high profitability of the strategy (93.33%) leads to increased confidence and showcases the high probability of success according to historical data.
The take profit (-8%) and the stop loss (+16%) of the strategy are widely placed to ensure the move is captured without being stopped out due to relief rallies. The stop loss also plays a role of mitigating losses and minimising risk of being stuck in a short position once there has been a fundamental trend reversal and the market has become bullish .
Exit Short: -8% price decrease from entry price.
OR
Exit Short: +16% price increase from entry price.
Tip: Research what coins have consistent and large token unlocks / highly inflationary tokenomics, and target these during bear markets to short as they will most likely have substantial selling pressure that outweighs demand - leading to declining prices.
The strategy assumes each order is using 30% of the available coins to make the results more realistic and to simulate you only ran this strategy on 30% of your holdings. A trading fee of 0.1% is also taken into account and is aligned to the base fee applied on Binance.
The backtesting data was recorded from December 1st 2021, just as the market was beginning its downtrend. We therefore recommend analysing the market conditions prior to utilising this strategy as it operates best on weak coins during downtrends and bearish conditions.
[blackcat] L2 James Garofallou RSI In 4 DimLevel 2
Background
Traders’ Tips of September 2020, the focus is James Garofallou’s article in the September issue, “Tracking Relative Strength In Four Dimensions”.
Function
In “Tracking Relative Strength In Four Dimensions” in this issue, author James Garofallou introduces us to a new method of measuring the relative strength of a security. This new technique creates a much broader reference than would be obtained by using a single security or index and combines several dimensions, as the author calls them, into a single rank value. This study compares a security to another in four dimensions, as explained in the article. James Garofallou presents a metric for a security’s strength relative to 11 major market sectors and over several time periods. All this is squeezed into a single value. The first step is the RS2. It normalizes the security to a market index, then calculates four moving averages and encodes their relations in a returned number. I just modified it by using most BTC-correlated instruments to reflect how BTC response to their performance.
Remarks
This is a Level 2 free and open source indicator.
Feedbacks are appreciated.
RSI Wave SignalsQuick Description: Smoothed RSI with optimized trailing moving average. Look for cross above or cross under signals for buy and sell orders respectively.
VIDYA moving average of RSI incorporated with "optimized trend tracker" system. Thanks to kivancozbilgic and anilozeksi for implementing this great idea on Tradingview. The indicator adds "1,000" to the RSI MA values for more natural and accurate percentage trailing.
Settings:
- Period MA is the moving average length of the blue line
- Trailing Percentage of MA adjusts the percentage (sort of) trailing level of the moving average.
- RSI Length adjusts the rsi length in calculation.
Trading Tips:
- System might be enhanced by taking signals only on "oversold" or "overbought" territories (i.e <~1020 or >~1080)
- Adjust position size of by 4 times of atr(length=14)
- Take 50% of position as profit when position reaches the 4*atr TP Level (breakeven)
- Let the rest ride.
- Best performing on short frequencies such as 1, 3, 5 mins.
PnL and Buy & Hold TrackerIn this script I use a simple, not necessarily profitable, strategy of a cross of MAs to teach how to calculate and plot the PnL of each trade made by the indicator. I also show how to calculate the cumulative PnL of all trades and the Buy and Hold of the same period.
These calculations which are natively available in any strategy script, require a bit of resourcefulness to work in an indicator script.
It can be very useful to optimize parameters for the best performance of an indicator-based strategy.
I use variables to store the price of the asset at each buy signal to calculate the PnL with the closing price of that particular trade and another variable to store the price value of the first trade, which calculates the Buy and Hold percentage with the current price of the asset.
I plot the values of the trades in labels and the accumulated values in a table.
I also show how to calculate and plot the unrealized PnL of open trades.
HOTT and LOTTA brand new indicator adaptation via ott from OTT developer Anıl Özekşi.
Optimized Trend Tracker, OTT is an indicator that provides traders to find an existing trend or in another words to ser which side of the current trend we are on. Kıvanç Özbilgiç coded OTT from the matrix program and adapted it to tradingview.
This indicator adaptation works with patch logic. Ott is created with the support of 10 bars Highest High and Lowest Low. The settings that the creator uses are the standard existing settings.
Here is the HighestOTT (HOTT) Line,
In general, what you need to see here is that prices tend to touch prices as they go up.
If the prices are rising, it tries to go below them, if it cannot, at least it tries to move within it.
When the price is flat or falling, it stays above the prices without touching them. This shows that our patch can do its job, which we wanted at the beginning, to protect us from horizontals and falls during purchase.
Here is the LowestOTT (LOTT) Line,
As you can notice, it uses similar construction as a structure. The only difference is that what we just did with Highest High, we are now trying to bring out the opposite effect by doing it with Lowest Low.
Now let's see hott and lott together. The places I want to draw your attention to are that prices are always above LOTT where they are on the up and sideways, and below HOTT when they are on the downtrend.
In this case, you must have understood the working principles of our patches.
If the prices are above the blue line, that is, HOTT, our buying door is opened, and as long as it is below, the buying door will remain closed.
Likewise, if the prices are below the purple line, that is, LOTT, our sales door is opened, and as long as it is above the sales door will remain closed.
Bar colors are also designed accordingly.
There is an Extra Plot Candle option in the settings tab of the indicator. This option is designed so that you can use bar colors efficiently while using normal candles. In order to use this option properly, you need to turn off the candle, border and wick colors in the symbol section of the graphic settings.
Built in Moving Average type defaultly set as VAR but users can choose from 8 different Moving Average types like:
SMA : Simple Moving Average
EMA : Exponential Moving Average
WMA : Weighted Moving Average
TMA : Triangular Moving Average
VAR : Variable Index Dynamic Moving Average a.k.a. VIDYA
WWMA : Welles Wilder's Moving Average
ZLEMA : Zero Lag Exponential Moving Average
TSF : True Strength Force
Best regards to Anıl Özekşi and Kıvanç Özbilgiç.
Abz BTC InvestorInvestor indicator:
This indicator is intended to be used on a chart showing Bitcoin's historical price action. By viewing years of Bitcoin's history, it's possible to better see Bitcoin's current price within a long term context of the price rage.
Purpose and possible usage:
I built the indicator to make it easier for me and for friends and family to make better informed decisions about our Bitcoin investments. The indicator shows the historic range of the asset and indicates where Bitcoin is oversold (below the bottom line) and overbought (above the top purple line):
- Above the top purple line, I'll look to take some profits or consider hedging to protect my long term position's growth
- Below the bottom purple line, I'll look to dollar cost average into a long term position
I think the idea for this came from idea listening to the YouTuber Birb talking about how well Bitcoin tracked between the 200 day moving average (bottom navy moving average) and 5x that value (top moving average).
Hope you find it useful.
Best wishes,
Abzorba
Overbought & Oversold TrackerAbout this indicator:
- This indicator is basically a stochastic indicator that shows to you the crossover in an Overbought or Oversold area DIRECTLY on the chart
How does it works:
- When Stochastic crosses at Oversold area, a Blue Triangle will appear below the candle with a Blue Dotted Line at the low of the current candle
- The Blue Triangle is to help you to see easily the candle where the crossover is occurring
- At the same time, the Blue Dotted Line will act as a minor Support for the current price
- If the current candle breaks the Blue Dotted Line (minor Support), the candle will be displayed in a red color
- Same things will occur if Stochastic crosses at the Overbought area, but at this time, a Red Triangle with Red Dotted Line will appear just to differentiate between Overbought and Oversold crossover
The advantage of using this indicator:
- You can easily see the point of stochastic crossover DIRECTLY on the chart without analyzing the stochastic indicator
- At the same time, it helps you to see clearly either the price is at the bottom / reversal by combining it with S&R / trendlines or other indicators
Personally, I will combine this indicator with:
a. Support and Resistance or Trendlines
b. Fibonacci retracement
c. Candlestick indicator (see my script list)
d. Ultimate MACD (see my script list)
e. Volume indicator
These combinations personally increase the possibility for me to buy exactly at the point of reversal in a pullback
- This indicator is preset at the value of 25 (oversold) and 75 (overbought) k line, it's my own preference. You can change these values at the setting menu to suit your trading style.
- Once again, I am opening the script for anyone to modify/alter it based on you own preference. Have a good day!