Three moving average strategies
If the short term (Default 7) moving average cuts the medium term (default 25) moving average, BUY. Conversely, it generates the SELL signal. If the long term (Default 99) moving average cuts its short term moving average, Quick SELL. Conversely, it can be interpreted as Fast SELL. You can change the moving average and the number of days as you wish, and you can trade in the short or long term. I hope it was useful.
Схождение/расхождение скользящих средних (MACD)
MACD Crossover trend strategy, Long and ShortHey everybody,
This is my first strategy and script I wrote mostly myself. There's tons of content out there to learn how to code in Pinescript and it's exactly what I wanted and needed in this time of my life.
In any case, I made a rather simple MACD crossover strategy that only takes trades in the direction of both EMA and SMA (there are inputs to change the length of the moving averages and lots of other stuff too).
If the MACD line crosses upwards on the signal line, while above the zero point of the histogram and the price is above EMA + SMA , it's a long signal.
If the MACD line cosses downards on the signal line, while below zero on the histogram and the price is below EMA + SMA , it's a short signal.
There are a lot of default variables that make no sense, for basically any symbol you're going to be looking at. You're going to have to adjust the EMA , SMA , backtest date, take profit, stop loss and all that good stuff yourself to find decently profitable parameters.
I made this myself because I couldn't really find a strategy out there that allowed for so much customizing and it's an easy way to get started in Pinescript.
If you have any suggestions, tips or you see a flatout mistake in my code, please let me know. I'm still learning, everyday and I'm enjoying every second of it.
Momentum Strategy (BTC/USDT; 1h) - MACD (with source code)Good morning traders.
It's been a while from my last publication of a strategy and today I want to share with you this small piece of script that showed quite interesting result across bitcoin and other altcoins.
The macd indicator is an indicator built on the difference between a fast moving average and a slow moving average: this difference is generally plottted with a blue line while the orange line is simply a moving average computed on this difference.
Usually this indicator is used in technical analysis for getting signals of buy and sell respectively when the macd crosses above or under its moving average: it means that the distance of the fast moving average (the most responsive one) from the slower one is getting lower than what it-used-to-be in the period considered: this could anticipate a cross of the two moving averages and you want to anticipate this potential trend reversal by opening a long position
Of course the workflow is specularly the same for opening short positions (or closing long positions)
What this strategy does is simply considering the moving average computed on macd and applying a linear regression on it: in this way, even though the signal can be sligthly delayed, you reduce noise plotting a smooth curve.
Then, it simply checks the maximums and the minimums of this curve detecting whenever the changes of the values start to be negative or positive, so it opens a short position (closes long) on the maximum on this curve and it opens a long position (closes short) on the minimum.
Of course, I set an option for using this strategy in a conventional way working on the crosses between macd and its moving average. Alternatively you can use this workflow if you prefer.
In conclusion, you can use a tons of moving averages: I made a function in pine in order to allw you to use any moving average you want for the two moving averages on which the macd is based or for the moving average computed on the macd
PLEASE, BE AWARE THAT THIS TRADING STRATEGY DOES NOT GUARANTEE ANY KIND OF SUCCESS IN ADVANCE. YOU ARE THE ONE AND ONLY RESPONSIBLE OF YOUR OWN DECISIONS, I DON'T TAKE ANY RESPONSIBILITY ASSOCIATED WITH THEM. IF YOU RUN THIS STRATEGY YOU ACCEPT THE POSSIBILITY OF LOOSING MONEY, ALL OF MY PUBBLICATIONS ARE SUPPOSED TO BE JUST FOR EDUCATIONAL PURPOSES.
IT IS AT YOUR OWN RISK WHETHER TO USE IT OR NOT
But if you make money out of this, please consider to buy me a beer 😜
Happy Trading!
[KL] BOLL + MACD Strategy v2 (published)This strategy will look for opportunities when price touches the lower Bollinger band, then enters Long when it anticipates a MACD crossover signal.
Setup: on 1-day chart interval
Exits when either (a) hitting trailing stop loss, or (b) meeting risk-to-reward, if defined by user.
Jim's MACDMACD Buy/Sell Strategy
Filters bearish crossovers above the 0 line and bullish crossovers below.
Uses 34 ema to further filter the trades and take only longs above and only shorts below.
Apply at least 2:1 risk to reward ratio to account for losing trades.
Trade at own risk!
MACD 50x Leveraged Strategy Real Equity Simulation Hello, I wrote this script to merge the two scripts I shared before.
The aim here is to see the real value of the state of the capital as a result of leveraged transactions and to combine both long and short directions.
Scripts :
MACD Long 50x Leverage Strategy :
MACD Short 50x Leverage Strategy :
The parameters have not changed so they are the same as the previous two scripts:
Adding margin: Forbidden or not specified. (Add Margin : No)
Position Size : %1 (0.01) (For each trade)
Stop-Loss : %2 (For each trade)
Long : Crossover(delta,0) (Standard MACD)
Long Exit : Long Stop Level or Short Entry
(In the case of Long Stop, all trades are closed and no positions are opened in short direction.)
Short : Crossunder(delta,0) (Standard MACD)
Short Exit : Short Stop or Long Entry
(In the case of Short Stop, all trades are closed and no positions are opened in the long direction.)
NOTE :
This is a simulation made using standard parameters, showing the state of the balance in very simple rules with leveraged transactions only.
The nice thing here is the direct observation of the results by making modifications on the strategy parameters.
Regards.
MACD Price Projected Bands [MPPB] Strategy for NIFTY / BTC 2 minMACD Price Projected Bands is an intraday NON REPAINTING Strategy to be used over BTCUSD and NIFTY on 2mins charts for optimum results!!
How the Strategy works
The strategy uses MACD with standard configuration as its main component.
The adaptive Bands are calculated over the MACD lookback, and MACD crosses of the adaptive bands are projected over the Price for creating a decision logic
A cyclic Trend Filter is used to calculate the Optimum Entry and Exit Points for the Strategy,
Levels are also plotted over the price projected bands for better visualisation of the targets!
What is used !
Macd_config : { fast:12 , slow:26 , signal:9 }
Lookback Length : 55
The Strategy has Provision for Alerts
You get Two signals
1. MPPBS Buy Signal
2. MPPBS Sell Signal
How the Visual Target System Works and How to trade Using this Strategy
An Adaptive Projected Band is constructed using MACD for traders to get Visual inputs regarding targets!!
The Trading Methodologies are in below Charts
For Short Trades
For Long Trades
Strategy Configurations for Backtest
For Englishmen!
The Backtesting Rules in the Strategy calculates only when order gets filled, the basic pyramiding in the strategy is set to 1, i.e The maximum number of entries allowed in the same direction is set to 1,
Also we trade only 1 quantity of the security with initial capital of 100000USD, and The commission type used in the strategy is set to 0.05 USD that means we pay 0.05USD as commissions in every trade!
For Coders!
{
calc_on_order_fills=true,
pyramiding=1,
default_qty_type=strategy.fixed,
default_qty_value=1,
initial_capital=100000,
currency=currency.USD,
commission_type= strategy.commission.cash_per_order,
commission_value = 0.05
}
How can you get access
Only do private message to me, donot use comment box for requesting access!
RSI of MACD Strategy [Long only]This strategy uses the RSI on MACD indicator.
BUY
====
When RSI indicator crossing over 30 or 35 line and price above slow ema
Note: when the position already taken, you may reenter on the purple candle
Partial Exit
==========
Partial profit taking option is available in settings. If this is selected , 1/3 position exited when RSI indicator crossing down 80 line
Close
=====
When RSI indicator crossing below 15
Stop Loss
=========
I havent used hard stop loss in this strategy. Reason is , when price going down , indicator may go up ... so just wanted to ride along with indicator ...
Stop loss mentioned in the settings is used in calculation of how many units can be be purchased based on risk level
Tested with SPY and QQQ ETFs on hourly chart
Warning
=========
For the eductional purposes only ...
This is not a financial advise. please do your own research before taking any trading decission
MACD Strategy (SL/TP Levels and Risk Management)Strategy based on MACD and EMA.
- Risk/Reward Ratio can be adjusted
- SL level can be slightly adjusted (Takes the last low/high as SL)
- Visual representation of SL and TP levels
- Risk management => 1 % max loss on a trade
Combo Backtest 123 Reversal & MACD Crossover with Trail and Stop
This is a modification of @HPotter "Combo Backtest 123 Reversal & MACD Crossover" script.
I've added a trail stop, basic leverage simulation and stop loss.
Below is HPotter's explanation of the script principals.
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
MACD – Moving Average Convergence Divergence. The MACD is calculated
by subtracting a 26-day moving average of a security's price from a
12-day moving average of its price. The result is an indicator that
oscillates above and below zero. When the MACD is above zero, it means
the 12-day moving average is higher than the 26-day moving average.
This is bullish as it shows that current expectations (i.e., the 12-day
moving average) are more bullish than previous expectations (i.e., the
26-day average). This implies a bullish , or upward, shift in the supply/demand
lines. When the MACD falls below zero, it means that the 12-day moving average
is less than the 26-day moving average, implying a bearish shift in the
supply/demand lines.
A 9-day moving average of the MACD (not of the security's price) is usually
plotted on top of the MACD indicator. This line is referred to as the "signal"
line. The signal line anticipates the convergence of the two moving averages
(i.e., the movement of the MACD toward the zero line).
Let's consider the rational behind this technique. The MACD is the difference
between two moving averages of price. When the shorter-term moving average rises
above the longer-term moving average (i.e., the MACD rises above zero), it means
that investor expectations are becoming more bullish (i.e., there has been an
upward shift in the supply/demand lines). By plotting a 9-day moving average of
the MACD , we can see the changing of expectations (i.e., the shifting of the
supply/demand lines) as they occur.
WARNING:
- For purpose educate only
- This script to change bars colors.
Self-Optimising MACD (Experimental)Hi guys, just thought I'd share a small part of an idea i've been working on.
One of the biggest problems with algo trading is optimisation and finding a way to constantly adapt to the market conditions as time unfolds.
First of all... You should NEVER EVER trade just using a MACD, including this study, and I only produced this script in a small amount of time, so make sure you backtest it properly before using it. When backtesting, it is my advice that your sample size should be at least 5000 trades, but I recommend 10000 in order to get sufficient statistical significance.
Also, I am not a financial advisor, and any trading based decisions are your sole responsibility.
Anyways...
This script is simple... it simply uses 4 different MACD's and tracks their profit/loss and automatically uses the one with the most historical profit at any given time to execute a trade. The type of MACD will obviously change as market states fluctuate.
Included are : Hull MACD, Ema MACD, Sma MACD and VWMA Macd.
You can adjust all four of their settings to your desire.
The trade execution is simple and definitely flawed... it simply tracks the MACD when it has a crossover for long, and then the opposite for short.
The green line represents the performance of the top MACD for Longs at any given time. This line refreshes once a year, and where it is in relation to price, reflects how profitable it has been I.e - the higher it is the better.
The Red line represents the performance on the Short side, and again, it reflects profit/loss, but this time the LOWER the line is in relation to price the better.
There is no exit strategy in place! This is why I do NOT recommend trading off this script alone, but to use it as a tool to help optimise your choice of MACD.
However, your exit strategy could change your optimal choice of MACD, so keep that in mind.
The lookback period represents how far the script will track the performance at any given time. This will change your results. The longer the period, the more it will show long term success and vice versa.
This optimisation process could be done with different indicators, moving averages, or even multiple strategies to find the most statistically viable option at any given time... if you wish to have this process coded into your strategies or indicators, message me.
Enjoy.
MACD Crossover Strategy with EMA200 Trend DetectionSimple MACD Strategy Indicator.
Rules:
- MACD Crossover with Signal Line
If
- MACD Crossover above zero line
- Price is below EMA200
=> Sell
If
- MACD Crossover below zero line (buy)
- Price is above EMA200
=> Buy
SmoothOps v1 - StrategyThe purpose of this script was to fine tune an indicator on BTCUSDT. I think the results speak for themselves.
This is a script that uses the MACD to predict future price movement. The original MACD signal lags too much for my taste so I went searching for something that could give signals sooner. I decided a smooth macd would help filter out noise and grabbing the highest values and lowest values over the past number of bars. I spent several days backtesting different settings and combinations of signals to arrive at what you see now. This strategy has been fine tuned for BTC/USDT on Binance, so I suggest you only use it for that. Any other coin/pair and exchange will need a new backtest since the data will be different. This is not a generalized indicator like everything else. It's specifically good at one thing: prediction BTCUSDT on Binance.
Use this in combination with the Study version so you can visually see what is happening when you change settings.
How to use:
Use only on BTCUSDT Binance
Set the preset to the timeframe you want. I HIGHLY suggest only using the 1h timeframe. It gives the best profit over time
Set the preset to custom if you want to try using your own settings.
You can change the source input if you want. ohlc4 usually works best for 1h
Change the date range if you want to do a specific timeframe.
Change the stop loss % if you want, but I didn't find much of a difference when using it on 1h
Renovation-10 (Including 10 Traditional Indicators)This idea is not rare. It is just a combination of 10 most well know and traditional Indicators to form one renovated indicator. There are Moving Average (MA), Volume (V), Bollinger Band (BB), Relative Strength Index ( RSI ), Stochastic RSI, Modified Stochastic RSI, Moving Average Convergence Divergence ( MACD ), Average directional index ( ADX ), Average True Range (ATR) and Parabolic Stop and Reverse (PSAR). These indicators most I found was just showing entering position strategic alone. I just want to know how well them work together when combination. I modified many times and thinking for the strategic enter and exist position with the choice of these 10 indicators to maximize the profitability which shows in strategic tester in every stock and conditions.
THEORY:
Fluctuation of price is like a Wave which I categorized it into four period. They are Sideway, Breakout Positive and Negative, Retracement and Consolidation. Breakout is rare to happen, either go up or go down. After a breakout usually will have small retracement, then trend will go for sideway. After long period of sideway, the wave is starting to run out of energy and there will be consolidation period.
STRATEGIC OPTION:
S: Sideway Period
B: Breakout Period
R: Retracement Period
(+): Buy
(-): Sell
PROBLEM:
1. Not performing very well at very penny stock which the graph looks like barcode.
Suggesting can change daily graph to weekly graph to avoid.
2. Be careful with Sideway entry signal because sometimes price may continue go down. You will stuck at middle if you enter without confirmation.
Confirm the price is stable at support by current low is higher or equal to past three to five day low before entry.
3.Always remember Breakout is rare, do not push for luck
Always make profit at Sideway and Retracement trend. Can Sell half only at BB when breakout buying signal is available, to avoid losing chance of chasing breakout.
4. Breakout selling signal 2 may delay
After breakout, make sure sell all when 2-3 red candle appeared or When BB is squeezing.
5. Other tools may required to confirm entry position.
These combination strategic is more to personal experiences and knowledges, it hard to adjust in coding for strategic position.
This is my first publication and I just do it for fun, having fun in reading the script and creating own ideas.
Information provided is only educational and sharing , should not be used to take action in the markets.
Buy and Sell Signals (With Stops and TP) - No Repaint
This strategy is primarily based on the MACD-indicator, but signals are filtered with the 200 ema.
This indicator gives you for every trade a stopp loss and take profit line.
As with every other strategy risk management is key. The trades taken have all 1.5:1 risk ratios, so when you lose one trade and win one you are still in profit.
This will only work if you calculate your position size accordingly when actually trading!
Without leverage:
position_size = (portfolio * loss_per_trade) / (stop_loss_in_percent )
Leverage:
position_size = (portfolio * loss_per_trade) / (stop_loss_in_percent * leverage)
For example:
portfolio = 100000
loss_per_trade = 0.01 | I only want to lose 1% per trade
stop_loss_in_percent = 0.04 | The stoploss is 4% away from our entry
(100000 * 0.01) / 0.04 = 2500 => if this trade hits my stop, I will only lose 1 % of my portfolio.
This strategy works well with:
BTCUSD 30m
BANDUSDTPERP 5m
EUR DOLLAR 15m
Of course it can be applied to anything, but you should firstly validate the strategy via backtest for the according trading pair and timeframe as it can perform differenlty in various timeframes.
This script does not repaint.
If you are interested in this strategy dm me.
Good luck on your trades!
MACD TRADING SYSTEMThis is a conservative Trend Continuation Trading System.
Uses a Hull Moving Average to determine general trend direction
Uses MACD to initiate Trade entries
Uses a variant of Chaikin Money Flow for volume confirmation
Also uses the Average True Range (ATR) to determine take profit and stoploss.
Stoploss becomes trailing when take profit target has been hit.
I built it mainly for myself to use.
Wanted an objective trading system to take all the emotions out of my trading.
MACD 50x Leveraged Short Strategy with Real Equity
Hello there ,
Short version of the Macd Long strategy.
MACD Long strategy:
Adding margin: Forbidden or not specified. (Add Margin : No)
Position size: (for each trade) 1%
Stop-Loss: (2% Above Entry Level)
Long: macd crossunder
Exit: macd crossover
Or ofc touching the stop-Loss value as predicted.
These strategies are just examples.
The goal is to observe true equity and equity change.
Warning: This strategy simulation is for Short direction only.
Regards.
MACD 50x Leveraged Long Strategy Results with Real Equity Hello there.
I was looking for a way to simulate leveraged transactions in Tradingview and this script came out.
You can examine the equity graph without looking at the strategy results.
Thus, the facts will come to light.
Strategy parameters:
Adding margin: Forbidden or not specified. (Add Margin : No)
Position size: (for each trade) 1%
Stop-Loss: (2%)
Long: macd crossover
Exit: macd crossunder
Or ofc touching the stop-Loss value as predicted.
Warning: This strategy simulation is for Long direction only.
Regards.
MACD Strategy with trailing ATR stopThis is a trend based strategy that uses EMA and SMA intersection for determining the direction of the trend and MACD for the entry signal. At the same time, the strategy uses ATR, which is working as a trailing stop.
The strategy entry will work when the Trend ribbon will turn green and MACD line will crossover the signal line. This strategy also takes into account the pyramiding and allows to enter the second time if the signal will repeat itself.
There are 3 exit points. The first 10% of the position will be closed when the price will increase by 1%. The second portion of 50% will be closed when the price reaches 5% Take profit target. The remaining 40 % of the position will wait for the exit signal which will occur when the price closes below the ATR line.
The strategy is using a fixed amount in dollars, each time the entry occurs the strategy will enter with 100$ in the order.
The strategy can be applied to other crypto assets. However, they will require input changes.
Best of luck with your trading.
Crypto BOT lower timeframesThis is a crypto bot designed for lower time frames.
Its made of 2 EMA, one fast and one slower . They are combined together with Stochastic, MACD and price action patterns.
For entries we have multiple conditions :
First we check if one of our last 4 closed candles crossed above or below the faster EMA. After that for long, we check that last close is above the fast EMA, that the fast ema is above the slower EMA, at the same time that the histogram from MACD is positive and that we have crossover with the oversold line on stochastic. For the short , the opposite of long.
For exit we have TP/SL mechanic based on price % movement, in this example if the price moved 10% from the initial position it will exit.
BTC and ETH Long strategy - version 2I wrote my first article in May 2020. See below
BTC and ETH Long strategy - version1
After 6 months, it is now time to check the result of my script for the last 6 months.
XBTUSD (4H): 14/05/2020 --> 22/11/2020 = +78% in 4 trades
ETHXBT (4H): 14/05/2020 --> 22/11/2020 = +21% in 9 trades
ETHUSD (4H): 14/05/2020 --> 22/11/2020 = +90% in 6 trades
Using the signals from this strategy to trade manually has shown that this was a bit frustrating because of the low rate of winning trades.
If you have to enter 100 trades and see 75% of them failing and 25% winning, this is frustrating. For sure the strategy makes good money but it is difficult to hold this mentality.
So, I have reviewed and modified it to get a higher winning rate.
After few days of work, tests and validation, I managed to get a wining rate close to 60%.
The key element was also to decrease the number of trades by using a higher time frame. (4H candles instead of 2H candles).
- Entry in position is based on
MACD, EMA (20), SMA (100), SMA (200) moving up
AND EMA (20) > SMA (100)
AND SMA (100) > SMA (200)
- Exit the position if: Stoploss is reached OR EMA (20) crossUnder SMA (100)
The goal of this new script is to be able to follow the signals manually and only make few trades per years.
I have also validated it against some other altcoins where some are giving very good results.
Here are some results for 2020 (from 01/01/2020 until now (22/11/2020). Those results are the one I get when using 4H candles.
ETH/USD: +144% in 8 trades.
BTC/USD: +120% in 7 trades.
ETH/BTC: +33% in 9 trades.
ICX/USD: +123% in 10 trades.
LINK/USD: +155% in 11 trades.
MLN/USD: +388% in 8 trades.
ADA/USD: +180% in 7 trades.
LINK/BTC: +97% in 10 trades.
The best is that above results are without considering compound effect. If you re-invest all gains done in each new trade, this will give you the below results :)
ETH/USD: +189% in 8 trades.
BTC/USD: +260% in 7 trades.
ETH/BTC: +29% in 9 trades.
ICX/USD: +112% in 10 trades.
LINK/USD: +222% in 11 trades.
MLN/USD: +793% in 8 trades.
ADA/USD: +319% in 7 trades.
LINK/BTC: +103% in 10 trades.
As you can see, the results are good and the number of trades for 11 months is not big, which allows the trader to place orders manually.
But still, I'm lazy :), so, I have also coded this strategy in HaasScript language which allows you to automate this strategy using the HaasOnline software specialized in automated crypto trading.
I hope that this strategy will give you ideas or will be the starting point for your own strategy.
Let me know if you need more details.
Amazing strategy for silver -XAGUSD, XAGEUR etcToday I bring an amazing strategy that works for 1h time frames for silver.
Its made of price actions movement combined together with MACD and simple moving average
It does not use neither stop loss/take profit levels. Instead it will always exit at the next candle after it opens a trade.
The rules are the next one :
For short condition : we have a bull candle, and candle is above the moving average, and MACD histogram is > 0 and last high0 and candle close > last high1 and, previus high1 and candle close > last high2
At the same time, viceversa for long condition.
In development terms, this is the formula
long1 = (close > open ) and time_cond and close > out and hist > 0 and hist > hist and high > high and high > high and close > high and close > high and close > high
short1 = (close < open) and time_cond and close < out and hist < 0 and hist < hist and low < low and low < low and close < low and close < low and close < low
But when we enter the trade, we enter in reverse, like lets say we go long -> for this we apply the short1 condition. If we go short we apply the long1 condition.
If you have any questions , please let me know .