MA Cross - Multi-Timeframe The MA cross is probably one of my favourite strategies because of its simplicity but it often gets overlooked for more complex strategies.
The original author of this script is ChartArt, I have just added some extra controls and functions which are outlined below. I would just like to add that this is my first published script, everything I have learned about coding has been from studying and tinkering with many of the publicly available scripts on TV so I would like thank all the authors who give out this knowledge so freely!
Updates
- Converted to v4
- Made some graphical changes and provided more control over plots
- Added RMA and VWMA
- Added alerts
Original script can be found here
Trend
RSI TrendsRSI is a momentum indicator, however most people seem to be using it to go against the momentum by trying to identify tops/bottoms using it. Its in my opinion the wrong way to be using it. It can be easily used for trend following which seems like a better use for it.
Uptrend - RSI > 60
Downtrend - RSI < 40
Sideways - RSI between 40 and 60
If however not interested in filtering for sideways trends and convert it to a long-short only strategy that stays in market all the time then it can be simply modified by setting both overbought/oversold thresholds to 50. In such a case uptrend will be above 50 and downtrend will be less than 50.
Note: wait for close for current bar to be confirmed as RSI is calculated at close
Ehlers 3 Pole Butterworth Filter V2 [CC]The 3 Pole Butterworth Filter was created by John Ehlers (Cybernetic Analysis For Stocks And Futures pgs 196-197) and this indicator is a moving average that also works well as a trendline. Buy when the indicator line turns green and sell when it turns red.
Let me know if you would like me to publish other indicators or if you want something custom done!
Ehlers 2 Pole Super Smoother Filter V2 [CC]The 2 Pole Super Smoother Filter was created by John Ehlers (Cycle Analytics For Traders pg 32) and this follows the price very closely and very useful because it is consistent with uptrends and falls sharply during a sudden downtrend so it should be able to help you stay more profitable. Buy when the indicator line turns green and sell when it turns red.
Let me know if there are other indicators you would like to see me publish or if you want something custom done!
Ehlers Center Of Gravity Oscillator [CC]The Center of Gravity Oscillator was created by John Ehlers (Cybernetic Analysis For Stocks And Futures pg 49) and this provides a pretty accurate way to see how the stock is trending. If the indicator stays above 0 then the stock is in a pretty strong uptrend and if it stays below 0 then the stock is in a pretty strong downtrend. Buy when the indicator changes from red to green and sell when it changes from green to red.
Let me know if you would like me to publish any other indicators or if you want something custom done!
Welles Wilder MA [MX]The average of 34 periods I observe as a mobile S/R, but I usually observe it more when it is in strong trend, and the average of 72 and 89 as trend dictators, if the asset is above them = Bullish , below = Bearish , and the 144 average as the last moving S/R, and also as an S/R even stronger than all other MAs and when the asset loses that average, I see it as final confirmation of the other previous averages.
I give more importance to the average of 89 periods than to 72, because I see it as an extension to the average of 72, as if it were a trend range.
for those who prefer to observe the crossing of short and long averages as a way to see the trend, I also left this option, although I do not use
//////////////////////////////
A média de 34 periodos eu observo como um S/R móvel, mas eu costumo observar ela mais quando está em forte tendência, estando bem bearish ou jeffish, e a média de 72 e 89 como ditadoras de tendência, se o ativo está acima delas = Bullish , abaixo = Bearish , e a média de 144 como o último S/R móvel, e também como um S/R ainda mais forte que todas as outras MA's e quando o ativo perde essa média, eu vejo como confirmação final das outras médias anteriores.
Eu dou mais importância a média de 89 períodos do que a de 72, porque eu vejo ela como uma extensão a média de 72, como se fosse um range de tendência.
para quem prefere observar o cruzamento das médias curtas com as longas como forma de ver a tendência, eu deixei também essa opção, embora eu não use
Percentile Nearest Rank Using Arrays [LuxAlgo]The new array feature is extremely powerful, as it will allow pinescript users to do more complex things, or compute existing calculations more efficiently, it will also be possible to shine some light to some already existing functions, one of them being percentile_nearest_rank .
We have been working on this new feature with our pal alexgrover, and made this script which computes a rolling percentile using the nearest rank method.
Settings
Length: Window of the rolling percentile, determine the number of past data to be used.
Percentage: Return the current value if Percentage % of the data fall below that value, the setting is in a range (0,100).
Src: Input source of the indicator.
Usage
A rolling percentile can have many usages when it comes to technical analysis, this is due to its ability to return the value of three common rolling statistics, the rolling median, which can be obtained using a percentage equal to 50, the rolling maximum, obtained with a percentage equal to 100, and the rolling minimum, obtained with a percentage equal to 0.
When we use our rolling percentile as a rolling median, we can obtain a robust estimation of the underlying trend in the price, while using it as a rolling maximum/minimum can allow us to determine if the market is trending, and at which direction. The rolling maximum/minimum is a rolling statistic used to calculate the well known stochastic oscillator and Donchian channel indicator.
We can also compute rolling quartiles, which can be obtained using a percentage of 25 or 75, with one of 25 returning the lower quartile and 75 the upper quartile.
In blue the upper rolling quartile (%75), in orange the lower rolling quartile (%25), both using a window size of 100.
Details
In order to compute a rolling percentile nearest rank, we must first take the most recent length closing prices, then order them in ascending order, we then return the value of the ordered observations at index (percentage/100*length) - 1 (we use - 1 because our array index starts at 0).
Momentum Adjusted EMA TrendThe script draws a moving average which responds to trend changes extraordinary fast!
It's calculated using Momentum, Acceleration and Probability (Psychological Effect) by interfering the Golden Ratio!
I got the idea thanks to Tradingview user DGT (dgtrd) and his/her excellent descriptions.
The indicator is simplified for users and the default settings work great, so use it as you like specially as a trend indicator.
Dual Volatility StopThis merges Volatility Stop & its MTF version both published by u/TradingView . Background is colored green or red when both the current timeframe Vstop and higher timeframe Vstop point in same direction. Aim is to take the standard Vstop script which differentiates market from only uptrend/downtrend to uptrend/downtrend/sideways. There is a tradeoff with this, that there is no need for the Vstop to be always in a position which reduces trade time & frees up capital. However this leads to situations where it takes slightly more time to catch on to a trend after a reversal.
Green Background = Buy
Red Background = Sell
No Background = Flat
SMA Directional Matrix [LuxAlgo]This script was created in collaboration with alexgrover and displays a simple & elegant panel showing the direction of simple moving averages with periods in a user-selected range (Min, Max). The displayed number in the panel is the period of a simple moving average and the symbol situated at the right of it is associated with the direction this moving average is taking.
Settings
Min: Minimum period of the moving average
Max: Maximum period of the moving average
Src: Source input of the moving averages
Number Of Columns: Number of columns to be displayed in the panel, handy when using a large range of periods.
Usage
Looking at the direction of moving averages with different periods is extremely useful when it comes to having information about the short/mid/long term overall market sentiment, and can also tell us if the market is trending or ranging.
Here we use periods ranging from 25 to 50, we can see that shorter moving averages react to the recent upward price variation, longer-term moving averages however are still affected by the overall downward variation you can see on the image. We can as such get information about the presence of potentials divergences, with shorter-term moving averages reacting to the divergence while the longer-term moving averages will still display the direction of the main trend.
As such the indicator can give information about how clean a trend is, with a clean trend being defined as a variation containing no retracements. When our trend contains no retracement, the mid/long term moving averages will all have the same direction, however, when a retracement is present, the midterm moving averages might be affected by it, thus displaying a direction contrary to the main trend.
When the market is ranging we can expect the panel to display an equal number of decreasing/increasing moving averages.
Possible Issues
When using a large range of periods, you might have an error message showing: "String is too long", try lowering the range of periods by increasing Min or decreasing Max .
If the script displays the error message "Loop is too long to execute", try resetting the settings and change them back to the one you wanted to use.
The Lazy Trader - Index (ETF) Trend Following Robot50/150 moving average, index (ETF) trend following robot. Coded for people who cannot psychologically handle dollar-cost-averaging through bear markets and extreme drawdowns (although DCA can produce better results eventually), this robot helps you to avoid bear markets. Be a fair-weathered friend of Mr Market, and only take up his offer when the sun is shining! Designed for the lazy trader who really doesn't care...
Recommended Chart Settings:
Asset Class: ETF
Time Frame: Daily
Necessary ETF Macro Conditions:
a) Country must have healthy demographics, good ratio of young > old
b) Country population must be increasing
c) Country must be experiencing price-inflation
Default Robot Settings:
Slow Moving Average: 50 (integer) //adjust to suit your underlying index
Fast Moving Average: 150 (integer) //adjust to suit your underlying index
Bullish Slope Angle: 5 (degrees) //up angle of moving averages
Bearish Slope Angle: -5 (degrees) //down angle of moving averages
Average True Range: 14 (integer) //input for slope-angle formula
Risk: 100 (%) //100% risk means using all equity per trade
ETF Test Results (Default Settings):
SPY (1993 to 2020, 27 years), 332% profit, 20 trades, 6.4 profit factor, 7% drawdown
EWG (1996 to 2020, 24 years), 310% profit, 18 trades, 3.7 profit factor, 10% drawdown
EWH (1996 to 2020, 24 years), 4% loss, 26 trades, 0.9 profit factor, 36% drawdown
QQQ (1999 to 2020, 21 years), 232% profit, 17 trades, 3.6 profit factor, 2% drawdown
EEM (2003 to 2020, 17 years), 73% profit, 17 trades, 1.1 profit factor, 3% drawdown
GXC (2007 to 2020, 13 years), 18% profit, 14 trades, 1.3 profit factor, 26% drawdown
BKF (2009 to 2020, 11 years), 11% profit, 13 trades, 1.2 profit factor, 33% drawdown
A longer time in the markets is better, with the exception of EWH. 6 out of 7 tested ETFs were profitable, feel free to test on your favourite ETF (default settings) and comment below.
Risk Warning:
Not tested on commodities nor other financial products like currencies (code will not work), feel free to leave comments below.
Moving Average Slope Angle Formula:
Reproduced and modified from source:
Grid System With Fake MartingaleThe proposed strategy is based on a grid system with a money management that tries to replicate the effect of a martingale without having to double your position size after each loss, hence the name "fake martingale". Note that a balance using this strategy is still subject to exponential decay, the risk is not minimized, as such, it would be dangerous to use this strategy.
For more information on the martingale and grid systems see:
Strategy Settings
Point determines the "grid" size and should be adjusted accordingly to the scale of the security you are applying the strategy to. Higher value would require larger price movements in order to trigger a trade, generating fewer trades as a result.
The order size determines the number of contracts/shares to purchase.
The martingale multiplier determines the factor by which the position size is multiplied after a loss, using values higher to 2 will "squarify" your balance, while a value of 1 would use a constant position sizing.
Finally, the anti-martingale parameter determines whether the strategy uses a reverse martingale or not, if set to true then the position size is multiplied after each win.
How It Works
Let's illustrate how we replicate a martingale without doubling our exposure with a simple casino example. Imagine you are playing roulette, and that you are betting on colors (black/red), your payout is 1 to 1, in the case you win, you will have your initial stake back plus a profit equal to your initial stake.
If your strategy is to recover any previous losses, you can double your stake each time you lose, once you win you will get back the previous losses plus a profit equal to your original stake, this is the martingale system. So how can we win back previous losses without having to double our stake? We could do that by doubling the payout ratio after a loss, so after a loss, we must use a payout ratio of 2:1, if we lose once again we must use a payout of 4:1...etc, our payout ratio would be subject to exponential growth instead of our stake.
Of course, the payout ratio is fixed with casino games, but in trading, we can manipulate the position of our take profit in order to replicate such effect, this is what this strategy is doing. So after a loss, we place our take profit such that a win recover our losses back plus generate a profit.
Advantages
The advantage of this approach is that unlike the martingale we don't double our position size, which instead can remain constant, this is a huge advantage as a martingale will require a significant capital in order to tank a series of losses.
Disadvantages
The main disadvantage of this method is that the price might never reach our take profit after a long losing streak, our balance would remain in the red and we couldn't do anything about it except reset the strategy.
Frictional costs are still a disadvantage, as such, we would need to place our take profits in order to account for them, while this is still better than purchasing additional shares, it minimizes the chances of the price reaching the take profit.
Conclusions
An alternative money management system replicating the effect of a martingale as been presented, we can see that such a system is far from being perfect, and it would be foolish to use it, however, it stills offer a convenient alternative to less aggressive progressive position sizing systems.
I have been receiving some messages from users criticizing me for exposing the martingale money management system, and I understand why but I can't agree, talking about it allow me to warn users against it, the grid-martingale methodology is will create more harm than anything else, the reward is only one side of the story and should always be compared against the risk, so always take a look at all the statics in a backtest.
Thanks for reading!
Shout-Out
This post was made possible thanks to my patrons:
@Happymono, @AmariMars, @kkhaial, @Nugehe, @LucF, @Nosmok, @iflostio, @DankBeans, @ecletv, @Neverstorm, @alex.crown.jr, @uk503, @xkingshotss, @vsov, @jbelka, @yatrader2, @hughza, @ganh
Heiken-Ashi Color Vts// Simple as it says:
// gives you the color of the Heiken Ashi candles in a separate panel.
// I needed this indicator since in TV switching from HA to normal candles resets the chart and I had to go back manually.
// This solves the nasty issue.
// Moreover, nobody enters/exits the trade on the HA values but everyone uses just their color, right?
// Since bearish candles are encoded with value -1 and bullish candles with +1,
// a simple average can be defined (if you don't find it useful, disable it).
// Vitelot-Yanez-Vts, Aug 2020
//
Setup Trend Following Bollinger Bands - ValenteBuy when the candle closes above upper BB
Sell when the candle closes bellow lower BB
Stop always on base line
Breakout Trend FollowerThis is a Study mirroring the Breakout Trend Follower Strategy I made. I use this one during live trading and the other for backtesting. It will also give alerts when buy and sell signals are hit.
Colored VolumeThe height represents total volume, the ratio of red to green represents the bullish/bearish volume. AKA buyers or sellers.
[A618] Trend Tracker using Chandelier StopTrend Tacker
Works on ATR concepts and uses "Chandelier Stop by pipCharlie" as its main engine
How it is calculated
> 2 ATR stop plots are plotted
> #one ATR stop is of current time frame
> other one is the 5 times multiple of the current timeframe
> Their crossovers are analysed with the close of Current Timeframe
> This sort of methodology can help one with generating consistent entry signals over a particular timeframe
> My timeframe of choice is : 5 mins
> I have used resolution of 25, for 5 mins (see 5*5 =25)
Credits:
Chandelier Stop by pipCharlie
Hope this helps!!!
MESA Adaptive Moving Average - Improved MTFThis indicator is a huge upgrade to my original MTF MESA
Plots are now extremely smooth and accurate on all timeframes **
Missing data points are automatically filled with the "best fit"
This is a Trend indicator and should be used to trade "top-down" aka:
Start with the Daily chart to confirm a trend
Move to 4H
2H
Etc...
Use your favorite entry method or simply watch for wicks forming when the price gets near the MESA adaptive moving average.
This is one of the few indicators that I've been using for years with success. Being able to plot both the current & higher timeframe MESA
can sometimes feel like cheating.
Due to the nature of the recursive calculation, you may notice slight differences between this version of MESA and others that either
approximate higher timeframes with fewer samples or make use of the latest "Resolution" argument in Pinescript V4. Both of which are
fine, until you start looking at M5 charts while plotting the Daily MESA.
As always, happy trading!
** Currently supports
M 1,3,5,15,30,45
H 1,2,3,4
Day 1
Week 1
Month 1
Combo Backtest 123 Reversal & Extracting The Trend 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
Extracting The Trend
The related article is copyrighted material from Stocks & Commodities Mar 2010
WARNING:
- For purpose educate only
- This script to change bars colors.
Up/Down Trend MarkerA simple indicator of trend by using 3 EMAs of multiplies of 2, 5 and 10, filtered by standard positive/negative directional movements (DM) which are the base of Average Directional Index (ADX).
The "Trend Strength" option is included to set the EMA multipliers and also the variation between DM+ and DM- which interpret the trend as a weak or a strong one.
Note that the markers only point to almost the beginning of the trends and just change the direction when the opposite trend is detected.
Feel free to send me your opinions.
CDub's BolBands SetupUses a set of Bollinger Bands (user defined deviation, user defined deviation * 2) to determine possible entry set ups.
Signals are triggered when price crosses the first band (closest to the baseline MA) in the desired direction.
baseline can be your take profit 1 target
The inside band determines entry and can be used as a take profit 2 target (Opposite side of baseline)
The outside band is a suggested stop loss target (Same side of baseline) and can be used as a take profit 3 target (Opposite side of baseline)
Suggestions are welcome!
-CDub
Combo Strategy 123 Reversal & Extracting The Trend 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
Extracting The Trend
The related article is copyrighted material from Stocks & Commodities Mar 2010
WARNING:
- For purpose educate only
- This script to change bars colors.
Grid Like StrategyIt is possible to use progressive position sizing in order to recover from past losses, a well-known position sizing system being the "martingale", which consists of doubling your position size after a loss, this allows you to recover any previous losses in a losing streak + winning an extra. This system has seen a lot of attention from the trading community (mostly from beginners), and many strategies have been designed around the martingale, one of them being "grid trading strategies".
While such strategies often shows promising results on paper, they are often subjects to many frictions during live trading that makes them totally unusable and dangerous to the trader. The motivations behind posting such a strategy isn't to glorify such systems, but rather to present the problems behind them, many users come to me with their ideas and glorious ways to make money, sometimes they present strategies using the martingale, and it is important to present the flaws of this methodology rather than blindly saying "you shouldn't use it".
Strategy Settings
Point determines the "grid" size and should be adjusted accordingly to the scale of the symbol you are applying the strategy to. Higher value would require larger price movements in order to trigger a trade, as such higher values will generate fewer trades.
The order size determines the number of contracts/shares to purchase.
The martingale multiplier determines the factor by which the position size is multiplied after a loss, using values higher to 2 will "squarify" your balance, while a value of 1 would use a constant position sizing.
Finally, the anti-martingale parameter determines whether the strategy uses a reverse martingale or not, if set to true then the position size is multiplied after any wins.
The Grid
Grid strategies are commons and do not present huge problems until we use certain position sizing methods such as the martingale. A martingale is extremely sensitive to any kind of friction (frictional costs, slippage...etc), the grid strategy aims to provide a stable and simple environment where a martingale might possibly behave well.
The goal of a simple grid strategy is to go long once the price crossover a certain level, a take profit is set at the level above the current one and stop loss is placed at the level below the current one, in a winning scenario the price reach the take profit, the position is closed and a new one is opened with the same setup. In a losing scenario, the price reaches the stop loss level, the position is closed and a short one is opened, the take profit is set at the level below the current one, and a stop loss is set at the level above the current one. Note that all levels are equally spaced.
It follows from this strategy that wins and losses should be constant over time, as such our balance would evolve in a linear fashion. This is a great setup for a martingale, as we are theoretically assured to recover all the looses in a losing streak.
Martingale - Exponential Decays - Risk/Reward
By using a martingale we double our position size (exposure) each time we lose a trade, if we look at our balance when using a martingale we see significant drawdowns, with our balance peaking down significantly. The martingale sequence is subject to exponential growth, as such using a martingale makes our balance exposed to exponential decays, that's really bad, we could basically lose all the initially invested capital in a short amount of time, it follows from this that the theoretical success of a martingale is determined by what is the maximum losing streak you can endure
Now consider how a martingale affects our risk-reward ratio, assuming unity position sizing our martingale sequence can be described by 2^(x-1) , using this formula we would get the amount of shares/contracts we need to purchase at the x trade of a losing streak, we would need to purchase 256 contracts in order to recover from a losing streak of size 9, this is enormous when you take into account that your wins are way smaller, the risk-reward ratio is totally unfair.
Of course, some users might think that a losing streak of size 9 is pretty unlikely, if the probability of winning and losing are both equal to 0.5, then the probability of 9 consecutive losses is equal to 0.5^9 , there are approximately 0.2% of chance of having such large losing streak, note however that under a ranging market such case scenario could happen, but we will see later that the length of a losing streak is not the only problem.
Other Problems
Having a capital large enough to tank 9any number of consecutive losses is not the only thing one should focus on, as we have to take into account market prices and trading dynamics, that's where the ugly part start.
Our first problem is frictional costs, one example being the spread, but this is a common problem for any strategy, however here a martingale is extra sensitive to it, if the strategy does not account for it then we will still double our positions costs but we might not recover all the losses of a losing streak, instead we would be recovering only a proportion of it, under such scenario you would be certain to lose over time.
Another problem are gaps, market price might open under a stop-loss without triggering it, and this is a big no-no.
Equity of the strategy on AMD, in a desired scenario the equity at the second arrow should have been at a higher position than the equity at the first arrow.
In order for the strategy to be more effective, we would need to trade a market that does not close, such as the cryptocurrency market. Finally, we might be affected by slippage, altho only extreme values might drastically affect our balance.
The Anti Martingale
The strategy lets you use an anti-martingale, which double the position size after a win instead of a loss, the goal here is not to recover from a losing strike but instead to profit from a potential winning streak.
Here we are exposing your balance to exponential gross but you might also lose a trade at the end a winning streak, you will generally want to reinitialize your position size after a few wins instead of waiting for the end of a streak.
Alternative
You can use other-kind of progressions for position sizing, such as a linear one, increasing your position size by a constant number each time you lose. More gentle progressions will recover a proportion of your losses in a losing streak.
You can also simulate the effect of a martingale without doubling your position size by doubling your target profit, if for example you have a 10$ profit-target/stop-loss and lose a trade, you can use a 20$ profit target to recover from the lost trade + gain a profit of 10$. While this approach does not introduce exponential decay in your balance, you are betting on the market reaching your take profits, considering the fact that you are doubling their size you are expecting market volatility to increase drastically over time, as such this approach would not be extremely effective for high losing streak.
Conclusion
You will see a lot of auto-trading strategies that are based on a grid approach, they might even use a martingale. While the backtests will look appealing, you should think twice before using such kind of strategy, remember that frictional costs will be a huge challenge for the strategy, and that it assumes that the trader has an important initial capital. We have also seen that the risk/reward ratio is theoretically the worst you can have on a strategy, having a low reward and a high risk. This does not mean that progressive position sizing is bad, but it should not be pushed to the extreme.
It is nice to note that the martingale is originally a betting system designed for casino games, which unlike trading are not subject to frictional costs, but even casino players don't use it, so why would you?
Thx for reading