Moving Average Crossover Swing StrategyMoving Average Crossover Swing Strategy
**Overview:**
The basic concept of this strategy is to generate a signal when a faster/shorter length moving average crosses over (for Longs) or crosses under (for Shorts) a medium/longer length moving average. All of which are customizable. This strategy can work on any timeframe, however the daily is the timeframe used for the default settings and screenshots, as it was designed to be a multi-day swing strategy. Once a signal has been confirmed with a candle close, based on user options, the strategy will enter the trade on the open of the next candle.
The crossover strategy is nothing new to trading, but what can make this strategy unique and helpful, is the addition of further confirmation points, ATR based stop loss and take profit targets, optional early exit criteria, customizable to your needs and style, and just about everything visual can be toggled on/off. This strategy is based on a Trend (MA) indicator and a Momentum (MACD) indicator. While a Volume-based indicator is not shown here, one could consider using their favorite from that category to further compliment the signal idea.
It should be noted that depending on the time frame, direction(s) chosen, the signal options, confirmation options, and exit options selected, that a ticker may not produce more than 100 trades on the back test. Depending on your style and frequency, one could consider adjusting options and/or testing multiple tickers. It should also be noted that this strategy simply tests the underlying stock prices, not options contracts. And of course, testing this strategy against historical data does not assume that the same results will occur in future price action.
Shoutout given to Ripster's Clouds Indicator as pieces of that code were taken and modified to create both the Cloud visualization effects, and the Moving Average Pair Plots that are implemented in this strategy.
BASIC DEFAULTS
All can be changed as normal
Initial capital = 10,000
Order Sizing = 25% of equity (use the "Inputs" tab to modify this)
Pyramiding = 0
Commission = 0.65 USD per order
Price Verification = 1 tick
Slippage = 1 tick
RISK MANAGMENT
You will notice two different percentage options and ATR multipliers. This strategy will adjust position sizing by not exceeding either one of those % values based on the ATR (Average True Range) of the symbol and the multipliers selected, should the stock hit the stop loss price.
For Example, lets assume these values are true:
Account size = $10,000,
Max Risk = 1% of account size
Max Position Size = 25% of the account size
Stock Price = 23.45
ATR = 3.5
ATR Stop Loss Multiplier = 1.4
Then the formulas would be:
ACCT_SIZE * MaxRisk_% = 10000 * .01 = $100 (MaxCashRisk)
-----
MaxCashRisk / (ATR * ATR_SL_MULTIPLIER) = 100 / (3.5 * 1.4) = 20.4 Shares based on Max Cash Risk
-----
(ACCT_SIZE * MaxEquity_%) / STOCK_PRICE = (10000 * .25) / 23.45 = 106.61 Shares based on Max Equity Allocation
The minimum value of each of those options is then used, which in this case would be to purchase 20 shares so as not to exceed the max dollar risk should the stock reach the stop loss target. Likewise, if the ATR were to be much lower, say 0.48 cents, and all else the same, then the strategy would purchase the 106 shares based on Max Equity Allocation because the Max Cash Risk would require 149.25 shares.
MOVING AVERAGE OPTIONS
Select between and change the length & type of up to 5 pairs (10 total) of moving averages
The "Show Cloud-x" option will display a fill color between the "a" and "b" pairs
All moving averages lines can be toggled on/off in the "Style" tab, as well as adjusting their colors.
Visualization features do not affect calculations, meaning you could have all or nothing on the chart and the strategy will still produce results
SIGNAL CHOICES
Choose the fast/shorter length MA and the medium/longer length MA to determine the entry signal
CONFIRMATION OPTIONS
Both of these have customizable values and can be toggled on/off
A candle close over a slower/much longer length moving average
An additional cross-over (cross-under for Shorts) on the MACD indicator using default MACD values. While the MACD indicator is not necessary to have on the chart, it can help to add that for visualization. The calculations will perform whether the indicator is on the chart or not.
EARLY EXIT CRITERIA
Both can be toggled on/off with customizable values
MA Cross Exit will exit the trade early if the select moving averages cross-under (for longs) or cross-over (for shorts), indicating a potential reversal.
Max Bars in Trades will act as a last-resort exit by simply calculating the amount of full bars the trade has been open, and exiting on the opening of the next bar. For example: the default value is 8 bars, so after 8 full bars in the trade, if no other exit has been triggered (Stop Loss, Take Profit, or MA Cross(if enabled)), then the trade will exit at the opening of the 9th bar.
Finally, there is a table displaying the amount of trades taken for each side, and the amount & percent of both early exits. This table can be turned off in the "Style" tab
ADDITIONAL PLOTS
MACD (Moving Average Convergence/Divergence):
- The MACD is an optional confirmation indicator for this strategy.
- Plotting the indicator is not necessary for the strategy to work, but it can be helpful to visually see the status and position of the MACD if this feature is enabled in the strategy
- This helps to identify if there is also momentum behind the entry signal
Crossunder
Multi-X by HamidBoxHello to All, introducing Multi Types Crossover strategy,
simply the best way of trading with Crossover and Crossunder Strategy, How it Works???
I added 5 types of Moving Averages,
1: Simple Moving Average ( SMA )
2: Exponential Moving Average ( EMA )
3: Weighted Moving Average ( WMA )
4: Volume Weighted Moving Average ( VWMA )
5: Relative Moving Average (RMA)
With this indicator, you can do scalping, You can trade not only with similar types of Moving Average indicators but also with different types of Moving Average indicators.
what is mean? like: Normal Condition is:
( Simple Moving Average ) Crossover to ( Simple Moving Average ), SMA x SMA
( Exponential Moving Average ) Crossover to ( Exponential Moving Average ), EMA x EMA
But we can Crossover with:
( Exponential Moving Average ) Crossover to ( Simple Moving Average ), EMA x SMA
( Simple Moving Average ) Crossover to ( Weighted Moving Average ), SMA x WMA
( Weighted Moving Average ) Crossover to ( Weighted Moving Average ), WMA x WMA
( Simple Moving Average ) Crossover to (Relative Moving Average), WMA x RMA
and also I added Moving Average ZONE in this tool, What does it work???
The zone will tell us what type of direction the market has, if the market is above the zone, it's mean we have a Bullish Trend, and if the market is below the zone, it means the market has a Bearish Trend,
so if you want to play on the safe side, never trade when the market is in Bearish Trend, and if you want to play on aggressive mood, you can skip Moving Average Zone section.
EMA StrategyThis is a simple EMA cross strategy. This script was published by CaptJava. I added in the ability to check off a box and allow shorting, the ability to select a back testing date range and also the ability to enter the buy message and sell message in the properties. You then create the webhook alert and put only this in the message:
{{strategy.order.alert_message}}
That will pull in your alert message dynamically.
I may add more features to this over time.
RSI Cross [xaurr]This is simple but profitable rsi cross strategy, to find optimal values you can change rsi and ema periods.
Good Luck!
Bitlinc MARSI Study AST w/ Take Profit & Stop loss - beta 0.1This script is beta 0.1 - will update as soon as the script is tradable
This script is based on AST on a 10 minute timeframe. You can change the asset and the timeframe for any asset you want to trade, but for it to work correct ALL settings have to be testes in the Strategy section of the TradingView. Each assets and timeframe require a different mixture of settings. This is NOT a one settings fits all trading for all assets on any timeframe. Below are the settings and explanation on how it works.
How it fires a buy / sell:
The script will plot an RSI with upper and lower bands in a separate indicator window. The idea behind this script is to fire a LONG when MA crosses OVER lower band and fire a SHORT when the MA crosses under the lower band. Each order that fires is an OCO (Order Cancels Order) for pyramiding.
Settings:
You have full control of these settings as mentioned above, you must configure every part of this script for each asset and timeframe you trade.
- Length of MA
- Length
- Upper bands of RSI
- Lower bands of RSI
- Take profit percentage
- Stop loss percentage
- Month to start and end the strategy (within 2020)
- Day to start and end the strategy (within 2020)
- Quantity type
- Slippage
- Pyramiding
***Remember that after the signal to enter or exit a trade is fired, the alert will trigger AFTER the close of the candle that caused the tigger to fire
Cross impro test by Canundo Crossover Crossunder Tick valuesThis is a script where I tried to check the following things:
Even thought the tick of an asset is, for example 0.5, there are calculated prices, like SMA's that have even more decimals. Leading to crosses happening that for example happen at the same price. Consequently triggering totally useless in side markets. What happens if SMA values are restricted to the tick resolution? (Option works on it's own or with a combination of the others.)
What happens if I set my own tick value, like 0.8 instead of 0.5, what will be the effect for calculated values that are used for crossings? Will tick sizes improve the success rate? (This option will work only when the first option is active.)
Can success rate, especially for sideway markets be improved when adding a spread between MA's, so that it triggers less in sideway markets? (Option works on it's own or with a combination of the others.)
First of all, I had a hard time to round prices properly when it needs to be dynamic and working for different assets with different amounts of decimal values in the tick. The solution is that abs(floor(syminfo.mintick)) will give you the amount of decimals a tick has. It works for all ticks that are at least lower than 10. I'm not sure how huge ticks are out there. I did not implement this solution at the end since I found another way to test it.
Findings:
The first option, when activated, takes out half the trades and raises the percent profitability by 8% so there is some effect. However, all of the tested options have less advantage than I hoped for but are nevertheless something worthy for sideway markets. The first option just forces the MA's from the example to use the tick resolution.
See these two images. One when the first option is off, the second when it's active.
The lines are the MA's with adjusted values, the crosses are the places of the MA's when left as is.
Here a screenshot of the third option set to the value 2 on the 1 minute XBTUSD chart.
The advantage is that less trades trigger that have a low change in price and so less trading fees will happen.
The disadvantage is that all options can implement some delay for a crossing since the crossing will trigger once a slightly bigger move into the direction was taken.
This test environment was not meant to be profitable but to test the effects.
Maybe someone finds it interesting or wanted to test the same, so here you can save some work.
EMA Crossover StrategyEMA Crossover Strategy
This strategy will enter a long trade when the 21 EMA crosses over the 55 EMA and both EMAs and the close price are above the 200 EMA (long-term trend).
It will enter a short trade when the 21 EMA crosses under the 55 EMA and both EMAs and the close price are below the 200 EMA.
It will exit a long trade when the RSI crosses under from overbought and indicates that the uptrend could be coming to an end.
It will exit a short trade when the RSI crosses over from oversold and indicates that the downtrend could be coming to an end.
Backtesting shows that it works best on:
30 MIN:
SYMBOL - PROFIT FACTOR
AUDCAD - 1.126
EURJPY - 1.12
EURNZD - 1.04
EURUSD - 1.65
GBPAUD - 1.27
USDCAD - 1.08
1 HR:
SYMBOL - PROFIT FACTOR
CADJPY- 1.23
EURNZD- 1.166
GBPJPY- 1.23
GBPUSD- 1.282
NZDJPY- 1.246
USDCHF- 1.344
3 HR:
SYMBOL - PROFIT FACTOR
CADCHF- 1.975
EURGBP- 1.776
EURNZD- 1.911
GBPAUD- 1.364
GBPCHF- 1.311
USDJPY- 1.162
XAUUSD - 2.00
As always, this strategy does not guarantee you to achieve profits and you should always use confirmations before entering a trade.
McGinley Dynamic Indicator This is a strategy based on the Mcginley Dynamic Moving Average indicator, a type of moving average that was designed to track the market better than existing moving average indicators. It is a technical indicator that improves upon moving average lines by adjusting for shifts in market speed.
Moving averages used:
EMA: 21
EMA: 42
The chart used for the backtest was the Bovespa Futures Index ( WIN1! Continuous: current contract in front )
150MA Cross BuyAndSell Strategy [d3nv3r]This is a Buy And Sell Strategy I haven't seen anywhere so i share mine.
Used on Bitcoin - daily chart - the strategy generate sell and buy indicator on crossover and crossunder the 150 simple moving average.
Scripting Tutorial 9 - TManyMA Strategy - Long Market Order OnlyThis script is for a triple moving average strategy where the user can select from different types of moving averages, price sources, lookback periods and resolutions.
Features:
- 3 Moving Averages with variable MA types, periods, price sources, resolutions and the ability to disable each individually
- Crossovers are plotted on the chart with detailed information regarding the crossover (Ex: 50 SMA crossed over 200 SMA )
- Forecasting available for all three MAs. MA values are forecasted 5 values out and plotted as if a continuation to the MA.
- Forecast bias also applies to all forecasting. Bias means we can forecast based on an anticipated bullish, bearish or neutral direction in the market.
- To understand bias, please read the source code, or if you can't read the code just send me a message on here or Twitter. Twitter should be linked to my profile.
- Ribbons added and on by default. Optional setting to disable the ribbons. 5 ribbons between MA1 and MA2 and another 5 between MA2 and MA3.
- Ribbons are alpha-color coded based on their relation to their default MAs.
- Ribbons are only visible between MAs if the MAs being compared share the same Type, Resolution, and Source because there is no way to consolidate those three in a simple manner.
- Ribbon values are calculated based on calculated MA Periods between the MAs.
- Converted the existing study into a strategy
- Strategy only enters long positions with a market order when MA crossovers occur
- Strategy exits positions when crossunders occur
- Trades 100% of the equity with one order/position by default
- Ability to disable trading certain crosses with input checks
This script is meant as an educational script with well-formatted styling, and references for specific functions.
*** PLEASE NOTE - THIS STRATEGY IS MEANT FOR LEARNING PURPOSES. DEPENDING ON IT'S CONFIGURATION IT MAY OR MAY NOT BE USEFUL FOR ACTUAL TRADING. THE STRATEGY IS NOT FINANCIAL ADVICE ***
Renko Strategy with Ema against price crossover/underRenko Strategy with Ema against price crossover/under
Help Requested - "Time-Slot" Delay for Crossover StrategyHello Tradingview Community,
I've been playing around with some various volume-based indicators, and recently have been experiencing a delay in the entries for my strategy for 2 minutes in this scenario. If the time is adjusted, it also is delayed 2 bars.
In this example, the "Short" position should enter when the blue line Crosses under the upper green line, and visa vera for the "Long" position. A simplified Pine Script is available below as well.
I have Googled this issue and attempted to modify the code with => criteria instead, but too no avail. Would appreciate any help or anyone who could point me in the right direction on this Time Delay Issue. Thanks!