Full strategy AllinOne with risk management MACD RSI PSAR ATR MAHey, I am glad to present you one of the strategies where I put a lot of time in it.
This strategy can be adapted to all type of timecharts like scalping, daytrading or swing.
The context is the next one :
First we have the ATR to calculate our TP/SL points. At the same time we have another rule once we enter(we enter based on % risk from total equity, in this example 1%, at the same time, lowest ammount for this example is 0.1 lots, but can be modified to 0.01), so we can exit both by tp/sl points, or by losing 1% of our equity or winning 1% of our total equity. It's dinamic.
The strategy is made from
Trend direction :
PSAR
First confirmation point :
Crossover between 10EMA and Bollinger bands middle point
Second confirmation
MACD histogram
Third confirmation
RSI overbought/oversold levels
For entries : we check trend with psar, then once ema cross bb middle point, we confirm together with rsi level for overbought/oversold and macd histogram ( > 0 or <0).
We exit, when we have opposite sign, like from buy to sell or sell to buy, or when we reach tp/sl points, or when we reach % basaed equity points.
It can be changed to be fixed lots, or fixed tp/sl , you just have to uncomment the size from entries, and tp/sl lines.
At the same time, it has the possibility if one desires, to trade only concrete forex session like european, asian and so on for intraday trading.
Hope you enjoy it.
Let me know how it goes.
Centered Oscillators
MACD+ Strategy [SystemAlpha]This is a strategy based on MACD Oscillator . Instead of using just the normal crossovers, we use trend filters, trailing stop loss and take profit targets. This strategy was developed for crypto, forex and stocks on daily timeframe but feel free to experiment on 15 minutes or higher using heikin ashi or normal candles
In this strategy you have a choice of:
Trend Filters:
- Average Directional Index ( ADX ) – buy when price is trend is up and sell when trend is down.
- Moving Average (MA) – buy when price close above the defined moving average and sell when price close below moving average
- Parabolic SAR – buy when SAR is above price is above price and sell when SAR is below price.
- All - Use ADX , MA and SAR as filters
For MA Filter , you can use the “TF MA Type” and "TF MA Period" parameter to select Simple or Exponential Moving Average and length.
Stop Loss:
- Average True Range (ATR) – ATR % stop as trailing stop loss.
- Parabolic SAR ( SAR ) – Parabolic SAR adapted as trailing stop loss.
For ATR , you can use the “ATR Trailing Stop Multiplier” parameter to set an initial offset for trailing stop loss.
Take Profit Target:
- Average True Range (ATR) – ATR % stop as trailing stop loss.
- Standard % – Percent as target profit
For ATR , you can use the “ATR Take Profit Multiplier” parameter to set an initial offset for trailing stop loss.
Additional feature include:
- Regular and Hidden Divergence display and alerts
STRATEGY ONLY:
- Set back test date range
- Set trade direction - Long, Short or Both
- Use timed exit - Select method and bars
- Method 1: Exit after specified number of bars.
- Method 2: Exit after specified number of bars, ONLY if position is currently profitable.
- Method 3: Exit after specified number of bars, ONLY if position is currently losing.
TradingView Links:
Alerts:
MACD:
How to use:
1. Apply the script by browsing through Indicators --> Invite-Only scripts and select the indicator
2. Once loaded, click the gear (settings) button to select/adjust the parameters based on your preference.
3. Wait for the next BUY or SELL signal to enter the trade!
Disclaimer:
The indicator and signals generated do not constitute investment advice; are provided solely for informational purposes and therefore is not an offer to buy or sell a security; are not warranted to be correct, complete or accurate; and are subject to change without notice.
percentrank strategySrategy for percentrank
Percent rank is the percents of how many previous values was less than or equal to the current value of given series.
long entry: intersection line 1 from bottom to top
short entry: crossing line 2 from top to bottom
Стратегия для индикатора percentrank
Процентный рейтинг — это процент от количества предыдущих значений, которые были меньше или равны текущему значению данной серии.
вход в лонг: пересечение line 1 снизу вверх
вход в шорт: пересечение line 2 сверху вниз
S&P Bear Warning IndicatorTHIS SCRIPT HAS BEEN BUILT TO BE USED AS A S&P500 SPY CRASH INDICATOR ON A DAILY TIME FRAME (should not be used as a strategy).
THIS SCRIPT HAS BEEN BUILT AS A STRATEGY FOR VISUALIZATION PURPOSES ONLY AND HAS NOT BEEN OPTIMIZED FOR PROFIT.
The script has been built to show as a lower indicator and also gives visual SELL signal on top when conditions are met. BARE IN MIND NO STOP LOSS, NOR ADVANCED EXIT STRATEGY HAS BEEN BUILT.
As well as the chart SELL signal an alert option has also been built into this script.
The script utilizes a VIX indicator (maroon line) and 50 period Momentum (blue line) and Danger/No trade zone(pink shading).
When the Momentum line crosses down across the VIX this is a sell off but in order to only signal major sell offs the SELL signal only triggers if the momentum continues down through the danger zone.
A SELL signal could be given earlier by removing the need to wait for momentum to continue down through the Danger Zone however this is designed only to catch major market weakness not small sell offs.
As you can see from the picture between the big October 2018 and March 2020 market declines only 2 additional SELLS were triggered.
To use this indicator to identify ideal buying then you should only buy when Momentum line is crossed above the VIX and the Momentum line is above the Danger Zone (ideally 3 - 5 days above danger zone)
Combo Backtest 123 Reversal & Ergodic MDI This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
This is one of the techniques described by William Blau in his book "Momentum,
Direction and Divergence" (1995). If you like to learn more, we advise you to
read this book. His book focuses on three key aspects of trading: momentum,
direction and divergence. Blau, who was an electrical engineer before becoming
a trader, thoroughly examines the relationship between price and momentum in
step-by-step examples. From this grounding, he then looks at the deficiencies
in other oscillators and introduces some innovative techniques, including a
fresh twist on Stochastics. On directional issues, he analyzes the intricacies
of ADX and offers a unique approach to help define trending and non-trending periods.
WARNING:
- For purpose educate only
- This script to change bars colors.
Combo Backtest 123 Reversal & Ergodic MACD This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
This is one of the techniques described by William Blau in his book
"Momentum, Direction and Divergence" (1995). If you like to learn more,
we advise you to read this book. His book focuses on three key aspects
of trading: momentum, direction and divergence. Blau, who was an electrical
engineer before becoming a trader, thoroughly examines the relationship
between price and momentum in step-by-step examples. From this grounding,
he then looks at the deficiencies in other oscillators and introduces some
innovative techniques, including a fresh twist on Stochastics. On directional
issues, he analyzes the intricacies of ADX and offers a unique approach to help
define trending and non-trending periods.
Blau`s indicator is like usual MACD, but it plots opposite of meaningof
stndard MACD indicator.
WARNING:
- For purpose educate only
- This script to change bars colors.
Combo Backtest 123 Reversal & Ergodic CSI This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
This is one of the techniques described by William Blau in his book
"Momentum, Direction and Divergence" (1995). If you like to learn more,
we advise you to read this book. His book focuses on three key aspects
of trading: momentum, direction and divergence. Blau, who was an electrical
engineer before becoming a trader, thoroughly examines the relationship between
price and momentum in step-by-step examples. From this grounding, he then looks
at the deficiencies in other oscillators and introduces some innovative techniques,
including a fresh twist on Stochastics. On directional issues, he analyzes the
intricacies of ADX and offers a unique approach to help define trending and
non-trending periods.
This indicator plots Ergotic CSI and smoothed Ergotic CSI to filter out noise.
WARNING:
- For purpose educate only
- This script to change bars colors.
Ehlers Bandpass FilterThis script uses @cheatcountry script to determine Ehlers Bandpass Filter.
Backtest offers 3 capital management tools. One that will always calculate order size as initial capital/close, one that uses the same calculation but adds or substracts profit. The last one allows you to enter manually the size you want to trade.
The time-based stop will close the position after a set number of bars.
CDC Action Zone V.2 Strategy BacktestPublished for backtest purpose
All credit to : CDC Action Zone V.2 by piriya33
จัดทำขึ้นเพื่อการดูผล Backtest เขียวซื้อแดงขาย
ตัวสคริปท์มีการเพิ่ม
- Strategy Long/Short/Both // ปรับได้ใน Setting
- Back test range // ปรับได้ใน Setting
MACD Trend Following Strategy How it work ?
Work like normal MACD because this is MACD without any modify but i add color of candlestick and strategy.
The color meaning :
Green= macd > signal and macd>0 (Buy)
Red= macd < signal and macd<0 (Sell)
Yellow= macd > signal and macd<0 (Maybe reversal point)
Blue= macd < signal and macd>0 (Maybe reversal point)
Feature
- Back test range
- Long/Short option
- Modifiable MACD Setting
TSI CCI Hull with profit$$$This is a modified version of @SeaSide420 TSI CCI Hull with profits exit on long and short order
ORIGINAL SCRIPT:
/// /// feel free to edit/improve and comment
Combing in MACD and MTFHi all, I'm trying to wedge in the MACD into a multiple timeframe. Scope is to create:
1) an alert when the MACD across all timeframes is positive,
2) an alert when the MACD across all timeframes is negative, and
3) one when neither of them is applicable.
Would anyone be so kind to give it some thoughts, please?
//@version=2
strategy(" Easy MTF Strategy", overlay=false)
TF_1_time = input("3", "Timeframe 1")
TF_2_time = input("5", "Timeframe 2")
TF_3_time = input("15", "Timeframe 3")
TF_4_time = input("30", "Timeframe 4")
fastLen = input(title="Fast Length", type=integer, defval=12)
slowLen = input(title="Slow Length", type=integer, defval=26)
sigLen = input(title="Signal Length", type=integer, defval=9)
= macd(close, fastLen, slowLen, sigLen)
width = 5
upcolor = green
downcolor = red
neutralcolor = blue
linestyle = line
TF_1 = security(tickerid, TF_1_time, open) < security(tickerid, TF_1_time, close) ? true:false
TF_1_color = TF_1 ? upcolor:downcolor
TF_2 = security(tickerid, TF_2_time, open) < security(tickerid, TF_2_time, close) ? true:false
TF_2_color = TF_2 ? upcolor:downcolor
TF_3 = security(tickerid, TF_3_time, open) < security(tickerid, TF_3_time, close) ? true:false
TF_3_color = TF_3 ? upcolor:downcolor
TF_4 = security(tickerid, TF_4_time, open) < security(tickerid, TF_4_time, close) ? true:false
TF_4_color = TF_4 ? upcolor:downcolor
TF_global = TF_1 and TF_2 and TF_3 and TF_4
TF_global_bear = TF_1 == false and TF_2 == false and TF_3 == false and TF_4 == false
TF_global_color = TF_global ? green : TF_global_bear ? red : white
TF_trigger_width = TF_global ? 6 : width
plot(1, style=linestyle, linewidth=width, color=TF_1_color)
plot(5, style=linestyle, linewidth=width, color=TF_2_color)
plot(10, style=linestyle, linewidth=width, color=TF_3_color)
plot(15, style=linestyle, linewidth=width, color=TF_4_color)
plot(25, style=linestyle, linewidth=4, color=TF_global_color)
exitCondition_Long = TF_global_bear
exitCondition_Short = TF_global
longCondition = TF_global
if (longCondition)
strategy.entry("MTF_Long", strategy.long)
shortCondition = TF_global_bear
if (shortCondition)
strategy.entry("MTF_Short", strategy.short)
strategy.close("MTF_Long", when=exitCondition_Long)
strategy.close("MTF_Short", when=exitCondition_Short)
Schaff Trend Cycle + Double MAThis strategy uses two different moving averages to determine a trend. It opens a position on a pullback from a trend.
Conditions for buy signal are:
►Crossover out of Shaff Trend Cycle's extreme levels
►The price is above its short period exponential moving average.
►A short period exponential moving average is above a long period exponential moving average.
*Conditions for sell are the opposite.
All in all, I don't think it needs to be on your chart but it can be optimized and even successful on some timeframes.
Shaff Trend Cycle solution was provided by @everget, I converted his script to Pine v.4, added exponential averages and created an algorithm for backtesting.
MacD 200 Day Moving Average Signal Crossover StrategyThis works on most time frames, but I noticed the 4 hour for BTCUSD on coinbase seems to work well as an example. The strategy is pretty simple. I was inspired by a youtube video that said to backtest their strategy so I did. Most of the time it doesn't work but sometimes it's pretty good as in the case I showed.
Basically, you buy if the MacD crossers over the signal line and the histogram is below 0 and you are above the 200 day moving average. Do the opposite to sell!
TSI CCI HullThis Strategy is Using TSI and CCI and Hull Moving Average to make swing trades on 1H chart but can be used on any pair and timeframe just change settings to suit (Hull Period mostly)
Combo Backtest 123 Reversal & Ease of Movement (EOM) This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
This indicator gauges the magnitude of price and volume movement.
The indicator returns both positive and negative values where a
positive value means the market has moved up from yesterday's value
and a negative value means the market has moved down. A large positive
or large negative value indicates a large move in price and/or lighter
volume. A small positive or small negative value indicates a small move
in price and/or heavier volume.
A positive or negative numeric value. A positive value means the market
has moved up from yesterday's value, whereas, a negative value means the
market has moved down.
WARNING:
- For purpose educate only
- This script to change bars colors.
StarbuxI made this in starbucks .
Bullish hammer trading signal algorithm
using MACD for trend determination and holding period.
BEST ATR Stop Multiple StrategyHello traders
Here we go again.... with another strategy snippet.
Reminder: it's an alternative of this Trailing Stop strategy script
Entry logic
The entry is based on a Simple Moving Averages (SMA) cross.
This part doesn't matter here - as I wanted to focus on the ATR multiple stop loss component.
ATR STOP
This strategy snippet uses an entry stop loss defined based on a multiple of the average true range value.
The soure code detects ATR value at entry price, applies the multiplier and will set a static (= non trailing) stop-loss to each position
A pinescript v4 label will appear for each new signal displaying the ATR*multiplier value at signal time
All the BEST
Dave
Combo Backtest 123 Reversal & Dynamo This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
In July 1996 Futures magazine, E. Marshall Wall introduces the
Dynamic Momentum Oscillator (Dynamo). Please refer to this article
for interpretation.
The Dynamo oscillator is a normalizing function which adjusts the
values of a standard oscillator for trendiness by taking the difference
between the value of the oscillator and a moving average of the oscillator
and then subtracting that value from the oscillator midpoint.
WARNING:
- For purpose educate only
- This script to change bars colors.
DEMA Strategy with MACDThe Double Exponential Moving Average (DEMA) indicator was introduced in January 1994 by Patrick G. Mulloy, in an article in the "Technical Analysis of Stocks & Commodities" magazine: "Smoothing Data with Faster Moving Averages"
It attempts to remove the inherent lag associated to Moving Averages by placing more weight on recent values. The name suggests this is achieved by applying a double exponential smoothing which is not the case. The name double comes from the fact that the value of an EMA (Exponential Moving Average) is doubled. To keep it in line with the actual data and to remove the lag the value "EMA of EMA" is subtracted from the previously doubled ema.
DEMA is a very responsive system. A lot of signals can be generated only when trading with DEMA. In this strategy, I combined Dema buy-sell signals with MACD indicator. When you activate MACD confirmation from settings; When DEMA comes to long situation, the MACD histogram is checked to be positive.
Trend Trader Strategy with MACDThis is plots the indicator developed by Andrew Abraham in the Trading the Trend article of TASC September 1998
The strategy I use has already been published explicitly by HPotter, you can review the core code from there.
I have converted the existing strategy codes that have been published into the strategy and the result looks great but I noticed that the indicator performed too much in short periods like 1 minute and I thought it would be healthier to get MACD approval. MACD approval will come selected by default. When the indicator reaches the buy status, if the macd histogram is positive, it enters the long process. By removing this confirmation from the settings window, you can see the normal signal frequency of the indicator.
This strategy is mainly based on trend signals. In fact, I am publishing this strategy to use in alternating trading for Bear-Bull crypto coins.
What does the bear-bull comparison mean?
You can open the same chart in the ETHBEAR / USDT symbol as opposed to the ETHBULL / USDT symbol that appears on the chart. When BUY signal comes in bull symbol, SELL will come in bear symbol. When BUY signal comes in bear symbol, SELL will come in bull symbol. In this way, very fast and very high profit can be obtained by alternating operation.
Laguerre RSI by KivancOzbilgic STRATEGYBacktesting.
" Laguerre RSI is based on John EHLERS' Laguerre Filter to avoid the noise of RSI .
Change alpha coefficient to increase/decrease lag and smoothness.
Buy when Laguerre RSI crosses upwards above 20.
Sell when Laguerre RSI crosses down below 80.
While indicator runs flat above 80 level, it means that an uptrend is strong.
While indicator runs flat below 20 level, it means that a downtrend is strong. "
Developer: John EHLERS
Author: KivancOzbilgic
Why is it ok to backtest on TradingView from now on!TradingView backtester has bad reputation. For a good reason - it was producing wrong results, and it was clear at first sight how bad they were.
But this has changed. Along with many other improvements in its PineScript coding capabilities, TradingView fixed important bug, which was the main reason for miscalculations. TradingView didn't really speak out about this fix, so let me try :)
Have a look at this short code of a swing trading strategy (PLEASE DON'T FOCUS ON BACKTEST RESULTS ATTACHED HERE - THEY DO NOT MATTER). Sometimes entry condition happens together with closing condition for the already ongoing trade. Example: the condition to close Long entry is the same as a condition to enter Short. And when these two aligned, not only a Long was closed and Short was entered (as intended), but also a second Short was entered, too!!! What's even worse, that second short was not controlled with closing conditions inside strategy.exit() function and it very often lead to losses exceeding whatever was declared in "loss=" parameter. This could not have worked well...
But HOORAY!!! - it has been fixed and won't happen anymore. So together with other improvements - TradingView's backtester and PineScript is now ok to work with on standard candlesticks :)
Yep, no need to code strategies and backtest them on other platforms anymore.
----------------
Having said the above, there are still some pitfalls remaining, which you need to be aware of and avoid:
Don't backtest on HeikenAshi, Renko, Kagi candlesticks. They were not invented with backtesting in mind. There are still using wrong price levels for entries and therefore producing always too good backtesting results. Only standard candlesticks are reliable to backtest on.
Don't use Trailing Stop in your code. TradingView operates only on closed candlesticks, not on tick data and because of that, backtester will always assume price has first reached its favourable extreme (so 'high' when you are in Long trade and 'low' when you are in Short trade) before it starts to pull back. Which is rarely the truth in reality. Therefore strategies using Trailing Stop are also producing too good backtesting results. It is especially well visible on higher timeframe strategies - for some reason your strategy manages to make gains on those huge, fat candlesticks :) But that's not reality.
"when=" inside strategy.exit() does not work as you would intuitively expect. If you want to have logical condition to close your trade (for example - crossover(rsi(close,14),20)) you need to place it inside strategy.close() function. And leave StopLoss + TakeProfit conditions inside strategy.exit() function. Just as in attached code.
If you're working with pyramiding, add "process_orders_on_close=ANY" to your strategy() script header. Default setting ("=FIFO") will first close the trade, which was opened first, not the one which was hit by Stop-Loss condidtion.
----------------
That's it, I guess :) If you are noticing other issues with backtester and would like to share, let everyone know in comments. If the issue is indeed a bug, there is a chance TradingView dev team will hear your voice and take it into account when working on other improvements. Just like they heard about the bug I described above.
P.S. I know for a fact that more improvements in the backtesting area are coming. Some will change the game even for non-coding traders. If you want to be notified quickly and with my comment - gimme "follow".