Dollar cost averaging trading system (DCA)As investors, we often face the dilemma of willing high stock prices when we sell, but not when we buy. There are times when this dilemma causes investors to wait for a dip in prices, thereby potentially missing out on a continual rise. This is how investors get lured away from the markets and become tangled in the slippery slope of market timing, which is not advisable to a long-term investment strategy.
Skyrex developed a complex trading system based on dollar-cost averaging in Quick Fingers Luc's interpretation. It is a combinations of strategies which allows to systematically accumulate assets by investing scaled amounts of money at defined market cycle global support levels. Dollar-cost averaging can reduce the overall impact of price volatility and lower the average cost per asset thus even during market slumps only a small bounce is required to reach take profit.
The strategy script monitors a chart price action and identifies bases as they form. When bases are reached the script provides entry actions. During price action development an asset value can go lower and in this way the script will perform safety entries at each subsequent accumulation levels. When weighted average entry price reaches target profit the script will perform a take profit action.
Bases are identified as pivot lows in a fractal pattern and validated by an adjustable decrease/rise percentage to ensure significancy of identified bases. To qualify a pivot low, the indicator will perform the following validation:
Validate the price rate of change on drops and bounces is above a given threshold amount.
Validate the volume at the low pivot point is above the volume moving average (using a given length).
Validate the volume amount is a given factor of magnitude above is above the volume moving average.
Validate the potential new base is not too close to the previous range by using a given price percent difference threshold amount.
A fractal pattern is a recurring pattern on a price chart that can predict reversals among larger, more chaotic price movements.
These basic fractals are composed of five or more bars. The rules for identifying fractals are as follows:
A bearish turning point occurs when there is a pattern with the highest high in the middle and two lower highs on each side.
A bullish turning point occurs when there is a pattern with the lowest low in the middle and two higher lows on each side.
Basic dollar-cost averaging approach is enhances by implementation of adjustable accumulation levels in order to provide opportunity of setting them at defined global support levels and Martingale volume coefficient to increase averaging effect. According to Quick Fingers Luc's principles trading principles we added volume validation of a base because it allows to confirm that the market is resistant to further price decrease.
The strategy supports traditional and cryptocurrency spot, futures, options and marginal trading exchanges. It works accurately with BTC, USD, USDT, ETH and BNB quote currencies. Best to use with 1H timeframe charts and limit orders. The strategy can be and should be configured for each particular asset according to its global support and resistance levels and price action cycles. You can modify levels and risk management settings to receive better performance
Advantages of this script:
Strategy has high net profit of 255% at backtests
Backtests show high accuracy around 75%
Low Drawdowns of around 14% at backtests
Strategy is sustainable to market slumps and can be used for long-term trading
The strategy provides a large number of entries which is good for diversification
Can be applied to any market and quote currency
Easy to configure user interface settings
How to use?
1. Apply strategy to a trading pair your are interested in using 1H timeframe chart
2. Configure the strategy: change layer values, order size multiple and take profit/stop loss values according to current market cycle stage
3. Set up a TradingView alert to trigger when strategy conditions are met
4. Strategy will send alerts when to enter and when to exit positions which can be applied to your portfolio using external trading platforms
5. Update settings once market conditions are changed using backtests on a monthly period
Portfolio Management
Key Performance IndicatorWe are happy to introduce the Key Performance Indicator by Detlev Matthes. This is an amazing tool to quantify the efficiency of a trading system and identify potential spots of improvement.
Abstract
A key performance indicator with high explanatory value for the quality of trading systems is introduced. Quality is expressed as an indicator and comprises the individual values of qualitative aspects. The work developing the KPI was submitted for the 2017 VTAD Award and won first prize.
Introduction
Imagine that you have a variety of stock trading systems from which to select. During backtesting, each trading system will deliver different results with regard to its indicators (depending on, inter alia, its parameters and the stock used). You will also get different forms of progression for profit development. It requires great experience to select the “best” trading system from this variety of information (provided by several indicators) and significantly varying equity progression forms. In this paper, an indicator will be introduced that expresses the quality of a trading system in just one figure. With such an indicator, you can view the results of one backtest at a glance and also more easily compare a variety of backtesting results with one another.
If you are interested in learning more about the calculations behind this indicator then I have included a link to the english version of his research paper.
Along with this, we now offer indicator development services. If you are interested in learning more then feel free to reach out to get a quote for your project.
**Please note that we have NOT inputted any real strategy into the code and therefore it is not producing any real value. Feel free to change the code as desired to test any strategy!**
drive.google.com
RELATIVE VALUE TRADE MANAGEMENT WEBHOOKThis script it's created to send open-close signals via webhook. It allows you to open a relative value position based in the relative graph. You can set the TP and SL levels and the script will send the signal to your exchange.
Due a pine limitations it is necessary apply the script in the 2 different actives and set the alerts. You can just do the relative analysis and then go to the first asset and set the script. Create your alert and then just go to the other asset and create the alert. It doesn't necessary to change anything in the script because the levels are the same.
It is also possible to do the analysis using the script, deploying the relative graph, but could be annoying sometimes due scales.
Positions will be placed at close always.
THIS IS IMPORTANT: I use Zignaly as a exhange so if you are using Binance or other YOU MUST CHANGE the code. If you know the JSON format that It requires would be easy.
Here is tips in all the important imputs. But let me explain the most important.
The MANDATORY fields are:
Ticker IDs: Here you must write the EXACT ID code for the active. Caps included.
Example : BINANCE:SUSHIUSDTPERP
It is also important select the correct market side. If you want to be long of ANY active you must write that ID in the LONG ID. For short positions is the same.
Time frame: Here you can select the time frame of the graph (not the current active graph, I mean the relative one.) The orders will be send using that time frame. I recommend to do the analysis in other window and then use the script to trigger the order in the time frame that you want.
Money management: In these fields you can select the qty that you will lose if the SL level is reach. Based in a determinated amount of currency or in a % of your capital.
Dates: It is important to select the start date. If the order is already open, we must look for the moment where the activation price was reached. If the order is unopened it is better to select the current date, so the order will be triggered when the entry level is reached.
Ids: If you have current open position you can set here that ID to send the correct order to the exchange.
To set the alert just call the function {{{strategy.order.alert_message}}}
Strategy Multiple Orders + Statistics Template - EducationalHello traders
It's been a while
We're back in a bear market so I have a bit more time to publish new Pine scripts for the TradingView community
Special thanks to @fikira for his Multiple Orders script () and to @carnagecain for allowing me to publish this script we worked together on
I got widely inspired by @fikira's script for that one
This script is for educational purposes only - I wanted to show how we can add multiple TPs/SL + a table with custom statistics
In this Strategy template, users can define multiple take-profit and multiple stop-loss levels.
Basically, we have 4 trades per trend and each trade has its own SL/TP
Statistics
Stats are split per trade direction (Long, Short) and then consolidated
I put custom stats in that table such as:
- Probability of Win
- Probability of Loss
- Avg Profit/Loss per Trade
- APPT: (Probability of Win * Average Gross Profit) - (Probability of Loss * Average Loss)
- Number of times each TP/SL has been hit
I'm catching up with all recent pinescript features as we speak - more educational scripts template to come soon
Best Regards
Dave
Solution Zigma - Fibonacci Impulse'Solution Zigma' is strategy for any securities because this strategy use EMA of Fibonacci Level and Plot Like candle easy for analysis trend impulse. This strategy used DMI(ADX) for filter sideway but not greatest indicator, Please use this strategy with Risk Management.
Swing Stock designed for Monthly/Yearly Trading This is a strategy tester designed around the most important data from FRED - Federal Reserve Economic Data
As input data, we have:
// Personal Consumption Expenditures
// Real Retail and Food Services Sales
// Leading Index for the United States
// All Employees: Total Nonfarm Payrolls
// Real Gross Domestic Product
// Gross Domestic Product
I adapted the long and short entry based on the GDP data, since they are most accurate in prediction compared to the rest.
However, feel free to test with other as well if you want.
For this test I compared previous GDP values, if they were higher than previous that represent a long signals, if they were smaller that represents a reversal=short signal.
From the tests performed we can see that GDP is highly accurate and overall as long as there is patience, profits are going to be make, sometimes even beat the index itself.
If you have any questions, let me know !
MilleMachineHello traders,
I hereby present to you the second stage of my journey to finding a reliable, profitable trading strategy.
The "Millemachine" is based on the "Millebot", my previous published strategy. This means the backbone of the strategy is still the same: a trend following system. Instead of using a fixed TP and SL, a trailing stoploss is now used. To limit the losses when the trend weakens, the trailing stoploss automatically gets smaller, as it is based on the ATR.
A new utility is you can now easily switch between indicators on which the decision making is based. This allows the user to discover which indicators work best for entry, long/short switching and stoploss configuration.
The strategy has been proven to be very profitable in trending markets, but can suffer losses during ranging market. To make the system more robust, the strategy cannot solely rely on a trending system. Other systems must be added.
I believe that a good trading bot must consist of more than 4 different strategies, based on different systems. This is what I am currently working on.
My goal for publishing this strategy is to help other traders build their own. In my journey I found it difficult to find a good strategy that employs a decent risk management, which is truly essential for having good, consistent results. Also, a realistic commission needs to be defined to have a realistic performance prediction. This weighs on the profitability and therefore is often set at 0 by authors of other strategies, which I find misleading.
If you have found this strategy informative or useful, please leave a comment.
Greetings Michael
Trading the Equity Curve Position Sizing Example"Trading the equity curve" as a risk management method is the process of acting on trade signals depending on whether a system’s performance is indicating the strategy is in a profitable or losing phase.
The point of managing equity curve is to minimize risk in trading when the equity curve is in a downtrend. This strategy has two modes to determine the equity curve downtrend: By creating two simple moving averages of a portfolio's equity curve - a short-term and a longer-term one - and acting on their crossings. If the fast SMA is below the slow SMA, equity downtrend is detected (smafastequity < smaslowequity).
The second method is by using the crossings of equity itself with the longer-period SMA (equity < smasloweequity).
When Trading with the Equity Curve" is active, the position size will be reduced by a specified percentage if the equity is "under water" according to a selected rule. If you're a risk seeker, select "Increase size by %" - for some robust systems, it could help overcome their small drawdowns quicker.
GRID Trading Optimized for Directional MarketsGRID trading is a popular trading strategy in Forex and Commodity markets.
It it however a tricky strategy when markets become directional.
This Directional GRID system adjusts its trading strategy and direction based on Overbought and Oversold RSI conditions on 2 timeframes.
It uses the short timeframe (chart) to trigger adjustments, so it delays buying/selling of all the levels, until it becomes overbought/sold
And it used the longer timeframe to trigger trading direction long/short.
This makes it far less likely to ever get "underwater", and builds in extra profit potential during market extremes.
I have coded it when i was trading SLV, but it could be optimized for any market using a "TradingView Strategy Input Optimizer".
Backtest based on a 25k max capital investment during 6 months.
Check the NET Profit (50%) result, and compare against the Buy & Hold (13.5%) return.
Losing trades are the ones that are currently open..
Av Bars in trades is the time between direction changes, as Position Adjustments are done more frequently.
Contact me for Trading Automation As A Service.
SuperTrend Multiple Risk Management SystemThis is an improved SuperTrend strategy that makes use of multiple types of risk management options.
We have for example :
1. Take profit and stop loss levels based on support and resistence created with RSI and Pivot Lines(dynamic)
For example, if we have an oversold level and a pivot low , we can take that low point for support.(or resistence for short)
If instead we have an overbought level and a pivot high, we can take that high point for resistence.(orsupport for short)
2. Take profit and stop loss levels based on swing low and swing high points calculated with highest high and lowest low function(dynamic)
For example we take the lowest point in the last 100 candles. We calculate the distance from the current point to that one, and we apply this value as a take profit point. Same for stop loss
3. Take profit and stop loss levels based on % movements(fixed)
For example we have a tp or sl of 10%. If either of them make a movement of 10% from the entry point, they will get triggered.
4. Break even stop loss once the asset moves certain % in our direction.
For example we have a long breakeven of 5%. If the asset moves 5% in our direction, we move the stop loss on the entry point so if the trade pullback and crosses with this point it will exit from the trade.
Notes:
All the exits from the strategy are happening at the end of the candle close, since we are checking if inside the current candle we cross with either high or low of the candles parts the set prices from any of the above options.
At the same time we can combine multiple of them into one, and we can either exit based on which one was hit first, or use a quantity reduction of the trade and exit multiple times when we hit any of the levels.
This tool is for educational purpose only.
Its main purpose is to show the difference between having a risk management or without.
For example on this scenario of BTC USD 4h, I found out that the drawdawn was reduced by more than half when using different type of risk management, compared to not use one at all, while at the same time increasing the profits by a huge margin.
Overnight Gap AnalysisThere is a wide range of opinion on holding positions overnight due to gap risk. So, out of curiosity, I coded this analysis as a strategy to see what the result of only holding a position overnight on an asset would be. The results really surprised me. The script backtests 10+ years, and here are the findings:
Holding a position for 1 hour bar overnight on QQQ since January 2010 results in a 545% return. QQQ's entire return holding through the same period is 643%
The max equity drawdown on holding that position overnight is lower then the buy/hold drawdown on the underlying asset.
It doesn't matter if the last bar of the day is green or red, the results are similar.
It doesn't matter if it is a bull or bear market. Filtering the script to only trade when the price is above the 200-day moving average actually reduces its return from 545% to 301%, though it does also reduce drawdown.
I see similar patterns when applying the script to other index ETFs. Applying it to leveraged index ETFs can end up beating buy/hold of the underlying index.
Since this script holds through the 1st bar of the day, this could also speak to a day-opening price pattern
The default inputs are for the script to be applied to 1 hour charts only that have 7 bars on the chart per day. You can apply it to other chart types, but must follow the instructions below for it to work properly.
What the script is doing :
This script is buying the close of the last bar of the day and closing the trade at the close of the next bar. So, all trades are being held for 1 bar. By default, the script is setup for use on a 1hr chart that has 7 bars per day. If you try to apply it to a different timeframe, you will need to adjust the count of the last bar of the day with the script input. I.e. There are 7 bars per day on an hour chart on US Stocks/ETFs, so the input is set to 7 by default.
Other ways this script can be used :
This script can also test the result of holding a position over any 1 bar in the day using that same input. For instance, on an hour chart you can input 6 on the script input, and it will model buying the close of the 6th bar of the day while selling on the close of the next bar. I used this out of curiosity to model what only holding the last bar of the day would result in. On average, you lose money on the last bar every day.
The irony here is that the root cause of this last bar of the day losing may be people selling their positions at the end of day so that they aren't exposed to overnight gap risk.
Disclaimer: This is not financial advice. Open-source scripts I publish in the community are largely meant to spark ideas that can be used as building blocks for part of a more robust trade management strategy. If you would like to implement a version of any script, I would recommend making significant additions/modifications to the strategy & risk management functions. If you don’t know how to program in Pine, then hire a Pine-coder. We can help!
Strategy - Cryptosystem NNFX wayFirst script done!
This is my version of the No-Nonsense Forex (NNFX) Strategy
This strategy shows you the entry and exit signal with a standard 1.5 x ATR for Stop Loss and 1 x ATR for Taking Profit. You can adjust the settings to your needs.
This strategy uses 5 indicators:
1. Average True Range for SL and TP placement, there is a nuance where you can add the 1XATR Rule;
2. SMA used to filter longs and shorts;
3. SSL Channel for 1st Confirmation;
4. DPO for 2nd Confirmation;
5. Waddah Attar Explosion as a volume indicator.
There is no exit indicator because I coded 2 trades (2x0.5). TP1 will be at 1xATR and TP2 will automatically trail behind with 1.5XATR. You can see the red trailing line on the charts.
Other exits can be: When SSL gives opposite signal or when price crosses and closes your baseline.
I used this system for 1D timeframe.
Hopefully this can be usefull for your tradingstyle.
Would be great if you guys leave a like.
Thanks!
Crypto Spot Market Bot | BacktestHello Friends.
This script is only for long positions.
How does the algorithm work ?
The Relative Momentum Index
Relative Strength İndex
Average Directional Movement İndex
Momentum
When rsi and adx produce signals in the same direction, the rmi indicator confirms the signal. After the Confirmed Signal, the buy-side transaction is entered , the closed according to the % of profit taking and stoploss specified on the algorithm in the entered transaction.
In the spot market, it is possible to make money even in a down trend
All shared charts run within a 1-hour time frame.
Note : The shared backtest results have been shared as of 9/9/2021 by calculating 50% balance and 2 pyramiding methods in an account of 1000 dollars. Keep in mind that this algorithm will want to try to average down in possible worst-case scenarios. 2% - %3take profit levels will provide consecutive gains in the spot market.
How should the adjustments be made?
Value variables should be made according to formula a and formula b values and backtest results. You can increase the frequency of transactions by lowering the adx and rsi values.
Overview :
Portfolio Performance - Effects of RebalancingFunction:
- Can be used to evaluate the performance of a portfolio containing 2 assets over a set time interval
- Shows the % return of the portfolio over the time interval defined by the user
- Includes a threshold rebalancing algorithm to show the effects that rebalancing has on the portfolio over the long term
- Created to evaluate of the performance of portfolios containing different weightings of stocks and bonds over time assuming that the user would rebalance the portfolio when asset weights crossed a threshold
Instructions:
- To be used with dividends adjustments turned on
- Add this script to a symbol. e.g. AMEX:SPY
- Click the chart to define the entry time and the exit time. i.e. the time interval
- Define the initial investment of the portfolio. Default setting is $100,000
- Define the second asset to be included in the portfolio. e.g. BATS:AGG
- The strategy comes pre-populated with a portfolio that has a weight of 80% asset 1 and 20% asset 2. i.e. 80% AMEX:SPY and 20% BATS:AGG if the symbols mentioned above were chosen
- The 7 lines show the weighted % return of each portfolio over the time period defined by the user
- Each line (except the blue) is the return based on a different rebalancing threshold. The default settings are 1%, 2.5%, 5%, 10%, 15%, 20%, 30%
- The blue line is the % return of a portfolio that was made up of 100% asset 1 over the time interval. i.e. 100% AMEX:SPY
- Asset weights and rebalancing thresholds are adjustable via the settings
- Each plot can be turned on and turned off via a tick box in the settings
Portfolio Performance - 2 AssetsFunction:
- Can be used to evaluate the performance of portfolios containing 2 assets over a set time interval
- Created to evaluate of the performance of portfolios containing different weightings of stocks and bonds over time
- Shows the % return of each portfolio over the time interval defined by the user
- Capable of showing the risk adjusted % return of each portfolio over the time interval defined by the user (setting turned off by default)
Instructions:
- To be used with dividends adjustments turned on
- Add this script to a symbol. e.g. NASDAQ:BND
- Click the chart to define the entry time and the exit time. i.e. the time interval
- Define the second asset to be included in the portfolio. e.g. AMEX:VOO
- The strategy comes pre-populated with 6 portfolios with the most common stock/bond weightings (100% stocks/0% bonds, 80% stocks/20% bonds, 60% stocks/40% bonds, et cetera)
- The 6 lines show the weighted % return of each portfolio over the time period defined by the user
- All asset weights are adjustable via the settings
- Each plot can be turned on and turned off via a tick box in the settings
- There are 6 plots that show the risk adjusted returns of each portfolio (setting turned off by default)