Pyramiding Entries On Early Trends (by Coinrule)Pyramiding the entries in a trading strategy may be risky but at the same time very profitable with a proper risk management approach. This strategy seeks to spot early signs of uptrends and increase the position's size while the right conditions persist.
Each trade comes with its stop-loss and take-profit to enforce a proportional risk/reward profile.
The strategy uses a mix of Moving Average based setups to define the buy-signal.
The Moving Average (200) is above the Moving Average (100), which prevents from buying when the uptrend is already in its late stages
The Moving Average (9) is above the Moving Average (100), indicating that the coin is not in a downtrend.
The price crossing above the Moving Average (9) confirms the potential upside used to fire the buy order.
Each entry comes with a stop-loss and a take-profit in a ratio of 1-to-1. After over 400 backtests, we opted for a 3% TP and 3% SL, which provides the best results.
The strategy is optimized on a 1-hour time frame.
The Advantages of this strategy are:
It offers the possibility of adjusting the size of the position proportionally to the confidence in the possibilities that an uptrend will eventually form.
Low drawdowns. On average, the percentage of trades in profit is above 60%, and the stop-loss equal to the take-profit reduces the overall risk.
This strategy returned good returns both with trading pairs with Fiat/stable coins and with BTC. Considering the mixed trends that cryptocurrencies experienced during 2020 vs BTC, this strengthens the strategy's reliability.
The strategy assumes each order to trade 20% of the available capital and pyramids the entries up to 7 times.
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.
Pyramid
Strategy PyramiCoverStrategy for pyramidization and coverage. (Indicator PyramiCover)
Recommended time frame 60 min.
Total Trend Follow Study with Alerts, Pyramid and DCA
Introduction
This is the study version of my trend following strategy. It is designed to be a “drop in” replacement for its twin strategy. I have replicated the analysis logic and entry and exit procedures to produce a nearly identical result set to the strategy. Other than the properties tab, the inputs dialog is exactly the same. Backtest the strategy to determine the best inputs to trade. Then apply the same inputs to this study to forward test. Alerts are available for trade entry, take profit close, stop-loss exit and pyramid level. Please see the strategy version for a complete description of the trading behavior of this script.
In brief, this script is intended to benefit from long duration trending markets. The trading behavior is to buy on strength and sell on weakness. As such the trade orders maintain its directional bias according to price pressure. What you will see on the chart is long positions on the left side of the mountain and short on the right. Long and short positions are not intermingled as long as there exists a detectable trend. My trend following script uses the same pivot point calculations used by my range trader but this time rising pivots are long and falling pivots are short. I refer to pivots as a vertex in the inputs dialog box. The cone based measurement adds a peak, sides and a base to the calculation elements. This allows the inputs to focus on adjusting the location of trades and not just trend lines. The pivot points can be plotted on the backtest. You can use the vertex input values to move the pivots where you want trades to be. This script can be traded in four different modes: Long, Short, BiDir, and Flip Flop.
This script replicates the TradingView pyramid feature by adding a field to the inputs tab. Pyramiding works the same way in this script as its twin strategy. Each pyramid level increases the order size as a multiple of its level. This makes it easy to comply with NFA FIFO Rule 2-43(b) if the trades are executed here in America. The current pyramid level is reported in the summary label when reports are enabled. You can use this value to manually adjust the position size in your forward testing. I also expose an alert when the pyramid threshold is breached. Use the TradingView alert window to send yourself a message when the level increases.
In addition to pyramiding this script employs a DCA feature which can increase the order size in response to stopped out or winning streak trades. The number of losing trades is tracked through the “Debt Sequence” value displayed in the summary report. When the debt is recovered the sequence number resets to zero. You can use the “Debt Sequence” number to manually manage DCA on your forward test. The main difference between DCA and pyramids is that this implementation of DCA applies to new trades while pyramids affect open positions. If DCA is enabled be sure to set the limiter to prevent your account from depleting capital during runaway markets.
I also have a range trading version of this script for those not interested in trend following.
Design
This script is approximately 1800 lines of Pine 4 code and implements nine indicators on two time frames. The chart (primary) interval and one higher time frame which is based on the primary. The higher time frame identifies the trend for which the primary will trade. The original trading algorithms are a port from a much larger program on another trading platform. I've converted some of the statistical functions to use standard indicators available on TradingView. The setups make heavy use of the Hull Moving Average in conjunction with EMAs that form the Bill Williams Alligator as described in his book “New Trading Dimensions” Chapter 3. Lag between the Hull and the EMAs form the basis of the entry and exit points. The alligator itself is used to identify the trend main body.
Indicator Repainting
Indicator repainting is an industry wide problem which mainly occurs when you mix backtest data with real-time data. It doesn't matter which platform you use some form of this condition will manifest itself on your chart over time. The TradingView wiki has an in depth article on this subject in regard to the elements of the Pine language which contribute or are susceptible to this effect. In dealing with this problem from a prevention aspect in Pine, you have to accept some repaint to occur.
The goal of my repaint prevention in the study script is simply to ensure that my signal trading bias remains consistent between the strategy, study and broker. This actually turned out to be kind of a job since it interfered with another project goal to synchronize the entry and exits between the strategy and study scripts. The script execution engines are different between the Pine strategy and study. While the primary chart interval is quite manageable the higher time frame requires the security() function. TradingViewʼs higher time frame implementation, which interleaves the chart interval, combined with the critical “lookahead” parameter makes the solution necessarily complex. According the wiki regarding this issue, best practice comes down to the following two methods:
1. a = security(syminfo.tickerid, 'D', close , lookahead=barmerge.lookahead_on)
2. indexHighTF = barstate.isrealtime ? 1 : 0
indexCurrTF = barstate.isrealtime ? 0 : 1
a0 = security(syminfo.tickerid, 'D', close ,lookahead=barmerge.lookahead_off)
a = a0
This script employs method 2 with the only problem being the Pine sar() function which does not expose its internal bar series. The best work around would require hand coding the parabolic but the script is at the maximum local scopes and run-time duration so that option is not viable. So far, this hasn't proven to be much of a problem. I'm currently running several symbols, forex and crypto, the strategy and study remain highly correlated with no instances of completely opposite real-time signals. However, I have received some alerts with no corresponding plot on the chart but so far it only occurred on one symbol. I will continue to monitor this problem.
The Bottom Line. Does this script repaint. Yes, it will repaint about as much as every other multi-interval script which employs the best practice solutions available in the Pine Language.
Usage
Please be aware that the purpose of the study script is to perform forward testing of the configuration established in the backtest process. Therefore, the usage here in the study begins with the backtest configuration parameters. The following steps provide instructions to get this study script connected to the TradingView alert notification system. For a detailed description of how to create a trend following system using this script please see the strategy version.
Step 1. Create a chart with the trading instrument and interval used in the backtest.
Step 2. Find this script in the “Invite Only” section of the Indicators Dialog and apply it to the current chart.
Step 3. Copy the values from the backtest input dialog to the study.
Step 4. Open the TradingView Alert window.
Step 5. In the “Condition” drop down field find and select the name of the script.
Step 6. A new drop down field will appear with the alerts available in the script. This script exposes the following eight signals:
-- Long Entry Signal
-- Long Profit Signal
-- Long Stop-loss Signal
-- Long Pyramid
-- Short Entry Signal
-- Short Profit Signal
-- Short Stop-loss Signal
-- Short Pyramid
Select the signal for which you want notification.
Step 7. In the “Options” field select the frequency of the alert. Typically, "Once Per Bar" or "Once Per Bar Close" will be sufficient.
Step 8. Set the expiration date and time.
Step 9. Select the action of the alert. Currently TradingView offers six different actions:
-- Notify on App
-- Show Popup
-- Send Email
-- Webhook URL
-- Play Sound
-- Send Email to SMS
Step 10. Create a message to to transmitted with the alert. The script provides a default message which can be overridden with any custom description. The price, time and other reserved chart elements can be included in the message
Step 11. Click the “Create” button to generate this single alert.
Step 12. Repeat steps 1 through 11 for every signal you wish to receive.
This script is open for beta testing. After successful beta test it will become a commercial application available by subscription only. I’ve invested quite a lot of time and effort into making this the best possible signal generator for all of the instruments I intend to trade. I certainly welcome any suggestions for improvements. Thank you all in advance.
Total Trend Follow Strategy with Pyramid and DCA
Introduction
This is a Pine 4 trend following strategy. It has a twin study with several alerts. The design intent is to produce a commercial grade signal generator that can be adapted to any symbol and interval. Ideally, the script is reliable enough to be the basis of an automated trading system web-hooked to a server with API access to crypto, forex and stock brokerages. The strategy can be run in three different modes: long, short and bidirectional.
As a trend following strategy, the behavior of the script is to buy on strength and sell on weakness. As such the trade orders maintain its directional bias according to price pressure. What you will see on the chart is long positions on the left side of the mountain and short on the right. Long and short positions are not intermingled as long as there exists a detectable trend. This is extremely beneficial feature in long running bull or bear markets. The script uses multiple setups to avoid the situation where you got in on the trend, took a small profit but couldn’t get back in because the logic is waiting for a pullback or some other intricate condition.
Deep draw-downs are a characteristic of trend following systems and this system is no different. However, this script makes use of the TradingView pyramid feature accessible from the properties tab. Additional trades can be placed in the draw-down space increasing the position size and thereby increasing the profit or loss when the position finally closes. Each individual add on trade increases its order size as a multiple of its pyramid level. This makes it easy to comply with NFA FIFO Rule 2-43(b) if the trades are executed here in America. The inputs dialog box contains various settings to adjust where the add on trades show up, under what circumstances and how frequent if at all. Please be advised that pyramiding is an advanced feature and can wipe out your account capital if your not careful. During the backtest use modest setting with realistic capital until you discover what you think you can handle.
In addition to pyramiding this script employs DCA which enables users to experiment with loss recovery techniques. This is another advanced feature which can increase the order size on new trades in response to stopped out or winning streak trades. The script keeps track of debt incurred from losing trades. When the debt is recovered the order size returns to the base amount specified in the TV properties tab. The inputs for this feature include a limiter to prevent your account from depleting capital during runaway markets. The main difference between DCA and pyramids is that this implementation of DCA applies to new trades while pyramids affect open positions. DCA is a popular feature in crypto trading but can leave you with large “bags” if your not careful. In other markets, especially margin trading, you’ll need a well funded account and much experience.
Consecutive loss limit can be set to report a breach of the threshold value. Every stop hit beyond this limit will be reported on a version 4 label above the bar where the stop is hit. Use the location of the labels along with the summary report tally to improve the adaptability of system. Don’t simply fit the chart. A good trading system should adapt to ever changing market conditions. On the study version the consecutive loss limit can be used to halt live trading on the broker side (Managed manually).
Design
This script uses nine indicators on two time frames. The chart (primary) interval and one higher time frame which is based on the primary. The higher time frame identifies the trend for which the primary will trade. I’ve tried to keep the higher time frame around five times greater than the primary. The original trading algorithms are a port from a much larger program on another trading platform. I’ve converted some of the statistical functions to use standard indicators available on TradingView. The setups make heavy use of the Hull Moving Average in conjunction with EMAs that form the Bill Williams Alligator as described in his book “New Trading Dimensions” Chapter 3. Lag between the Hull and the EMAs form the basis of the entry and exit points. The alligator itself is used to identify the trend main body.
The entire script is around 1700 lines of Pine code which is the maximum incidental size given the TradingView limits: local scopes, run-time duration and compile time. I’ve been working on this script for over a year and have tested it on various instruments stocks, forex and crypto. It performs well on higher liquidity markets that have at least a year of historical data. Though it can be configured to work on any interval between 5 minutes and 1 day, trend trading is generally a longer term paradigm. For day trading the 10 to 15 minute interval will allow you to catch momentum breakouts. For intraweek trades 30 minutes to 1 hour should give you a trade every other a day. Four hours and above are for seasoned deep pocket traders. Originally, this script contained both range trading and trend following logic but had to be broken into separate scripts due to the aforementioned limitations.
Inputs to the script use cone centric measurements in effort to avoid exposing adjustments to the various internal indicators. The goal was to keep the inputs relevant to the actual trade entry and exit locations as opposed to a series of MA input values and the like. As a result the strategy exposes over 50 inputs grouped into long or short sections. Inputs are available for the usual minimum profit and stop-loss as well as safeguards, trade frequency, DCA, modes, presets, reports and lots of calibrations. The inputs are numerous, I’m aware. Unfortunately, at this time, TradingView does not offer any other method to get data in the script. The usual initialization files such as cnf, cfg, ini, json and xml files are currently unsupported.
Example configurations for various instruments along with a detailed PDF user manual is available.
Indicator Repainting And Anomalies
Indicator repainting is an industry wide problem which mainly occurs when you mix backtest data with real-time data. It doesn't matter which platform you use some form of this condition will manifest itself on your chart over time. The critical aspect being whether live trades on your broker’s account continue to match your TradingView study. Since this trading system is featured as two separate scripts, indicator repainting is addressed in the study version. The strategy (this script) is intended to be used on historical data to determine the appropriate trading inputs to apply in the study. As such, the higher time frame of this strategy will indeed repaint. Please do not attempt to trade from the strategy. Please see the study version for more information.
One issue that comes up when comparing the strategy with the study is that the strategy trades show on the chart one bar later than the study. This problem is due to the fact that “strategy.entry()” and “strategy_exit()” do not execute on the same bar called. The study, on the other hand, has no such limitation since there are no position routines. However, alerts that are subsequently fired off when triggered in the study are dispatched from the TradingView servers one bar later from the study plot. Therefore the alert you actually receive on your cell phone matches the strategy plot but is one bar later than the study plot. A lot can happen in four hours if you are trading off a 240 bar.
Please be aware that the data source matters. Cryptocurrency has no central tick repository so each exchange supplies TradingView its feed. Even though it is the same symbol the quality of the data and subsequently the bars that are supplied to the chart varies with the exchange. This script will absolutely produce different results on different data feeds of the same symbol. Be sure to backtest this script on the same data you intend to receive alerts for. Any example settings I share with you will always have the exchange name used to generate the test results.
Usage
The following steps provide a very brief set of instructions that will get you started but will most certainly not produce the best backtest. A trading system that you are willing to risk your hard earned capital will require a well crafted configuration that involves time, expertise and clearly defined goals. As previously mentioned, I have several example configs that I use for my own trading that I can share with you along with a PDF which describes each input in detail. To get hands on experience in setting up your own symbol from scratch please follow the steps below.
The input dialog box contains over 50 inputs separated into seven sections. Each section is identified as such with a makeshift separator input. There are three main areas that must to be configured: long side, short side and settings that apply to both. The rest of the inputs apply to pyramids, DCA, reporting and calibrations. The following steps address these three main areas only. You will need to get your backtest in the black before moving on to the more advanced features
Step 1. Setup the Base currency and order size in the properties tab.
Step 2. Select the calculation presets in the Instrument Type field.
Step 3. Select “No Trade” in the Trading Mode field.
Step 4. Select the Histogram indicator from section 3. You will be experimenting with different ones so it doesn’t matter which one you try first.
Step 5. Turn on Show Markers in Section 3.
Step 6. Go to the chart and checkout where the markers show up. Blue is up and red is down. Long trades show up along the blue markers and short trades on the red.
Step 7. Make adjustments to Base To Vertex and Vertex To Base net change and roc in section 3. Use these fields to move the markers to where you want trades to be. Blue is long and red is short.
Step 8. Try a different indicator from section 3 and repeat Step 7 until you find the best match for this instrument on this interval. This step is complete when the Vertex settings and indicator combination produce the most favorable results.
Step 9. Turn off Show Markers in Section 3.
Step 10. Enable the Symmetrical and Deviation calculation models at the top of section 5 and 6 (Symmetrical, Deviation).
Step 11. Put in your Minimum Profit and Stop Loss in the first section. This is in pips or currency basis points (chart right side scale)
Step 12. Return to step 3 and select a Trading Mode (Long, Short, BiDir, Flip Flop). If you are planning to trade bidirectionally its best to configure long first then short. Combine them with BiDir or Flip Flop after setting up both sides of the trade individually.
Step 13. Trades should be showing on the chart.
Step 14. Make adjustments to the Vertex fields in section 3 until the TradingView performance report is showing a profit.
Step 15. Change indicators and repeat step 14. Pick the best indicator.
Step 16. Use the check boxes in sections 5 and 6 to improve the performance of each side.
Step 17. Try adding the Correlation calculation model to either side. This model can sometimes produce a negative result but can be improved by enabling “Adhere To Markers” or “Narrow Correlation Scope” in the sections 5 and 6.
Step 18. Enable the reporting conditions in section 7. Look for long runs of consecutive losses or high debt sequences. These are indications that your trading system cannot withstand sudden changes in market sentiment.
Step 19. Examine the chart and see that trades are being placed in accordance with your desired trading model.
Step 20. Apply the backtest settings to the study version and perform forward testing.
This script is open for beta testing. After successful beta test it will become a commercial application available by subscription only. I’ve invested quite a lot of time and effort into making this the best possible signal generator for all of the instruments I intend to trade. I certainly welcome any suggestions for improvements. Thank you all in advance.
Renko/Linebreak Pyramiding StrategyPrivate strategy created for and in collaboration with TV user: kaiji_
This strategy employs either a Renko or Linebreak version of the current tickerid and places orders based on configurable criteria, optionally increasing winning positions as long as they remain profitable before closing on trailing stops.
[Tutorial] RSIwings (swings) for find pyramiding entries ->hh,llThis indicator show higher high + higher low and lower high + lower low -> based on RSI modification.
HOW I USE
On a longsetup I set a buyorder on the high, if the RSI swings show red the first time. My stoploss I choose on the lowest price from the red swing before.
After every ending bar without tradeentry I move the buyorder step by step on the last high till the price move up and the longtrade start.
The same game I use for sellorder with the green swings, if I want a shortsetup. Best times for this are retracements from a trendchannel i.e.
HOW I PYRAMIDING
From swing to swing with the same color I move my stoploss. If my risk are 100 USD and with the next moving stoploss are only 60 USD in risk, then I have 40 USD for my next pyramiding trade in the same trendsetup.
WHEN I MOVE MY STOPLOSS
If I have choose a stoploss, than this is fixed till the last highest/lowest price from the other swing is broken.
Any questions? Ask me!
Multi Bollinger Bands V7 [SuperTrend Color]
Multi Bollinger Bands V7 is for trading volatility and trend .
You can user Multi Bollinger Bands V7 for Pyramid Trading