MACD + BB + RSI Strategy [Alorse]A very simple and highly effective strategy that combines 3 famous indicators:
MACD
Bollinger Bands
RSI
Entry conditions are:
The MACD line crosses over the signal line.
RSI less than 50
Price below the BB baseline
Exit conditions are:
RSI greater than 70
Closing price higher than the upper BB
Or when the price hits the Stop Loss defined by you (Feature).
Volatility
MACD + DMI Scalping with Volatility Stop by (Coinrule)Trend-following strategies are cool because they allow you to catch potential high returns.
The main limit of such strategies are:
False signals > the asset is not experiencing a strong trend. The strategy gets stuck with a sideways move or, worst, with the beginning of a downtrend.
The sell signal may come later than the actual top, leading in some cases to turn a trade in profit into a loss.
This strategy tries to address these limitations to develop a trading system that optimises the entry and closes trade once the profit achieves a pre-set level.
ENTRY
The trading system uses the MACD and the DMI to confirm when is the best time for buying. Combining these two indicators prevents trading during downtrends and reduces the likelihood of getting stuck in a market with low volatility.
The system confirms the entry when:
The MACD histogram turns bullish.
When the positive DMI is greater than the negative DMI, there are more chances that the asset is trading in a sustained uptrend.
EXIT
The strategy comes with a fixed take profit combined with a volatility stop, which acts as a trailing stop to adapt to the trend's strength. Depending on your long term confidence in the asset, you can edit the fixed take profit to be more conservative or aggressive.
The position is closed when:
The price increases by 3%
The price crosses below the volatility stop.
The best time frame for this strategy based on our backtest is the 3-hr . The 4-hr can work well. In general, this approach suits medium to long term strategies
The strategy assumes each order to trade 30% of the available capital to make the results more realistic. A trading fee of 0.1% is taken into account. The fee is aligned to the base fee applied on Binance, which is the largest cryptocurrency exchange.
Webhook Starter Kit [HullBuster]
Introduction
This is an open source strategy which provides a framework for webhook enabled projects. It is designed to work out-of-the-box on any instrument triggering on an intraday bar interval. This is a full featured script with an emphasis on actual trading at a brokerage through the TradingView alert mechanism and without requiring browser plugins.
The source code is written in a self documenting style with clearly defined sections. The sections “communicate” with each other through state variables making it easy for the strategy to evolve and improve. This is an excellent place for Pine Language beginners to start their strategy building journey. The script exhibits many Pine Language features which will certainly ad power to your script building abilities.
This script employs a basic trend follow strategy utilizing a forward pyramiding technique. Trend detection is implemented through the use of two higher time frame series. The market entry setup is a Simple Moving Average crossover. Positions exit by passing through conditional take profit logic. The script creates ten indicators including a Zscore oscillator to measure support and resistance levels. The indicator parameters are exposed through 47 strategy inputs segregated into seven sections. All of the inputs are equipped with detailed tool tips to help you get started.
To improve the transition from simulation to execution, strategy.entry and strategy.exit calls show enhanced message text with embedded keywords that are combined with the TradingView placeholders at alert time. Thereby, enabling a single JSON message to generate multiple execution events. This is genius stuff from the Pine Language development team. Really excellent work!
This document provides a sample alert message that can be applied to this script with relatively little modification. Without altering the code, the strategy inputs can alter the behavior to generate thousands of orders or simply a few dozen. It can be applied to crypto, stocks or forex instruments. A good way to look at this script is as a webhook lab that can aid in the development of your own endpoint processor, impress your co-workers and have hours of fun.
By no means is a webhook required or even necessary to benefit from this script. The setups, exits, trend detection, pyramids and DCA algorithms can be easily replaced with more sophisticated versions. The modular design of the script logic allows you to incrementally learn and advance this script into a functional trading system that you can be proud of.
Design
This is a trend following strategy that enters long above the trend line and short below. There are five trend lines that are visible by default but can be turned off in Section 7. Identified, in frequency order, as follows:
1. - EMA in the chart time frame. Intended to track price pressure. Configured in Section 3.
2. - ALMA in the higher time frame specified in Section 2 Signal Line Period.
3. - Linear Regression in the higher time frame specified in Section 2 Signal Line Period.
4. - Linear Regression in the higher time frame specified in Section 2 Signal Line Period.
5. - DEMA in the higher time frame specified in Section 2 Trend Line Period.
The Blue, Green and Orange lines are signal lines are on the same time frame. The time frame selected should be at least five times greater than the chart time frame. The Purple line represents the trend line for which prices above the line suggest a rising market and prices below a falling market. The time frame selected for the trend should be at least five times greater than the signal lines.
Three oscillators are created as follows:
1. Stochastic - In the chart time frame. Used to enter forward pyramids.
2. Stochastic - In the Trend period. Used to detect exit conditions.
3. Zscore - In the Signal period. Used to detect exit conditions.
The Stochastics are configured identically other than the time frame. The period is set in Section 2.
Two Simple Moving Averages provide the trade entry conditions in the form of a crossover. Crossing up is a long entry and down is a short. This is in fact the same setup you get when you select a basic strategy from the Pine editor. The crossovers are configured in Section 3. You can see where the crosses are occurring by enabling Show Entry Regions in Section 7.
The script has the capacity for pyramids and DCA. Forward pyramids are enabled by setting the Pyramid properties tab with a non zero value. In this case add on trades will enter the market on dips above the position open price. This process will continue until the trade exits. Downward pyramids are available in Crypto and Range mode only. In this case add on trades are placed below the entry price in the drawdown space until the stop is hit. To enable downward pyramids set the Pyramid Minimum Span In Section 1 to a non zero value.
This implementation of Dollar Cost Averaging (DCA) triggers off consecutive losses. Each loss in a run increments a sequence number. The position size is increased as a multiple of this sequence. When the position eventually closes at a profit the sequence is reset. DCA is enabled by setting the Maximum DCA Increments In Section 1 to a non zero value.
It should be noted that the pyramid and DCA features are implemented using a rudimentary design and as such do not perform with the precision of my invite only scripts. They are intended as a feature to stress test your webhook endpoint. As is, you will need to buttress the logic for it to be part of an automated trading system. It is for this reason that I did not apply a Martingale algorithm to this pyramid implementation. But, hey, it’s an open source script so there is plenty of room for learning and your own experimentation.
How does it work
The overall behavior of the script is governed by the Trading Mode selection in Section 1. It is the very first input so you should think about what behavior you intend for this strategy at the onset of the configuration. As previously discussed, this script is designed to be a trend follower. The trend being defined as where the purple line is predominately heading. In BiDir mode, SMA crossovers above the purple line will open long positions and crosses below the line will open short. If pyramiding is enabled add on trades will accumulate on dips above the entry price. The value applied to the Minimum Profit input in Section 1 establishes the threshold for a profitable exit. This is not a hard number exit. The conditional exit logic must be satisfied in order to permit the trade to close. This is where the effort put into the indicator calibration is realized. There are four ways the trade can exit at a profit:
1. Natural exit. When the blue line crosses the green line the trade will close. For a long position the blue line must cross under the green line (downward). For a short the blue must cross over the green (upward).
2. Alma / Linear Regression event. The distance the blue line is from the green and the relative speed the cross is experiencing determines this event. The activation thresholds are set in Section 6 and relies on the period and length set in Section 2. A long position will exit on an upward thrust which exceeds the activation threshold. A short will exit on a downward thrust.
3. Exponential event. The distance the yellow line is from the blue and the relative speed the cross is experiencing determines this event. The activation thresholds are set in Section 3 and relies on the period and length set in the same section.
4. Stochastic event. The purple line stochastic is used to measure overbought and over sold levels with regard to position exits. Signal line positions combined with a reading over 80 signals a long profit exit. Similarly, readings below 20 signal a short profit exit.
Another, optional, way to exit a position is by Bale Out. You can enable this feature in Section 1. This is a handy way to reduce the risk when carrying a large pyramid stack. Instead of waiting for the entire position to recover we exit early (bale out) as soon as the profit value has doubled.
There are lots of ways to implement a bale out but the method I used here provides a succinct example. Feel free to improve on it if you like. To see where the Bale Outs occur, enable Show Bale Outs in Section 7. Red labels are rendered below each exit point on the chart.
There are seven selectable Trading Modes available from the drop down in Section 1:
1. Long - Uses the strategy.risk.allow_entry_in to execute long only trades. You will still see shorts on the chart.
2. Short - Uses the strategy.risk.allow_entry_in to execute short only trades. You will still see long trades on the chart.
3. BiDir - This mode is for margin trading with a stop. If a long position was initiated above the trend line and the price has now fallen below the trend, the position will be reversed after the stop is hit. Forward pyramiding is available in this mode if you set the Pyramiding value in the Properties tab. DCA can also be activated.
4. Flip Flop - This is a bidirectional trading mode that automatically reverses on a trend line crossover. This is distinctively different from BiDir since you will get a reversal even without a stop which is advantageous in non-margin trading.
5. Crypto - This mode is for crypto trading where you are buying the coins outright. In this case you likely want to accumulate coins on a crash. Especially, when all the news outlets are talking about the end of Bitcoin and you see nice deep valleys on the chart. Certainly, under these conditions, the market will be well below the purple line. No margin so you can’t go short. Downward pyramids are enabled for Crypto mode when two conditions are met. First the Pyramiding value in the Properties tab must be non zero. Second the Pyramid Minimum Span in Section 1 must be non zero.
6. Range - This is a counter trend trading mode. Longs are entered below the purple trend line and shorts above. Useful when you want to test your webhook in a market where the trend line is bisecting the signal line series. Remember that this strategy is a trend follower. It’s going to get chopped out in a range bound market. By turning on the Range mode you will at least see profitable trades while stuck in the range. However, when the market eventually picks a direction, this mode will sustain losses. This range trading mode is a rudimentary implementation that will need a lot of improvement if you want to create a reliable switch hitter (trend/range combo).
7. No Trade. Useful when setting up the trend lines and the entry and exit is not important.
Once in the trade, long or short, the script tests the exit condition on every bar. If not a profitable exit then it checks if a pyramid is required. As mentioned earlier, the entry setups are quite primitive. Although they can easily be replaced by more sophisticated algorithms, what I really wanted to show is the diminished role of the position entry in the overall life of the trade. Professional traders spend much more time on the management of the trade beyond the market entry. While your trade entry is important, you can get in almost anywhere and still land a profitable exit.
If DCA is enabled, the size of the position will increase in response to consecutive losses. The number of times the position can increase is limited by the number set in Maximum DCA Increments of Section 1. Once the position breaks the losing streak the trade size will return the default quantity set in the Properties tab. It should be noted that the Initial Capital amount set in the Properties tab does not affect the simulation in the same way as a real account. In reality, running out of money will certainly halt trading. In fact, your account would be frozen long before the last penny was committed to a trade. On the other hand, TradingView will keep running the simulation until the current bar even if your funds have been technically depleted.
Entry and exit use the strategy.entry and strategy.exit calls respectfully. The alert_message parameter has special keywords that the endpoint expects to properly calculate position size and message sequence. The alert message will embed these keywords in the JSON object through the {{strategy.order.alert_message}} placeholder. You should use whatever keywords are expected from the endpoint you intend to webhook in to.
Webhook Integration
The TradingView alerts dialog provides a way to connect your script to an external system which could actually execute your trade. This is a fantastic feature that enables you to separate the data feed and technical analysis from the execution and reporting systems. Using this feature it is possible to create a fully automated trading system entirely on the cloud. Of course, there is some work to get it all going in a reliable fashion. Being a strategy type script place holders such as {{strategy.position_size}} can be embedded in the alert message text. There are more than 10 variables which can write internal script values into the message for delivery to the specified endpoint.
Entry and exit use the strategy.entry and strategy.exit calls respectfully. The alert_message parameter has special keywords that my endpoint expects to properly calculate position size and message sequence. The alert message will embed these keywords in the JSON object through the {{strategy.order.alert_message}} placeholder. You should use whatever keywords are expected from the endpoint you intend to webhook in to.
Here is an excerpt of the fields I use in my webhook signal:
"broker_id": "kraken",
"account_id": "XXX XXXX XXXX XXXX",
"symbol_id": "XMRUSD",
"action": "{{strategy.order.action}}",
"strategy": "{{strategy.order.id}}",
"lots": "{{strategy.order.contracts}}",
"price": "{{strategy.order.price}}",
"comment": "{{strategy.order.alert_message}}",
"timestamp": "{{time}}"
Though TradingView does a great job in dispatching your alert this feature does come with a few idiosyncrasies. Namely, a single transaction call in your script may cause multiple transmissions to the endpoint. If you are using placeholders each message describes part of the transaction sequence. A good example is closing a pyramid stack. Although the script makes a single strategy.close() call, the endpoint actually receives a close message for each pyramid trade. The broker, on the other hand, only requires a single close. The incongruity of this situation is exacerbated by the possibility of messages being received out of sequence. Depending on the type of order designated in the message, a close or a reversal. This could have a disastrous effect on your live account. This broker simulator has no idea what is actually going on at your real account. Its just doing the job of running the simulation and sending out the computed results. If your TradingView simulation falls out of alignment with the actual trading account lots of really bad things could happen. Like your script thinks your are currently long but the account is actually short. Reversals from this point forward will always be wrong with no one the wiser. Human intervention will be required to restore congruence. But how does anyone find out this is occurring? In closed systems engineering this is known as entropy. In practice your webhook logic should be robust enough to detect these conditions. Be generous with the placeholder usage and give the webhook code plenty of information to compare states. Both issuer and receiver. Don’t blindly commit incoming signals without verifying system integrity.
Setup
The following steps provide a very brief set of instructions that will get you started on your first configuration. After you’ve gone through the process a couple of times, you won’t need these anymore. It’s really a simple script after all. I have several example configurations that I used to create the performance charts shown. I can share them with you if you like. Of course, if you’ve modified the code then these steps are probably obsolete.
There are 47 inputs divided into seven sections. For the most part, the configuration process is designed to flow from top to bottom. Handy, tool tips are available on every field to help get you through the initial setup.
Step 1. Input the Base Currency and Order Size in the Properties tab. Set the Pyramiding value to zero.
Step 2. Select the Trading Mode you intend to test with from the drop down in Section 1. I usually select No Trade until I’ve setup all of the trend lines, profit and stop levels.
Step 3. Put in your Minimum Profit and Stop Loss in the first section. This is in pips or currency basis points (chart right side scale). Remember that the profit is taken as a conditional exit not a fixed limit. The actual profit taken will almost always be greater than the amount specified. The stop loss, on the other hand, is indeed a hard number which is executed by the TradingView broker simulator when the threshold is breached.
Step 4. Apply the appropriate value to the Tick Scalar field in Section 1. This value is used to remove the pipette from the price. You can enable the Summary Report in Section 7 to see the TradingView minimum tick size of the current chart.
Step 5. Apply the appropriate Price Normalizer value in Section 1. This value is used to normalize the instrument price for differential calculations. Basically, we want to increase the magnitude to significant digits to make the numbers more meaningful in comparisons. Though I have used many normalization techniques, I have always found this method to provide a simple and lightweight solution for less demanding applications. Most of the time the default value will be sufficient. The Tick Scalar and Price Normalizer value work together within a single calculation so changing either will affect all delta result values.
Step 6. Turn on the trend line plots in Section 7. Then configure Section 2. Try to get the plots to show you what’s really happening not what you want to happen. The most important is the purple trend line. Select an interval and length that seem to identify where prices tend to go during non-consolidation periods. Remember that a natural exit is when the blue crosses the green line.
Step 7. Enable Show Event Regions in Section 7. Then adjust Section 6. Blue background fills are spikes and red fills are plunging prices. These measurements should be hard to come by so you should see relatively few fills on the chart if you’ve set this up as intended. Section 6 includes the Zscore oscillator the state of which combines with the signal lines to detect statistically significant price movement. The Zscore is a zero based calculation with positive and negative magnitude readings. You want to input a reasonably large number slightly below the maximum amplitude seen on the chart. Both rise and fall inputs are entered as a positive real number. You can easily use my code to create a separate indicator if you want to see it in action. The default value is sufficient for most configurations.
Step 8. Turn off Show Event Regions and enable Show Entry Regions in Section 7. Then adjust Section 3. This section contains two parts. The entry setup crossovers and EMA events. Adjust the crossovers first. That is the Fast Cross Length and Slow Cross Length. The frequency of your trades will be shown as blue and red fills. There should be a lot. Then turn off Show Event Regions and enable Display EMA Peaks. Adjust all the fields that have the word EMA. This is actually the yellow line on the chart. The blue and red fills should show much less than the crossovers but more than event fills shown in Step 7.
Step 9. Change the Trading Mode to BiDir if you selected No Trades previously. Look on the chart and see where the trades are occurring. Make adjustments to the Minimum Profit and Stop Offset in Section 1 if necessary. Wider profits and stops reduce the trade frequency.
Step 10. Go to Section 4 and 5 and make fine tuning adjustments to the long and short side.
Example Settings
To reproduce the performance shown on the chart please use the following configuration: (Bitcoin on the Kraken exchange)
1. Select XBTUSD Kraken as the chart symbol.
2. On the properties tab set the Order Size to: 0.01 Bitcoin
3. On the properties tab set the Pyramiding to: 12
4. In Section 1: Select “Crypto” for the Trading Model
5. In Section 1: Input 2000 for the Minimum Profit
6. In Section 1: Input 0 for the Stop Offset (No Stop)
7. In Section 1: Input 10 for the Tick Scalar
8. In Section 1: Input 1000 for the Price Normalizer
9. In Section 1: Input 2000 for the Pyramid Minimum Span
10. In Section 1: Check mark the Position Bale Out
11. In Section 2: Input 60 for the Signal Line Period
12. In Section 2: Input 1440 for the Trend Line Period
13. In Section 2: Input 5 for the Fast Alma Length
14. In Section 2: Input 22 for the Fast LinReg Length
15. In Section 2: Input 100 for the Slow LinReg Length
16. In Section 2: Input 90 for the Trend Line Length
17. In Section 2: Input 14 Stochastic Length
18. In Section 3: Input 9 Fast Cross Length
19. In Section 3: Input 24 Slow Cross Length
20. In Section 3: Input 8 Fast EMA Length
21. In Section 3: Input 10 Fast EMA Rise NetChg
22. In Section 3: Input 1 Fast EMA Rise ROC
23. In Section 3: Input 10 Fast EMA Fall NetChg
24. In Section 3: Input 1 Fast EMA Fall ROC
25. In Section 4: Check mark the Long Natural Exit
26. In Section 4: Check mark the Long Signal Exit
27. In Section 4: Check mark the Long Price Event Exit
28. In Section 4: Check mark the Long Stochastic Exit
29. In Section 5: Check mark the Short Natural Exit
30. In Section 5: Check mark the Short Signal Exit
31. In Section 5: Check mark the Short Price Event Exit
32. In Section 5: Check mark the Short Stochastic Exit
33. In Section 6: Input 120 Rise Event NetChg
34. In Section 6: Input 1 Rise Event ROC
35. In Section 6: Input 5 Min Above Zero ZScore
36. In Section 6: Input 120 Fall Event NetChg
37. In Section 6: Input 1 Fall Event ROC
38. In Section 6: Input 5 Min Below Zero ZScore
In this configuration we are trading in long only mode and have enabled downward pyramiding. The purple trend line is based on the day (1440) period. The length is set at 90 days so it’s going to take a while for the trend line to alter course should this symbol decide to node dive for a prolonged amount of time. Your trades will still go long under those circumstances. Since downward accumulation is enabled, your position size will grow on the way down.
The performance example is Bitcoin so we assume the trader is buying coins outright. That being the case we don’t need a stop since we will never receive a margin call. New buy signals will be generated when the price exceeds the magnitude and speed defined by the Event Net Change and Rate of Change.
Feel free to PM me with any questions related to this script. Thank you and happy trading!
CFTC RULE 4.41
These results are based on simulated or hypothetical performance results that have certain inherent limitations. Unlike the results shown in an actual performance record, these results do not represent actual trading. Also, because these trades have not actually been executed, these results may have under-or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated or hypothetical trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to these being shown.
RSI Rising Crypto Trending StrategyThis is crypto and stock market trending strategy designed for long timeframes such as 4h+
From my tests it looks like it works better to trade crypto against crypto than trading against fiat.
Indicators used:
RSI for rising/falling of the trend
BB sidemarket
ROC sidemarket
Rules for entry
For long: RSI values are rising, and bb and roc tells us we are not in a sidemarket
For long: RSI values are falling, and bb and roc tells us we are not in a sidemarket
Rules for exit
We exit when we receive an opposite direction.
Cuation: Because this strategy uses no risk management, I recommend you takje care with it.
If you have any questions, let me know !
MarketGod for Tradingview(strategy)Fully Open Source Tv Market God Strategy. Good Luck
Strategy Description
MarketGod can be applied to any market, with any time-frame associated to it. The signals relay the alert at the close of the period, and the painted alert is then available to users to see on the chart or even set notifications for via tradingview's alert system. We recommend that users implement marketgod on their preferred time frames for trading, which for us is the 1h, 4h, 6h, 1D and above TFs.
MarketGod Versioning
The versions included with this release are the following
MarketGod v1
MarketGod v2
MarketGod v3
MarketGod v4
MarketGod v5
MarketGod v6
MarketGod v7
MarketGod v8
MarketGodx²
Ichimoku God
Suggested Uses
• MarketGod will inevitably produce false positives. We've taken steps to reduce this but we highly suggest you add this as a component of your strategy, not an end all be all
• That said, please do not feel the need to fire a trade based solely on a marketgod signal, or to every signal it fires.
• MarketGod users should backtest their strategy using OHLC candles for best results
• Heikin Ashi candles were recomended in the past, and we have eliminated the need for them, meaning that traditional candlestick inputs will yield the highest results.
• MarketGod will always give stronger alerts on higher TF's. If the 1-Day has fired a given signal and the 30 min or similar fire the opposite signal, know that the overall trend is still likely downward. Same concept applies to all timeframes on this tool.
Adjusting the Filter Settings
This tool has a noise filter for users to adjust.
The filter is a percentage based calculation, between significant points in time. The filter ranges between .5 and 25, with .5 increments
• For lower TFs ( IE Intraday), keep the filter set between .5-5
• Mid-TFs (4H,6H,12H,1D), the recommended range is between 5.5-10
• Higher TFs (3D and Higher), look for approx 11-20 range
Customizations
Customize the indicator by adjusting the colors in the style pane. Additionally, users can change the plots into labels with the price of close added to them, or a few other label text options, listed in the 'inputs' panel, below the filter adjustments. Users can also opt to turn the strategy orders as well, as this version will have them printed.
Strategy Performance Interpretation
Its important to understand the only metric that should be relevant is not the win %, as many may initially think. Alternatively, the only metric that matters in the end is your take home profit... meaning the profit one fees and taxes are accounted for. In our example here, the % brought back since the beginning of our window of 2018 is around 47% for $10,000 initial capital and 10% traded per position. Many are ignorant to the take home profit aspect as they focus solely on the winning %, which is ultimately incorrect approach to trading as a whole. as long as we maintain +30% (our goal minimum), the outcome being in the green, is our goal.
Initial templateI have created a starting template for strategies.
It allows quick control of turning on/off long and short conditions, or disabling them entirely.
It includes trade filters for strategy equity and volatility. If there is not enough volatility it will not trade, or if the strategy equity is below the equity ema it will not trade.
It has standard stops and limits.
Simply change the long/short conditions!
[KL] Mean Reversion (ATR) StrategyThis strategy will enter into a position when price volatility is relative high, betting that price will subsequently trend in a favourable direction.
Hypothesis : During periods of high price volatility, ATR will divert from its moving average by at least +/- one standard deviation. Eventually, ATR will revert back to the mean. However, just knowing the magnitude of increase/decrease of ATR does not give a trend signal, so we need to introduce a model in this script to predict whether the next bars will be up/down.
Trend Prediction : This strategy calculates the expected logarithmic return of the security (the "Drift") and considers prices to be moving in uptrend if the drift curve is upward sloping or if the drift value is positive.
Entry Conditions : Long position is entered when:
(a) ATR has diverted from mean by one standard deviation, and
(b) trend is predicted to move in our favor.
Exit Condition : When trailing stop loss is hit.
Results from backtesting against VOO (1H timeframe):
- approx 46% win rate over 491 trades, on average holding for 20 hours per trade
- price at the beginning of backtest (Jan. 2015) was $187.52, giving holding period return of ~120% had we not sold in between ("HPR of HODL'ing")
- this strategy gained ~159%, exceeding ~120% HPR of HODL'ing
Bollinger Bands And Aroon Scalping (by Coinrule)Many technical indicators can be profitable in certain market conditions while failing in others. No indicator is perfect alone.
All the best trading strategies involve multiple indicators and leverage the benefit of each of them. The following is an optimised strategy based on Bollinger Bands and the Aroon indicator.
The Bollinger Bands are among the most famous and widely used indicators. They can suggest when an asset is oversold or overbought in the short term, thus provide the best time for buying and selling it.
A strategy buying dips can work well during times of uptrend. Downtrends will result in a drawdown for the P&L of the strategy. The suggested approach minimises the drawdowns, ensuring that the system trades only when it's more likely to close the trade in profit.
The Setup
ENTRY
The price crosses below the basis line of the Bollinger Band indicator
The Aroon Indicator is above 90
EXIT
The price crosses below the upper Bollinger Band
The Aroon Indicator drops below 70
The Aroon Indicator plays a key role in this strategy. It acts as a confirmation that the asset is currently in an uptrend. On the other hand, it acts as a stop if market conditions deteriorate. The strategy uses an Aroon Indicator set to 288 periods to provide a longer-term view on market conditions, not being heavily dependent on short-term volatility.
The best time frame for this strategy based on our backtest is the 4-hr . The 1-hr can work well with three times more trades, on average. As trades increase, the profitability decreases. Yet again, this is the confirmation that trading more does not mean gaining more.
To make the results more realistic, the strategy assumes each order to trade 30% of the available capital. A trading fee of 0.1% is taken into account. The fee is aligned to the base fee applied on Binance, which is the largest cryptocurrency exchange.
[KL] Double Bollinger Bands Strategy (for Crypto/FOREX)This strategy uses a setup consisting of two Bollinger Bands based on the 20 period 20-SMA +/-
(a) upper/lower bands of two standard deviations apart, and
(b) upper/lower bands of one standard deviation apart.
We consider price at +/- one standard deviation apart from 20-SMA as the "Neutral Zone".
If price closes above Neutral Zone after a period of consolidation, then it's an opportunity for entry. Strategy will long, anticipating for breakout.
The illustration below shows price closing above the Neutral Zone after a period of consolidation.
a.c-dn.net
Position is exited when prices closes at Neutral Zone (being lower than prior bars)
SQZ Multiframe StrategyThis is a first attempt to automate what my current strategy when trading is.
It uses 2 timeframes: the one you are currently using to see the chart and an "anchor trend" which is a higher order frame.
Supported timeframes are: 1m, 5m, 15m, 30m, 1H, 4H, 1D, 1W
The Strategy relies on two indicators:
Squeeze Momentum Indicator
CMF
How does it works?
It looks for a moment when the following conditions are met.
For Long:
Positive directionality in SQZM monitor in anchor timeframe
Positive directionality in SQZM monitor in current timeframe
Recent minimum in CMF
For Short:
Negative directionality in SQZM monitor in anchor timeframe
Negative directionality in SQZM monitor in current timeframe
Recent maximum in CMF
After a BUY or SELL order is executed the plot will start showing two lines: A TP line, and a SL line.
The TP and SL move dynamically based on a greedy algorithm based on 3 input parameters.
Min Profit to Start Moving SL (%): Sets an initial target for the trade.
Maximum Possible of SL (%): This is the maximum amount possible for SL. If volatility is not too high, a shorter SL will be chosen based on Kaufman's Stops method
Take profit factor: Is how much portion of the target I am taking as profit once the target is reached
Example for 5% Min profit:
When the first target is reached (+5%), the SL will be updated to 2.5% over the enter price.
When the second target is reached (+10%), the SL will be updated to 5% over the enter price.
Note: The strategy might abandon the position prematurely if a contrary signal is received while the trade is opened, and will change direction.
The Strategy has been backtested mostly for crypto. It might be good for stocks too, but the parameters mentioned might need some adjustments since price moves at a different rate.
Recommended timeframe is 4H for BTC , and 30min/1H for alts.
Comments and ideas are more than welcome!
Qullamaggie Breakout V2After publishing the Qullamaggie Breakout script and seeing that it had some decent results, I wanted to explore it a bit further. There were a few things I didn't like about that methodology that didn't really jive with the way I like to trade. So what I did was combined the Breakout Trend Follower strategy I had been using for entries with the Qullamaggie strategy for trailing stops once in profit. The results seem pretty good to me and an approach that fits my personality and something I can actually trade. Typically better profit than the Breakout Trend Follower by giving more room for your winners to run, while still protecting your entries by moving up the trailing stop until you are in profit, all while taking less trades, so that's great.
Everything is done with stop orders. So you set your buy stop at the recent swing high point and wait for a breakout. Once in a position you set your sell stop at the recent swing low point. The most recent swing high and low are shown on the chart for easy reference with the blue and orange horizontal lines. Once in a trade, trail your sell stop after a new swing low is registered (shown by the thicker orange stop line). Once you are in profit, leave that hard stop level there (the orange line will stay there helping you). Now, you wait for price to cross a Moving Average of your choosing (default is Daily 10 MA). Once the bar crosses that moving average, you move your stop to the low of that candle (shown by the blue stop line) and trail your stop along every crossing of the moving average until the trend changes and takes out your stop. So managing this trade is pretty easy...just wait for the stop lines to move and move your stop with them. It's a great way to trade when you can't be at your computer all the time because the stop orders take care of execution on both buy and sell side. If you use a daily timeframe for your moving averages (the default), you really only need to move stops around about once a day, so is a good part time trader's strategy in my opinion.
The best opportunities will come by scanning for stocks in the longer term timeframe of your moving averages. Wait for a consolidation on that timeframe so the anticipated breakout has some room to run. Once you've identified a good candidate, zoom in to your lower timeframe where the swing highs/lows will act as your entry and exit points, all while keeping the moving averages consistent between timeframes.
Hope you guys find it useful.
A few options available:
- Choose any timeframe for your moving averages, while using swing high/low points on intraday charts.
- Choose one of two moving averages shown for your trailing stops (default 10 and 20 MA).
- Choose to use the third moving average as a filter for keeping you out of trades that are below it (trading with the trend).
- Use the charts resolution candle or the moving average resolution candle for the moving average trailing stop.
- Only take trades where your buy level minus stop level is below a % of the Average Daily Range (ADR). This allows you to potentially have better risk/reward. I added a little table that shows the ADR of the stock/ticker as well as the range between the recent buy and sell levels (shown by the orange and blue horizontal lines) for easy reference.
RebalancingThis script gives you an approximation of the APR you can get when using the technique of Rebalancing.
Further discription are embeded in the script.
HOW TO USE:
- Start date: Choose start date
- Settings: Change settings to your own needs
- Base currency: Select Base currency
- Portfolio: Select the coins (MAX 9 pcs.) you want to use in your portfolio for the rebalancing algoritm
- Click "Data Window" to see the APR (appr.)
Markets:
It can be used to all markets.
NOTE:
Some Exchanges don't go very far back in the past and for this reason this may have impact on this Indicator.
Make sure the coins you selected are available at the Exchange you select in the settings section. If you dont do this, the script generates an error.
Strategy Template - V2This is an educational script created to demonstrate few basic building blocks of a trend based strategy and how to achieve different entry and exit types. My initial intention was to create a comprehensive strategy template which covers all the aspects of strategy. But, ended up creating fully fledged strategy based on trend following.
This is an enhancement on Strategy-Template But this script is comparitively more complex. Hence I decided to create new version instead of updating the existing one.
Lets dive deep.
SIMPLE COMPONENTS OF TREND FOLLOWING STRATEGY
TREND BIAS - This defines the direction of trend. Idea is not to trade against the trend direction. If the bias is bullish, look for long opportunities and if bias is bearish, look for short opportunities. Stay out of the market when the bias is neutral.
Often, trend bias is determined based on longer timeframe conditions. Example - 200 Moving Average, Higher timeframe moving averages, Higher timeframe high-lows etc. can be used for determining the trend bias.
In this script, I am using Weekly donchian channels combined with daily donchian channels to define trend bias.
Long Bias - 40 Day donchian channel sits completely in upper portion of 40 Week dochnial channel.
Short Bias - 40 Day donchian channel sits completely in lower portion of 40 Week donchian channel.
ENTRY CONDITION - Entry signals are generated only in the direction of bias. Hence, when in LongBias, we only get Long signals and when in short bias, we only get short signals.
In our case, when in Long Bias - if price hits 40 day high for the first time, this creates our long entry signal. Similarly when in Short Bias , price hitting 40 day low will create signal for going short. Since we do not take trades opposite to trend, no entry conditions are formed when price hits 40 day high in Short Bias or 40 day low in Long Bias.
EXIT CONDITION - Exit conditions are formed when we get signals of trend failure.
In our case, when in long trade, price hitting 40 day low creates exit signal. Similarly when in short trade price hitting 40 day high creates exit signal for short trade.
DIFFERENT TYPES OF ENTRY AND EXIT
In this script, I have tried to demonstrate different entry and exit types.
Entry types
Market - Enter immediately when entry signal is received. That is, in this case when price crossover over high in long bias and crosses under low in short bias
Stop - This method includes estimating at what level new highs are made and creating a stop buy order at that level. This way, we do not miss if the break out is stronger. But, susciptible to fail during fakeouts.
Limit - This method includes executing a limit order to buy at lower price or sell at higher price. In trend following methods, downside of limit order is when there is genuine breakout, these limit orders may not hit and during trend failures the limit orders are likely to hit and go straight to stop.
Stop-Limit - this is same as stop order but will also place a limit condition to avoid buying on overextended breakout or with lots of slippage.
Exit types
Market - whether to keep the existing trade running or whether to close it is determined after close of each bar and exit orders are executed manually upon receiving exit signal.
Stop - We place stop loss orders beforehand when there is a trade in place. This can help in avoiding big movements against trade within bar. But, this may also stop on false signals or fakeouts.
Take profit
Stop - No take profits are configured.
Target - 30% of the positions are closed when take profit levels are hit. Take profit levels are defined by risk reward.
USING THE CODE AS TEMPLATE
As mentioned earlier, I intended to create a fully fledged strategy template. But, ended up creating a fully fledged stratgy. However, you can take some part of this code and use it to start your own strategy. Will explain what all things can be adopted without worrying about the strategy implementation within
Strategy definition : This can be copied as is and just change the title of strategy. This defines some of the commonly used parameters of strategy which can help with close to realistic backtesting results for your coded strategy and comparison with buy and hold.
Generic Strategy Parameters : The parameter which defines controlling alllowed trade direction and trading window are present here. This again can be copied as is and variable inDateRange can be directly used in entry conditions.
Generic Methods : f_getMovingAverage and f_secureSecurity are handy and can be used as is. atr method provideded by pine gives you ATR based on RMA. If you want SMA or any other moving average based ATR, you can use the method f_getCustomAtr
Trade Statements : This section has all types of trading instructions which includes market/stop/limit/stop-limit type of entries and exits and take profit statements. You can adopt the type of entry you are interested in and change when condition to suit your strategy.
Trade conditions and levels : This section is required. But, cannot be copied. All the trade logic goes here which also sets parameters which are used in when of Trade Statements.
Hope this helps.
Forex Scalping 1min Bollinger Bands, RSI and ADX Trading SystemThis is a Forex Scalping Trading Sytem based on the Bollinger Bands.
Its suited for major pairs, with lowest possible comission (below 1 pip) and with timeframes ranging between 1-15 min.
Indicators:
Bollinger bands
ADX
RSI
Rules for entry:
Long Entry: price to move below the upper Bollinger Bands RSI raise above the 30 line and ADX<32 at the same time.
Short Entry: price to move above the upper Bollinger Bands, RSI raise below the 70 line and ADX<32 at the same time.
Rules for exit
Profit Exit: 3 options: 1, exit position when the price touches the middle band, 2) when the price touches the opposite band, X pips target profit.
Loss Exit: X pips loss
Keltner Channel - Trend Based StrategyThis strategy is based on 3 main indicators.
1st indicator is a trend indicator, which consists of SMA and EMA
2nd is Keltner Channel
3rd is DM indicator.
The conditions for the entry of this strategy are following:
First of all the assets need to be in an upward trend, this will occur when the EMA will cross SMA. The next condition for the entry is the opening and the closure of the candle. The open price of the candle should be in the upper part of the Keltner Channel and the close price should be above the Keltner channel. The third condition for the DM indicator is to be above a certain benchmakr. This benchmark can be set in the settings of the strategy.
The strategy has two potential Take Profit levels and single stop-loss levels. For the more efficient way you may try an use the trailing stop or extend the number of take-profit levels.
Improved Bollinger Swing Strategy Stock NasdaqThis is an improved bollinger band strategy adapted to Nasdaq Index/Stocks.
The new update include a multiple logic calculation BB adapted for long and short, together with a risk management using movement in %.
Rules for entry
For long we have a crossover between the close and the lower band from the bb
For long we have a crossover between the close and the upper band from the bb
Rules for exit
We exit when we either find a reverse condition, or if we hit the take profit/stop loss levels.
If you have any questions, let me know !
Bagheri IG EtherThis is a technical trading strategy for Ethereum ( BINANCE:ETHUSDT ). We built and developed it on MetaEditor and optimized it with MetaTrader optimizer.
The main indicators are Donchian Channel, Oscillator of ROC, Bears Power, Balance of Power, and Simple Moving Average (SMA). Default values in the input panel are the best combination of these indicators, but you can change any of them and try it for better results.
Please notice that this strategy has been optimized on the 1-minute chart of Ethereum.
For each position, you can see the Take Profit (TP) and Stop Loss (SL) levels. Also, you can find the values of mentioned TP and SL in points from the input panel of the script.
Attention: The price of Ethereum has 2 decimal places.
Therefore, 3000 points for TP means 30 USDT for trading 1 BINANCE:ETHUSDT .
[KL] Relative Volume + ATR StrategyThis strategy will enter into long position when (a) current volume is above the average volume, and when (b) volatility of prices (based on ATR) is relatively low.
Backtested on hourly timeframes, win rates range between 35% to 50% on stocks with positive drifts (i.e. tendency to move upwards). Default setups are as follows:
- Average volume is computed using simple moving average (sma) of 14 periods. By default, 1.4x ratio seems to work well on most large cap stocks. If it's too high, then amount of potential points for entry will decrease. But if it's too low, then this indicator becomes meaningless.
- ATR (for determining volatility), look back period is 14 (following conventions). I have noticed that the profits could change drastically when changed to different values for each individually security. Feel free to experiment around with this parameter.
Other information: This strategy is based off of one of my previous scripts; a script called "Relatively Volume Strategy". The objective of this new script is to simplify the process of determining periods of low volatility. In this new script, we assume prices are consolidating when current ATR is within its moving average value by +/- one standard deviation.
3Commas BotBjorgum 3Commas Bot
A strategy in a box to get you started today
With 3rd party API providers growing in popularity, many are turning to automating their strategies on their favorite assets. With so many options and layers of customization possible, TradingView offers a place no better for young or even experienced coders to build a platform from to meet these needs. 3Commas has offered easy access with straight forward TradingView compatibility. Before long many have their brokers hooked up and are ready to send their alerts (or perhaps they have been trying with mixed success for some time now) only they realize there might just be a little bit more to building a strategy that they are comfortable letting out of their sight to trade their money while they eat, sleep, etc. Many may have ideas for entry criteria they are excited to try, but further questions arise... "What about risk mitigation?" "How can I set stop or limit orders?" "Is there not some basic shell of a strategy that has laid some of this out for me to get me going?"
Well now there is just that. This strategy is meant for those that have begun to delve into the world of algorithmic trading providing a template that offers risk defined positions complete with stops, limit orders, and even trailing stops should one so choose to employ any of these criteria. It provides a framework that is easily manipulated (with some basic working knowledge of pine coding) to encompass ones own ideas and entry criteria, while also providing an already functioning strategy.
The default settings have a basic 1:1 risk to reward ratio, which sets a limit and a stop equal distance from the entry. The entry is a simple MA cross (up for long, down for short). There a variety of MA's to choose from and the user can define the lengths of the averages. The ratio can be adjusted from the menu along with a volatility based adder (ATR) that helps to distance a stop from support or resistance. These values are calculated off the swing low/high of the user defined lookback period. Risk is calculated from position entry to stop, and projected upwards to the limit as a function of the desired risk to reward ratio. Of note: the default settings include 0.05% commissions. Competitive commissions of the leading cryptocurrency exchanges are .1% round trip (one buy and one sell) for market orders. There is also some slippage to allow time for alerts to be sent and orders to fill giving the back test results a more accurate representation of real time conditions. Its recommended to research the going rates for your exchange and set them to default for the strategy you use or build.
To get started a user would:
1) Make a copy of the code and paste in their bot keys in the area provided under the "3Comma Keys" section
- eg. Long bot "start deal" copied from 3commas in to define "Long" etc. (code is commented)
2) Place alert on desired asset with desired settings ensuring to select "Order fills and alert() function calls"
3) Paste webhook into the webhook box and select webhook URL alerts (3rd party provided webhook)
3) Delete contents of alert message box and replace with {{strategy.order.alert_message}} and nothing else
- the codes will be sent to the webhook appropriately as the strategy enters and exits positions. Only 1 alert is needed
settings used for the display image:
1hr chart on BTCUSD
-ATR stop
-Risk adjustment 1.2
-ATR multiplier 1.3
-RnR 0.6
-MAs HEMA/SMA
-MA Length 50/100
-Order size percent of equity
-Trail trigger 60% of target
Experiment with your own settings on your crypto of choice or implement your own code!
Implementing your trailing stop (optional)
Among the options for possible settings is a trailing stop. This stop will ratchet higher once triggered as a function of the Average True Range (ATR). There is a variable level to choose where the user would like to begin trailing the stop during the trade. The level can be assigned with a decimal between 0 and 1 (eg. 0.5 = 50% of the distance between entry and the target which must be exceeded before the trail triggers to begin). This can allow for some dips to occur during the trade possibly keeping you in the trade for longer, while potentially reducing risk of drawdown over time. The default for this setting is 0 meaning unless adjusted, the trail will trigger on entry if the trailing stop exit method is selected. An example can be seen below:
Again, optional as well is the choice to implement a limit order. If one were to select a trailing stop they could choose not to set a limit, which could allow a trail to run further until hit. Drawdowns of this strategy would be foregoing locking gains at highs on target on other trades. This is a trade-off the user can decide on and test. An example of this working in favor can be observed below:
Conclusion
Although a simple strategy is implemented here, the benefits of this script allow a user a starting platform to build their strategies from with built in risk mitigation. This allows the user to sidestep some of the potential difficulties' that can arise while learning Pine and taking on the endeavor of automating their trading strategies. It is meant as an aid, a structure, and an educational piece that can be seen as a "pick-up-and-go" strategy with easy 3Commas compatibility. Additionally, this can help users become more comfortable with strategy alert messages and sending strings in the form of alerts from Pine. As well, FAQs are often littered with questions regarding "strategy.exit" calls, how to implement stops. how to properly set a trailing stop based on ATR, and more. The time this can save an individual to get started is likely of the best "take-aways" here.
Happy trading
Crypto Scalper Divergence Macd Psar Ema 200This is a very efficient crypto scalper adapted to very short timeframes, however it can be optimized for other timeframes and assests as well.
Its components are
MACD
P SAR
EMA 200
Risk management
Rules for entry:
For short : we have an uptrend on PSAR , histogram is positive (divergence MACD) and close of a candle is below EMA 200
For long : we dont have an uptrend on PSAR, histogram is negative(divergence MACD) and close of a candle is above EMA 200
Rules for exit:
We exit when we either find a reverse condition than the entry one, or based on stop loss/take profit that are calculated on % movements of the price.
If you have any questions, let me know !
[VJ]Phoenix Force of PSAR +MACD +RSIThis is a simple intraday strategy for working on Stocks or commodities based out on PSAR, MACD , RSI and chop index . You can modify the start time and end time based on your timezones. Session value should be from market start to the time you want to square-off
Important: The end time should be at least 2 minutes before the intraday square-off time set by your broker
Comment below if you get good returns
Strategy: Entry Exits using PSAR and momentum and trend using MACD and RSI. A chop index is used as filtering
Indicators used :
Parabolic SAR is a technical indicator that is used to determine the price direction of stocks and it also draws attention to the traders when the price is changing
PSAR helps you:
Identify when a certain price trend is going to change direction
Indicate the most effective level at which to enter into the trade
Indicate the most effective exit point for the trade
Moving average convergence divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of a security's price. ... Traders may buy the security when the MACD crosses above its signal line and sell—or short—the security when the MACD crosses below the signal line
RSI is intended to chart the current and historical strength or weakness of a stock or market based on the closing prices of a recent trading period.
Buying/Selling
When trading with the parabolic SAR, you would buy a market when the dots move below the current asset price and are green in colour. Alternatively, you would sell a market when the dots move above the current asset price and are red in colour. We use MACD , RSI to ensure that a right trade is picked when PSAR gives an indication. CI is used to stay away from the range bound market as much as possible.
Usage & Best setting :
Choose a good volatile stock and a time frame - 5m.
MA length : 200
RSI threshold : 50
MACD: 12,26,9
There is stop loss and take profit that can be used to optimise your trade
The template also includes daily square off based on your time.
Av3Based on the ANNE EA v3 for MT4. For use on FOREX.
if ATR is greater than ATR average taken from last 5 candles, then market considered as trending, and so Open(0)>Close(1)=buy Open(0)Close(1)=sell Open(0)<Close(1)=buy.
If trending, then buy high & sell low, if consolidation then buy low sell high.
Exit is by trail and Take Profit.
PM me for edit or MT4 version info.
ROC_PA_Strategy (A3Sh)Hi there,
An experiment with rate of price change in combination with price averaging. The strategy is inspired by Price Change Scalping Strategy developed by Prosum Solutions and Scalping Dips On Trend Strategy developed by Coinrule. Both strategies look at the percentage of price change to open orders.
When the price drops beyond a specified percentage, a order entry threshold (yellow line) is setup. The order entry threshold is only active for a specified number of bars and will de-activate when not crossed within the specified number of bars. When the price drops further and crosses the entry threshold with a minimum of a specified percentage, a long position is entered. The same reverse logic (white line) used to close the long position.
I first ran the strategy without stop loss and take profit and that worked very well in a bullish market. I later added stop loss and take profit and that seems to work better in a side ways or bearisch market. There are a lot of tweaking possibilities in the settings.
In the settings you can specify the percentage of portfolio to use for each trade to spread the risk and for each order a trading fee of 0.075% is calculated.