Default Strategy Inputs (Forex / Crypto)The code in this post contains a set of default strategy inputs I use in new projects / backtests in Tradingview.
Full code commentary is available on the Backtest-Rookies website. To comply with house rules, I cannot post the direct link here.
Features
Trade Direction: So that you can limit the strategy for long only, short only or trade in both directions. It is important to note that when you select “Long Only”, you will still see Short signals on the chart. However, they are only used to close a position rather than reverse it. This is the default behaviour for strategies. The same applies to “Short Only”.
Date Ranges: So that you can isolate backtesting to specific periods of interest such as bull or bear markets.
Sessions: So you can easily get an idea of the expected results during your own session. You may also notice that performance of the strategy varies depending on which session it is deployed in.
Some example stop losses: It is not an exhaustive list but it should be enough to provide some inspiration for different types of stops that you can experiment with.
Happy Scripting. I hope the community finds it useful.
Средний истинный диапазон (ATR)
Daily Average True Range OverlayPlots the upper and lower average true range away from the previous days close on all time frames.
ATR+ (Stop Loss Indicator)This script is designed to aid in back-testing and trade execution.
It displays three sets of values - the teal colored value is the current ATR, the green colored value is your stop loss distance (in pips) below the most recent swing low for long trades , and the red colored value is your stop loss distance (in pips) above the most recent swing high for short trades .
You can change the stop loss settings to base your stop loss on a set pip amount or by however many multiples of the current ATR as you wish (eg. 1.5x ATR).
Feel free to ask any questions or edit the script without permission :)
- Matt.
Aggressive Pullback IndicatorThis indicator is designed to be used with the rules of Steven Hart's Aggressive Pullback Strategy. It is intended for use on the 4-hour timeframe of certain currency pairs, but will work on all timeframes and instruments. The rules are customizable, but the default settings are designed to reflect the rules of Steven's pullback strategy as closely as possible.
To enable alerts: Add the indicator to the chart and create a new alert with the settings Condition: API , Frequency: Once Per Bar (on Close).
Feel free to message me if you have any questions :)
- Matt.
Average Daily Range - without open barBasic ADR-indicator that is showing the daily range on lower timeframes as well, without using the current open daily bar for calculation.
Also plots as line in a separate indicator window. Updates displayed value when hovering over the candles on the chart to see historical Numbers.
ATR%A useful measure of recent volatility. I use 50 day or 50 week periods, but you can experiment with other values too. Because it measures ranges as a % of current close it can be used to make good comparisons with other historic periods of low (or high) volatility. This measure reached a new 23 year low for daily S&P 500 in July 2017.
Uses and historic examples: lunatictrader.com
Average True Range - without open barBasic ATR without the current open bar in progress, it calculates the closed bars within the chosen ATR Period
[STRATEGY][RS]Open Session Breakout TraderEXPERIMENTAL: use at your own discretion.
custom session breakout strategy, it uses a percentage of daily atr to set breakout limits. strategy only viable for intraday timeframes and is suggested under 1hour.
ATR BandThe indicator is intended to be used with daily or higher time frames.
Options:
Mark out of Band: show a symbol if price has moved beyond the band
ATR BandThe indicator is intended to be used with daily or higher time frames.
Options:
Mark out of Band: show a symbol is price has moved beyond the band
Average True Range ChannelsPlots three Average True Range channels as described in Alexander Elder's "The New Trading for a Living".
You can adjust the EMA and ATR days that are the basis of these channels.
This is my first script – happy to get any feedback on this! Thanks :)
J-PipsI made this tool to measure the exact PIP range of different currency pairs in an easy to understand format.
It comes with the option to convert the PIP Values to XXX/JPY Pairs with a simple check-box.
"H" is the highest PIP movement in 377 time periods.
"N" is the EMA-377 of the PIP ranges.
"P" is the current time periods PIP moment (true range).
ATR Pips [LazyBear] [Fixed by Elixium]This is ATR in pips. This was requested by user @ElixiumCapital on Twitter. ATRPIPs in his words:
How to use: Change the chart to the Daily time frame. The indicators value e.g. 0.0105 means that the average daily range of the past 5 trading days is 105 pips. (On standard pairs like EURUSD, GBPUSD)
"ATR PIPs is useful for finding markets with your desired amount of volatility, for example I prefer to trade forex pairs with the highest amount of volatility in the past 5 days, setting the length parameter to 5 days. And setting my stop loss at 25% to 33% of the the indicators value."
Fixed: Default parameters and a critical bug.
ATR Pips [LazyBear]This is ATR in pips. This was requested by user @ElixiumCapital. ATRPIPs in his words:
"ATR PIPs is useful for finding markets with your desired amount of volatility, for example I prefer to trade forex pairs with the highest amount of volatility in the past 5 days, setting the length parameter to 5 days. And setting my stop loss at 25% to 33% of the the indicators value."
I have added options to show a BB around ATR, as well as normal ATR (not in PIPs). All the parameters are configurable.
List of my public indicators: bit.ly
List of my app-store indicators: blog.tradingview.com
Daily ATR%If You are using a percentage of the Daily Average True Range in determining your stop placement,
this quick indicator is for You.
excerpt from investopedia.com/articles/trading/06/stopplacement.asp
ATR % Stop Method
The ATR% stop method can be used by any type of trader because the width of the stop is determined by the percentage of average true range (ATR). ATR is a measure of volatility over a specified period of time. The most common length is 14, which is also a common length for oscillators such as the relative strength index (RSI) and stochastics. A higher ATR indicates a more volatile market, while a lower ATR indicates a less volatile market. By using a certain percentage of ATR, you ensure that your stop is dynamic and changes appropriately with market conditions.
For example, for the first four months of 2006, the GBP/USD average daily range was around 110 to 140 pips. A day trader may want to use a 10% ATR stop - meaning that the stop is placed 10% x ATR pips from the entry price.In this instance, the stop would be anywhere from 11 to 14 pips from your entry price. A swing trader might use 50% or 100% of ATR as a stop. In May and June of 2006, daily ATR was anywhere from 150 to 180 pips. As such, the day trader with the 10% stop would have stops from entry of 15 to 18 pips while the swing trader with 50% stops would have stops of 75 to 90 pips from entry.
QQE MT4QQE (Quantative Qualitative Estimation) MT4 Version by Roman Ignatov
Another indicator from MT4 to pinescript, from a google search i found the that the original author is unknown and its best used for volatile pairs /JPY
yellow line is a smoothed rsi,
red line "slow trailing stop" is the ATR smoothing with a 14-periods wilders smoothing function that is multiplied by a factor of 4.236
Also big thanks to BlindFreddy, i used part of his supertrend indicator to make it work
Flex Renko Emulatorupdate:
As far as my algorithm design will take me this is it. So It's complete in my eyes. Here is a "working" version of something I've been looking for for a long time: "Flex" Renko Charting.
Bricks' sizes are determined by ATR and are set by simply choosing a resolution for the ATR calculation. No need to go in and choose renko granulation(resolution) AND brick size. Renko granulation is current chart resolution. Feel free to send me feedback on how to manage the reversal bricks' calculation or any other thoughts and ideas.
Replace the "close" in the main body of the renko calculation with 'high' and 'low' to get more consistent paintings across different aggregations since renkos aren't technically based off closing prices but where the price has been. Of course it's all a matter of preference:
Brick1 = high >
nz(Brick1) + BrickSize ? nz(Brick1) + BrickSize : low <
nz(Brick1) - BrickSize ?
nz(Brick1) - BrickSize
: nz(Brick1)
CM ATR Stops/Bands - Multi-TimeFrameCM_MTF ATR Bands/Stops
Many Options Available Via Input Tab:
-Chart Defaults to Upper and Lower ATR's Based on Current Chart TimeFrame
-Ability to Plot either Upper and/or Lower ATR's
-Ability to Change the Time Frame ATR's are Based On!
-Ability to change Look Back Period and ATR Multiplier Individually for Both Time Frames
-This Gives you the ability to plot same Time Frame with (for ex.) a 5 ATR with a 1.5 Mult and a 14 ATR with a 2.0 Mult etc.
-Or you can plot Daily ATR's on a 60 minute Chart etc.
-ATR Multipliers are Calculated with Code that allows "Non Whole Numbers" Allowing Ability to use 1.5 ATR's, 1.8 ATR's etc.
***Endless # of Combinations can be used!!!!
Average True Range Trailing Stops ColoredAverage True Range Trailing Stops Strategy, by Sylvain Vervoort
The related article is copyrighted material from Stocks & Commodities Jun 2009
CM ATR PercentileRankCM ATR PercentileRank - Great For Showing Market Bottoms.
When Increased Volatility to the Downside Reaches Extreme Levels it’s Usually a Sign of a Market Bottom.
This Indicator Takes the ATR and uses a different LookBack Period to calculate the Percentile Rank of ATR Which is a Great Way To Calculate Volatility
Be Careful Of Using w/ Market Tops. Not As Reliable.
***Ability to Control ATR Period and set PercentileRank to Different Lookback Period
***Ability to Plot Histogram Just Showing Percentiles or Histogram Based on Up/Down Close
Fuchsia Lines = Greater Than 90th Percentile of Volatility based on ATR and LookBack Period.
Red Lines = Warning — 80-90th Percentile
Orange Lines = 70-80th Percentile
Other Useful Indicators
Williams Vix Fix
CM_RSI EMA Is a Great Filter for Williams Vix Fix
Average True Range Trailing Stops Strategy Average True Range Trailing Stops Strategy, by Sylvain Vervoort
The related article is copyrighted material from Stocks & Commodities Jun 2009
Indicator: STARC BandsSTARC (Stoller Average Range Channels) bands make use of ATR to form the bands, giving it a more in-depth snapshot of market volatility compared to Bollinger Bands.
When a price curve penetrates a Bollinger Band, it may indicate the continuation of a price move; in contrast, the STARC bands tend to define upper and lower limits for normal price action.